Patchwork [v3,02/10] curl: change magic number to sizeof

login
register
mail settings
Submitter Fam Zheng
Date May 20, 2013, 7:03 a.m.
Message ID <1369033424-14594-3-git-send-email-famz@redhat.com>
Download mbox | patch
Permalink /patch/244853/
State New
Headers show

Comments

Fam Zheng - May 20, 2013, 7:03 a.m.
String field length is duplicated in two places. Make it a sizeof.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/curl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/block/curl.c b/block/curl.c
index 0aede58..901deb2 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -567,7 +567,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, sizeof(state->range) - 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);