From: Richard Russon Date: Tue, 3 Apr 2018 12:49:15 +0000 (+0100) Subject: cppcheck: printf format X-Git-Tag: neomutt-20180512~65^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64e3d8a669efe4573d6eba5ff8baa92809c4e2f4;p=neomutt cppcheck: printf format --- diff --git a/mh.c b/mh.c index 094515895..35e47ea8f 100644 --- a/mh.c +++ b/mh.c @@ -1709,7 +1709,7 @@ static int mh_commit_msg(struct Context *ctx, struct Message *msg, while (true) { hi++; - snprintf(tmp, sizeof(tmp), "%d", hi); + snprintf(tmp, sizeof(tmp), "%u", hi); snprintf(path, sizeof(path), "%s/%s", ctx->path, tmp); if (mutt_file_safe_rename(msg->path, path) == 0) { diff --git a/newsrc.c b/newsrc.c index b652d3fae..1aed72288 100644 --- a/newsrc.c +++ b/newsrc.c @@ -471,9 +471,9 @@ int nntp_newsrc_update(struct NntpServer *nserv) if (j) buf[off++] = ','; if (nntp_data->newsrc_ent[j].first == nntp_data->newsrc_ent[j].last) - snprintf(buf + off, buflen - off, "%d", nntp_data->newsrc_ent[j].first); + snprintf(buf + off, buflen - off, "%u", nntp_data->newsrc_ent[j].first); else if (nntp_data->newsrc_ent[j].first < nntp_data->newsrc_ent[j].last) - snprintf(buf + off, buflen - off, "%d-%d", + snprintf(buf + off, buflen - off, "%u-%u", nntp_data->newsrc_ent[j].first, nntp_data->newsrc_ent[j].last); off += strlen(buf + off); } @@ -639,7 +639,7 @@ int nntp_active_save_cache(struct NntpServer *nserv) buflen *= 2; mutt_mem_realloc(&buf, buflen); } - snprintf(buf + off, buflen - off, "%s %d %d %c%s%s\n", nntp_data->group, + snprintf(buf + off, buflen - off, "%s %u %u %c%s%s\n", nntp_data->group, nntp_data->last_message, nntp_data->first_message, nntp_data->allowed ? 'y' : 'n', nntp_data->desc ? " " : "", nntp_data->desc ? nntp_data->desc : ""); @@ -712,7 +712,7 @@ void nntp_hcache_update(struct NntpData *nntp_data, header_cache_t *hc) if (current >= nntp_data->first_message && current <= nntp_data->last_message) continue; - snprintf(buf, sizeof(buf), "%d", current); + snprintf(buf, sizeof(buf), "%u", current); mutt_debug(2, "mutt_hcache_delete %s\n", buf); mutt_hcache_delete(hc, buf, strlen(buf)); } diff --git a/nntp.c b/nntp.c index 3f2f7b3ed..219ddb718 100644 --- a/nntp.c +++ b/nntp.c @@ -1144,7 +1144,7 @@ static int parse_overview_line(char *line, void *data) char buf[16]; /* try to replace with header from cache */ - snprintf(buf, sizeof(buf), "%d", anum); + snprintf(buf, sizeof(buf), "%u", anum); void *hdata = mutt_hcache_fetch(fc->hc, buf, strlen(buf)); if (hdata) { @@ -1243,7 +1243,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, if (!ctx->quiet) mutt_message(_("Fetching list of articles...")); if (nntp_data->nserv->hasLISTGROUPrange) - snprintf(buf, sizeof(buf), "LISTGROUP %s %d-%d\r\n", nntp_data->group, first, last); + snprintf(buf, sizeof(buf), "LISTGROUP %s %u-%u\r\n", nntp_data->group, first, last); else snprintf(buf, sizeof(buf), "LISTGROUP %s\r\n", nntp_data->group); rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_numbers, &fc); @@ -1258,7 +1258,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, if (fc.messages[current - first]) continue; - snprintf(buf, sizeof(buf), "%d", current); + snprintf(buf, sizeof(buf), "%u", current); if (nntp_data->bcache) { mutt_debug(2, "#1 mutt_bcache_del %s\n", buf); @@ -1289,7 +1289,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, mutt_progress_update(&fc.progress, current - first + 1, -1); #ifdef USE_HCACHE - snprintf(buf, sizeof(buf), "%d", current); + snprintf(buf, sizeof(buf), "%u", current); #endif /* delete header from cache that does not exist on server */ @@ -1354,7 +1354,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, break; } - snprintf(buf, sizeof(buf), "HEAD %d\r\n", current); + snprintf(buf, sizeof(buf), "HEAD %u\r\n", current); rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_tempfile, fp); if (rc) { @@ -1373,7 +1373,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, /* no such article */ if (nntp_data->bcache) { - snprintf(buf, sizeof(buf), "%d", current); + snprintf(buf, sizeof(buf), "%u", current); mutt_debug(2, "#3 mutt_bcache_del %s\n", buf); mutt_bcache_del(nntp_data->bcache, buf); } @@ -1416,7 +1416,7 @@ static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first, if (current <= last && rc == 0 && !nntp_data->deleted) { char *cmd = nntp_data->nserv->hasOVER ? "OVER" : "XOVER"; - snprintf(buf, sizeof(buf), "%s %d-%d\r\n", cmd, current, last); + snprintf(buf, sizeof(buf), "%s %u-%u\r\n", cmd, current, last); rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, parse_overview_line, &fc); if (rc > 0) { @@ -1901,7 +1901,7 @@ static int check_mailbox(struct Context *ctx) if (anum >= first && anum <= nntp_data->last_loaded) messages[anum - first] = 1; - snprintf(buf, sizeof(buf), "%d", anum); + snprintf(buf, sizeof(buf), "%u", anum); hdata = mutt_hcache_fetch(hc, buf, strlen(buf)); if (hdata) { @@ -1947,7 +1947,7 @@ static int check_mailbox(struct Context *ctx) if (messages[anum - first]) continue; - snprintf(buf, sizeof(buf), "%d", anum); + snprintf(buf, sizeof(buf), "%u", anum); hdata = mutt_hcache_fetch(hc, buf, strlen(buf)); if (hdata) { @@ -2470,7 +2470,7 @@ int nntp_check_children(struct Context *ctx, const char *msgid) cc.child = mutt_mem_malloc(sizeof(anum_t) * cc.max); /* fetch numbers of child messages */ - snprintf(buf, sizeof(buf), "XPAT References %d-%d *%s*\r\n", + snprintf(buf, sizeof(buf), "XPAT References %u-%u *%s*\r\n", nntp_data->first_message, nntp_data->last_loaded, msgid); rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_children, &cc); if (rc)