linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
	Fengguang Wu <fengguang.wu@intel.com>,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	Douglas Gilbert <dgilbert@interlog.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: [PATCH 5/5] scsi_debug: fix sparse warnings related to data integrity field
Date: Wed, 18 Sep 2013 21:27:28 +0900	[thread overview]
Message-ID: <1379507248-15929-6-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1379507248-15929-1-git-send-email-akinobu.mita@gmail.com>

Each member in data integrity field tuple is big-endian.  But the
endianness of the values being compared with these members are not
annotated.  So this fixes these sparse warnings.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/scsi_debug.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index a21322d..80b8b10 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1745,25 +1745,22 @@ static int do_device_access(struct scsi_cmnd *scmd,
 	return ret;
 }
 
-static u16 dif_compute_csum(const void *buf, int len)
+static __be16 dif_compute_csum(const void *buf, int len)
 {
-	u16 csum;
+	__be16 csum;
 
-	switch (scsi_debug_guard) {
-	case 1:
-		csum = ip_compute_csum(buf, len);
-		break;
-	case 0:
+	if (scsi_debug_guard)
+		csum = (__force __be16)ip_compute_csum(buf, len);
+	else
 		csum = cpu_to_be16(crc_t10dif(buf, len));
-		break;
-	}
+
 	return csum;
 }
 
 static int dif_verify(struct sd_dif_tuple *sdt, const void *data,
 		      sector_t sector, u32 ei_lba)
 {
-	u16 csum = dif_compute_csum(data, scsi_debug_sector_size);
+	__be16 csum = dif_compute_csum(data, scsi_debug_sector_size);
 
 	if (sdt->guard_tag != csum) {
 		pr_err("%s: GUARD check failed on sector %lu rcvd 0x%04x, data 0x%04x\n",
@@ -1841,7 +1838,7 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec,
 		sector = start_sec + i;
 		sdt = dif_store(sector);
 
-		if (sdt->app_tag == 0xffff)
+		if (sdt->app_tag == cpu_to_be16(0xffff))
 			continue;
 
 		ret = dif_verify(sdt, fake_store(sector), sector, ei_lba);
-- 
1.8.3.1


  parent reply	other threads:[~2013-09-18 12:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18 12:27 [PATCH 0/5] scsi_debug: several fixes related to data integrity support Akinobu Mita
2013-09-18 12:27 ` [PATCH 1/5] scsi_debug: fix buffer overrun when DIF/DIX is enabled and virtual_gb > 0 Akinobu Mita
2013-09-20 22:13   ` Martin K. Petersen
2013-09-18 12:27 ` [PATCH 2/5] scsi_debug: factor out copying PI from dif_storep to prot_sglist Akinobu Mita
2013-09-20 22:20   ` Martin K. Petersen
2013-09-18 12:27 ` [PATCH 3/5] scsi_debug: avoid partial copying PI from prot_sglist to dif_storep Akinobu Mita
2013-09-20 22:23   ` Martin K. Petersen
2013-09-18 12:27 ` [PATCH 4/5] scsi_debug: fix invalid value check for guard module parameter Akinobu Mita
2013-09-20 22:23   ` Martin K. Petersen
2013-09-18 12:27 ` Akinobu Mita [this message]
2013-09-20 22:24   ` [PATCH 5/5] scsi_debug: fix sparse warnings related to data integrity field Martin K. Petersen

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=1379507248-15929-6-git-send-email-akinobu.mita@gmail.com \
    --to=akinobu.mita@gmail.com \
    --cc=JBottomley@parallels.com \
    --cc=dgilbert@interlog.com \
    --cc=fengguang.wu@intel.com \
    --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;
as well as URLs for NNTP newsgroup(s).