From: Paul Bolle <pebolle@tiscali.nl>
To: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Douglas Gilbert <dgilbert@interlog.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3] [SCSI] scsi_debug: silence GCC warning
Date: Wed, 17 Jul 2013 09:36:24 +0200 [thread overview]
Message-ID: <1374046584.26384.36.camel@x61.thuisdomein> (raw)
In-Reply-To: <CAC5umyioeYDxFVs5J8fvPmXWOB8k9dp_qCp8Ntcq_d8cKhkS9g@mail.gmail.com>
Building scsi_debug.o triggers a GCC warning:
drivers/scsi/scsi_debug.c: In function ‘dif_verify’:
drivers/scsi/scsi_debug.c:1755:3: warning: ‘csum’ may be used uninitialized in this function [-Wmaybe-uninitialized]
This warning was apparently introduced (in v3.11-rc1) by commit
beb40ea42b ("[SCSI] scsi_debug: reduce duplication between
prot_verify_read and prot_verify_write"). It is a false positive. But if
we transform the switch statement in dif_compute_csum() to a
straightforward if/else statement we supply GCC with enough information
to determine that csum will not be used uninitialized.
Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
0) v2: much simpler, and doesn't change any behavior;
v3: mention commit bebe40ea42b, as Akinobu suggested.
1) Still only compile tested.
drivers/scsi/scsi_debug.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index cb4fefa..7565ec5 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1735,14 +1735,11 @@ static u16 dif_compute_csum(const void *buf, int len)
{
u16 csum;
- switch (scsi_debug_guard) {
- case 1:
+ if (scsi_debug_guard == 1)
csum = ip_compute_csum(buf, len);
- break;
- case 0:
+ else
csum = cpu_to_be16(crc_t10dif(buf, len));
- break;
- }
+
return csum;
}
--
1.8.1.4
prev parent reply other threads:[~2013-07-17 7:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-15 9:18 [PATCH] " Paul Bolle
2013-07-15 18:48 ` [PATCH v2] " Paul Bolle
2013-07-16 15:21 ` Akinobu Mita
2013-07-16 15:29 ` Paul Bolle
2013-07-16 15:42 ` Akinobu Mita
2013-07-17 7:36 ` Paul Bolle [this message]
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=1374046584.26384.36.camel@x61.thuisdomein \
--to=pebolle@tiscali.nl \
--cc=JBottomley@parallels.com \
--cc=akinobu.mita@gmail.com \
--cc=dgilbert@interlog.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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
all inboxes | Powered by JetHome®