diff mbox

[2/2] scsi: wd7000: print sector number as 64-bit

Message ID 4878482.cSGU6mK9NX@wuerfel (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Arnd Bergmann June 15, 2016, 8:54 p.m. UTC
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>
---
Not Cc'ing Miroslav Zagorac <zaga@fly.cc.fer.hr>, that address bounces
with "Requested action not taken: mailbox unavailable invalid DNS MX or A/AAAA resource record"


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

kernel test robot June 16, 2016, 5:36 p.m. UTC | #1
Hi,

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v4.7-rc3 next-20160616]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/scsi-lpfc-avoid-harmless-comparison-warning/20160616-045453
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=alpha 

All warnings (new ones prefixed by >>):

   drivers/scsi/wd7000.c: In function 'mail_out':
   drivers/scsi/wd7000.c:915:44: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
       any2scsi((unchar *) ogmbs[ogmb].scbptr, (int) scbptr);
                                               ^
   drivers/scsi/wd7000.c: In function 'wd7000_queuecommand_lck':
   drivers/scsi/wd7000.c:1117:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
      any2scsi(scb->dataptr, (int) sgb);
                             ^
   drivers/scsi/wd7000.c:1121:4: warning: 'isa_page_to_bus' is deprecated [-Wdeprecated-declarations]
       any2scsi(sgb[i].ptr, isa_page_to_bus(sg_page(sg)) + sg->offset);
       ^
   In file included from include/linux/io.h:25:0,
                    from include/linux/irq.h:24,
                    from include/asm-generic/hardirq.h:12,
                    from arch/alpha/include/asm/hardirq.h:7,
                    from include/linux/hardirq.h:8,
                    from include/linux/interrupt.h:12,
                    from drivers/scsi/wd7000.c:170:
   arch/alpha/include/asm/io.h:95:39: note: declared here
    static inline dma_addr_t __deprecated isa_page_to_bus(struct page *page)
                                          ^
   drivers/scsi/wd7000.c:1128:4: warning: 'isa_page_to_bus' is deprecated [-Wdeprecated-declarations]
       any2scsi(scb->dataptr, isa_page_to_bus(sg_page(sg)) + sg->offset);
       ^
   In file included from include/linux/io.h:25:0,
                    from include/linux/irq.h:24,
                    from include/asm-generic/hardirq.h:12,
                    from arch/alpha/include/asm/hardirq.h:7,
                    from include/linux/hardirq.h:8,
                    from include/linux/interrupt.h:12,
                    from drivers/scsi/wd7000.c:170:
   arch/alpha/include/asm/io.h:95:39: note: declared here
    static inline dma_addr_t __deprecated isa_page_to_bus(struct page *page)
                                          ^
   drivers/scsi/wd7000.c: In function 'wd7000_diagnostics':
   drivers/scsi/wd7000.c:1151:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     any2scsi(icb.ptr, (int) &buf);
                       ^
   drivers/scsi/wd7000.c: In function 'wd7000_adapter_reset':
   drivers/scsi/wd7000.c:1236:46: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     any2scsi((unchar *) & (init_cmd.mailboxes), (int) &(host->mb));
                                                 ^
   In file included from include/linux/kernel.h:13:0,
                    from include/linux/delay.h:10,
                    from drivers/scsi/wd7000.c:168:
   drivers/scsi/wd7000.c: In function 'wd7000_detect':
   drivers/scsi/wd7000.c:1482:59: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
        dprintk("wd7000_detect: adapter allocated at 0x%x\n", (int) host);
                                                              ^
   include/linux/printk.h:114:17: note: in definition of macro 'no_printk'
      printk(fmt, ##__VA_ARGS__); \
                    ^
>> drivers/scsi/wd7000.c:1482:5: note: in expansion of macro 'dprintk'
        dprintk("wd7000_detect: adapter allocated at 0x%x\n", (int) host);
        ^

vim +/dprintk +1482 drivers/scsi/wd7000.c

^1da177e Linus Torvalds 2005-04-16  1466  				dprintk("ok!\n");
^1da177e Linus Torvalds 2005-04-16  1467  
^1da177e Linus Torvalds 2005-04-16  1468  			if (inb(iobase + ASC_INTR_STAT) == 1) {
^1da177e Linus Torvalds 2005-04-16  1469  				/*
^1da177e Linus Torvalds 2005-04-16  1470  				 *  We register here, to get a pointer to the extra space,
^1da177e Linus Torvalds 2005-04-16  1471  				 *  which we'll use as the Adapter structure (host) for
^1da177e Linus Torvalds 2005-04-16  1472  				 *  this adapter.  It is located just after the registered
^1da177e Linus Torvalds 2005-04-16  1473  				 *  Scsi_Host structure (sh), and is located by the empty
^1da177e Linus Torvalds 2005-04-16  1474  				 *  array hostdata.
^1da177e Linus Torvalds 2005-04-16  1475  				 */
^1da177e Linus Torvalds 2005-04-16  1476  				sh = scsi_register(tpnt, sizeof(Adapter));
^1da177e Linus Torvalds 2005-04-16  1477  				if (sh == NULL)
^1da177e Linus Torvalds 2005-04-16  1478  					goto err_release;
^1da177e Linus Torvalds 2005-04-16  1479  
^1da177e Linus Torvalds 2005-04-16  1480  				host = (Adapter *) sh->hostdata;
^1da177e Linus Torvalds 2005-04-16  1481  
^1da177e Linus Torvalds 2005-04-16 @1482  				dprintk("wd7000_detect: adapter allocated at 0x%x\n", (int) host);
^1da177e Linus Torvalds 2005-04-16  1483  				memset(host, 0, sizeof(Adapter));
^1da177e Linus Torvalds 2005-04-16  1484  
^1da177e Linus Torvalds 2005-04-16  1485  				host->irq = configs[pass].irq;
^1da177e Linus Torvalds 2005-04-16  1486  				host->dma = configs[pass].dma;
^1da177e Linus Torvalds 2005-04-16  1487  				host->iobase = iobase;
^1da177e Linus Torvalds 2005-04-16  1488  				host->int_counter = 0;
^1da177e Linus Torvalds 2005-04-16  1489  				host->bus_on = configs[pass].bus_on;
^1da177e Linus Torvalds 2005-04-16  1490  				host->bus_off = configs[pass].bus_off;

:::::: The code at line 1482 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Arnd Bergmann June 17, 2016, 11:45 a.m. UTC | #2
On Friday, June 17, 2016 1:36:52 AM CEST kbuild test robot wrote:
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/scsi/wd7000.c: In function 'mail_out':
>    drivers/scsi/wd7000.c:915:44: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>        any2scsi((unchar *) ogmbs[ogmb].scbptr, (int) scbptr);
>                                                ^
>    drivers/scsi/wd7000.c: In function 'wd7000_queuecommand_lck':
>    drivers/scsi/wd7000.c:1117:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>       any2scsi(scb->dataptr, (int) sgb);
>                              ^
>    drivers/scsi/wd7000.c:1121:4: warning: 'isa_page_to_bus' is deprecated [-Wdeprecated-declarations]
>    drivers/scsi/wd7000.c:1128:4: warning: 'isa_page_to_bus' is deprecated [-Wdeprecated-declarations]
>    drivers/scsi/wd7000.c: In function 'wd7000_diagnostics':
>    drivers/scsi/wd7000.c:1151:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>    drivers/scsi/wd7000.c:1236:46: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>    drivers/scsi/wd7000.c:1482:59: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

I'm pretty sure these are all preexisting warnings, and they don't show up
on ARM or x86.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin K. Petersen June 21, 2016, 1:12 a.m. UTC | #3
>>>>> "Arnd" == Arnd Bergmann <arnd@arndb.de> writes:

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

[...]

+	dprintk("wd7000_biosparam: dev=%s, size=%lld, ",
+		bdevname(bdev, b), (s64)capacity);

s64?

Why not unsigned long long like we usually do with sector_t?
Arnd Bergmann June 21, 2016, 11:41 a.m. UTC | #4
On Monday, June 20, 2016 9:12:50 PM CEST Martin K. Petersen wrote:
> >>>>> "Arnd" == Arnd Bergmann <arnd@arndb.de> writes:
> 
> 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()
> 
> [...]
> 
> +       dprintk("wd7000_biosparam: dev=%s, size=%lld, ",
> +               bdevname(bdev, b), (s64)capacity);
> 
> s64?
> 
> Why not unsigned long long like we usually do with sector_t?

The printk() was using %d as the format string, printing it
as a signed number, so I did not change it.

Using %llu makes sense though, I've resent it like that.

	Arnd

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index 0c0f17b9a3eb..39a3b5333bd6 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=%lld, ",
+		bdevname(bdev, b), (s64)capacity);
 	(void)b;	/* unused var warning? */
 
 	/*