From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Mike McCormack" <mike@codeweavers.com>,
"Benjamin Kramer" <benny.kra@googlemail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [RFC/PATCH] imap-send: Code correctness flagged by clang
Date: Sat, 7 Aug 2010 12:12:16 +0000 [thread overview]
Message-ID: <1281183136-10352-1-git-send-email-avarab@gmail.com> (raw)
Clang 1.1 flagged the following issues in imap-send.c, this change
fixes the warnings by moving some code around:
imap-send.c:548:27: warning: data argument not used by format string [-Wformat-extra-args]
cmd->tag, cmd->cmd, cmd->cb.dlen);
^
Here the sprintf format didn't use the cmd->cb.dlen argument if
cmd->cb.data was false. Change the code to use a if/else instead of a
two-level ternary to work it. This code was introduced with imap-send
itself in f2561fda.
imap-send.c:1089:41: warning: conversion specifies type 'unsigned short' but the argument has type 'int' [-Wformat]
snprintf(portstr, sizeof(portstr), "%hu", srvc->port);
~~^ ~~~~~~~~~~
Here sprintf is being given an int with a %hu format. Cast the
srvc->port to unsigned short to work it. This code was introduced in
94ad2437 to add IPv6 support.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
imap-send.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index 1a577a0..4b25375 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -543,9 +543,14 @@ static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx,
while (imap->literal_pending)
get_cmd_result(ctx, NULL);
- bufl = nfsnprintf(buf, sizeof(buf), cmd->cb.data ? CAP(LITERALPLUS) ?
- "%d %s{%d+}\r\n" : "%d %s{%d}\r\n" : "%d %s\r\n",
- cmd->tag, cmd->cmd, cmd->cb.dlen);
+ if (cmd->cb.data) {
+ bufl = nfsnprintf(buf, sizeof(buf),
+ CAP(LITERALPLUS) ? "%d %s{%d+}\r\n" : "%d %s{%d}\r\n",
+ cmd->tag, cmd->cmd, cmd->cb.dlen);
+ } else {
+ bufl = nfsnprintf(buf, sizeof(buf), "%d %s\r\n", cmd->tag, cmd->cmd);
+ }
+
if (Verbose) {
if (imap->num_in_progress)
printf("(%d in progress) ", imap->num_in_progress);
@@ -1086,7 +1091,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
int gai;
char portstr[6];
- snprintf(portstr, sizeof(portstr), "%hu", srvc->port);
+ snprintf(portstr, sizeof(portstr), "%hu", (unsigned short)srvc->port);
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
--
1.7.1
next reply other threads:[~2010-08-07 12:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-07 12:12 Ævar Arnfjörð Bjarmason [this message]
2010-08-07 21:04 ` [RFC/PATCH] imap-send: Code correctness flagged by clang Jonathan Nieder
2010-08-07 22:53 ` Ævar Arnfjörð Bjarmason
2010-08-07 23:09 ` [PATCH maint] imap-send: Fix sprintf usage Jonathan Nieder
2010-08-07 23:25 ` Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1281183136-10352-1-git-send-email-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=benny.kra@googlemail.com \
--cc=git@vger.kernel.org \
--cc=mike@codeweavers.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).