[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 02/11] curl: change magic number to macro
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v2 02/11] curl: change magic number to macro |
Date: |
Tue, 14 May 2013 10:04:31 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, May 14, 2013 at 10:26:21AM +0800, Fam Zheng wrote:
> @@ -70,7 +70,8 @@ typedef struct CURLState
> size_t buf_start;
> size_t buf_off;
> size_t buf_len;
> - char range[128];
> +#define CURL_RANGE_SIZE 128
> + char range[CURL_RANGE_SIZE];
> char errmsg[CURL_ERROR_SIZE];
> char in_use;
> } CURLState;
> @@ -567,7 +568,7 @@ static void curl_readv_bh_cb(void *p)
> state->orig_buf = g_malloc(state->buf_len);
> state->acb[0] = acb;
>
> - snprintf(state->range, 127, "%zd-%zd", start, end);
> + snprintf(state->range, CURL_RANGE_SIZE - 1, "%zd-%zd", start, end);
Simpler solution: sizeof(state->range) - 1
Then you don't need to introduce "CURL_RANGE_SIZE" which risks
conflicting with libcurl's namespace.
- [Qemu-devel] [PATCH v2 00/11] curl: fix curl read, Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 01/11] curl: introduce CURLSockInfo to BDRVCURLState., Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 02/11] curl: change magic number to macro, Fam Zheng, 2013/05/13
- Re: [Qemu-devel] [PATCH v2 02/11] curl: change magic number to macro,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH v2 03/11] curl: change curl_multi_do to curl_fd_handler, Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 04/11] curl: fix curl_open, Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 05/11] curl: add timer to BDRVCURLState, Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 06/11] curl: introduce CURLDataCache, Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 07/11] curl: make use of CURLDataCache., Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 08/11] curl: use list to store CURLState, Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 09/11] curl: release everything on curl_close, Fam Zheng, 2013/05/13
- [Qemu-devel] [PATCH v2 10/11] curl: add cache quota., Fam Zheng, 2013/05/13