From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uc4x0-0002n9-Ar for qemu-devel@nongnu.org; Mon, 13 May 2013 22:26:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uc4wy-0003Oq-86 for qemu-devel@nongnu.org; Mon, 13 May 2013 22:26:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uc4wy-0003Om-04 for qemu-devel@nongnu.org; Mon, 13 May 2013 22:26:48 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4E2QlWj021228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 May 2013 22:26:47 -0400 From: Fam Zheng Date: Tue, 14 May 2013 10:26:21 +0800 Message-Id: <1368498390-20738-3-git-send-email-famz@redhat.com> In-Reply-To: <1368498390-20738-1-git-send-email-famz@redhat.com> References: <1368498390-20738-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 02/11] curl: change magic number to macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, Fam Zheng , stefanha@redhat.com String field length is duplicated in two places. Make it a macro. Signed-off-by: Fam Zheng --- block/curl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/curl.c b/block/curl.c index 14f4552..aa78086 100644 --- a/block/curl.c +++ b/block/curl.c @@ -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); DPRINTF("CURL (AIO): Reading %d at %zd (%s)\n", (acb->nb_sectors * SECTOR_SIZE), start, state->range); curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range); -- 1.8.1.4