linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] scsi: wd7000: print sector number as 64-bit
@ 2016-06-21  9:02 Arnd Bergmann
  2016-06-21  9:14 ` Joe Perches
  2016-06-22  2:22 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-06-21  9:02 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Arnd Bergmann, linux-scsi, linux-kernel

Enabling format checking in dprintk() shows that wd7000_biosparam
uses an incorrect format string for sector_t:

drivers/scsi/wd7000.c: In function 'wd7000_biosparam':
drivers/scsi/wd7000.c:1594:21: error: format '%d' expects argument of type 'int', but argument 3 has type 'sector_t {aka long long unsigned int}' [-Werror=format=]

As sector_t can be 32-bit wide, this adds a cast to 'u64' and prints
that with the correct format. The change to use no_printk()
generally helps with finding this kind of hidden format string bug,
and I found that when building with "-Wextra", which warned about
an empty else clause in

       } else
              dprintk("ok!\n");

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: use %llu instead of %lld and use 'u64' instead of 's64' because
sector_t is unsigned.

 drivers/scsi/wd7000.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index 0c0f17b9a3eb..409f959845c4 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -192,7 +192,7 @@
 #ifdef WD7000_DEBUG
 #define dprintk printk
 #else
-#define dprintk(format,args...)
+#define dprintk	no_printk
 #endif
 
 /*
@@ -1591,8 +1591,8 @@ static int wd7000_biosparam(struct scsi_device *sdev,
 {
 	char b[BDEVNAME_SIZE];
 
-	dprintk("wd7000_biosparam: dev=%s, size=%d, ",
-		bdevname(bdev, b), capacity);
+	dprintk("wd7000_biosparam: dev=%s, size=%llu, ",
+		bdevname(bdev, b), (u64)capacity);
 	(void)b;	/* unused var warning? */
 
 	/*
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] scsi: wd7000: print sector number as 64-bit
  2016-06-21  9:02 [PATCH v2] scsi: wd7000: print sector number as 64-bit Arnd Bergmann
@ 2016-06-21  9:14 ` Joe Perches
  2016-06-22  2:22 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2016-06-21  9:14 UTC (permalink / raw)
  To: Arnd Bergmann, James E.J. Bottomley, Martin K. Petersen
  Cc: linux-scsi, linux-kernel

On Tue, 2016-06-21 at 11:02 +0200, Arnd Bergmann wrote:
> Enabling format checking in dprintk() shows that wd7000_biosparam
> uses an incorrect format string for sector_t:

trivia:

> diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
[]
> @@ -192,7 +192,7 @@
>  #ifdef WD7000_DEBUG
>  #define dprintk printk
>  #else
> -#define dprintk(format,args...)
> +#define dprintk	no_printk
>  #endif

It'd be nicer if both defines were the same form

#ifdef WD7000_DEBUG
#define dprintk		printk
#else
#define dprintk		no_printk
#endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] scsi: wd7000: print sector number as 64-bit
  2016-06-21  9:02 [PATCH v2] scsi: wd7000: print sector number as 64-bit Arnd Bergmann
  2016-06-21  9:14 ` Joe Perches
@ 2016-06-22  2:22 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2016-06-22  2:22 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi, linux-kernel

>>>>> "Arnd" == Arnd Bergmann <arnd@arndb.de> writes:

Arnd> Enabling format checking in dprintk() shows that wd7000_biosparam
Arnd> uses an incorrect format string for sector_t:

Applied to 4.8/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-22  2:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21  9:02 [PATCH v2] scsi: wd7000: print sector number as 64-bit Arnd Bergmann
2016-06-21  9:14 ` Joe Perches
2016-06-22  2:22 ` Martin K. Petersen

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).