Skip to contentSkip to conversation

block: Correct misuses of 0x%<decimal>

PATCH In review Joe Perches 3 participants 8 messages Aug 2, 2015 – Aug 4, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: Correct misuses of 0x%<decimal>

Correct misuse of 0x%d in logging messages.

---
 drivers/block/DAC960.c | 4 ++--
 drivers/block/cciss.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/block/DAC960.c +2 -2
index 811e11c..d9b32f2 100644
@@ -2954,7 +2954,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
        case DAC960_PD_Controller:
          if (!request_region(Controller->IO_Address, 0x80,
                              Controller->FullModelName)) {
-               DAC960_Error("IO port 0x%d busy for Controller at\n",
+               DAC960_Error("IO port 0x%x busy for Controller at\n",
                             Controller, Controller->IO_Address);
                goto Failure;
          }
@@ -2990,7 +2990,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
        case DAC960_P_Controller:
          if (!request_region(Controller->IO_Address, 0x80,
                              Controller->FullModelName)){
-               DAC960_Error("IO port 0x%d busy for Controller at\n",
+               DAC960_Error("IO port 0x%x busy for Controller at\n",
                             Controller, Controller->IO_Address);
                goto Failure;
          }
drivers/block/cciss.c +1 -1
index 0422c47..2758982 100644
@@ -3854,7 +3854,7 @@ static void print_cfg_table(ctlr_info_t *h)
               readl(&(tb->HostWrite.CoalIntDelay)));
        dev_dbg(&h->pdev->dev, "   Coalesce Interrupt Count = 0x%x\n",
               readl(&(tb->HostWrite.CoalIntCount)));
-       dev_dbg(&h->pdev->dev, "   Max outstanding commands = 0x%d\n",
+       dev_dbg(&h->pdev->dev, "   Max outstanding commands = 0x%x\n",
               readl(&(tb->CmdsOutMax)));
        dev_dbg(&h->pdev->dev, "   Bus Types = 0x%x\n",
                readl(&(tb->BusTypes)));
Reviewed-by on v1 1/1
#1 lore raw
Quoted 44 lines · Joe Perches

Correct misuse of 0x%d in logging messages.

---
 drivers/block/DAC960.c | 4 ++--
 drivers/block/cciss.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/block/DAC960.c +2 -2
index 811e11c..d9b32f2 100644
@@ -2954,7 +2954,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
        case DAC960_PD_Controller:
          if (!request_region(Controller->IO_Address, 0x80,
                              Controller->FullModelName)) {
-               DAC960_Error("IO port 0x%d busy for Controller at\n",
+               DAC960_Error("IO port 0x%x busy for Controller at\n",
                             Controller, Controller->IO_Address);
                goto Failure;
          }
@@ -2990,7 +2990,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
        case DAC960_P_Controller:
          if (!request_region(Controller->IO_Address, 0x80,
                              Controller->FullModelName)){
-               DAC960_Error("IO port 0x%d busy for Controller at\n",
+               DAC960_Error("IO port 0x%x busy for Controller at\n",
                             Controller, Controller->IO_Address);
                goto Failure;
          }
drivers/block/cciss.c +1 -2
index 0422c47..2758982 100644
@@ -3854,7 +3854,7 @@ static void print_cfg_table(ctlr_info_t *h)
               readl(&(tb->HostWrite.CoalIntDelay)));
        dev_dbg(&h->pdev->dev, "   Coalesce Interrupt Count = 0x%x\n",
               readl(&(tb->HostWrite.CoalIntCount)));
-       dev_dbg(&h->pdev->dev, "   Max outstanding commands = 0x%d\n",
+       dev_dbg(&h->pdev->dev, "   Max outstanding commands = 0x%x\n",
               readl(&(tb->CmdsOutMax)));
        dev_dbg(&h->pdev->dev, "   Bus Types = 0x%x\n",
                readl(&(tb->BusTypes)));
--
Quoted 3 lines

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

Signature · 6 lines
Johannes Thumshirn                                           Storage
[email protected]                                 +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
#2 lore raw
In reply to Joe Perches
Quoted 46 lines · Joe Perches

Correct misuse of 0x%d in logging messages.

---
drivers/block/DAC960.c | 4 ++--
drivers/block/cciss.c | 2 +-

2 files changed, 3 insertions(+), 3 deletions(-)
drivers/block/DAC960.c +2 -2
index 811e11c..d9b32f2 100644
@@ -2954,7 +2954,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
       case DAC960_PD_Controller:
         if (!request_region(Controller->IO_Address, 0x80,
                             Controller->FullModelName)) {
-               DAC960_Error("IO port 0x%d busy for Controller at\n",
+               DAC960_Error("IO port 0x%x busy for Controller at\n",
                            Controller, Controller->IO_Address);
               goto Failure;
         }
@@ -2990,7 +2990,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
       case DAC960_P_Controller:
         if (!request_region(Controller->IO_Address, 0x80,
                             Controller->FullModelName)){
-               DAC960_Error("IO port 0x%d busy for Controller at\n",
+               DAC960_Error("IO port 0x%x busy for Controller at\n",
                            Controller, Controller->IO_Address);
               goto Failure;
         }
drivers/block/cciss.c +1 -1
index 0422c47..2758982 100644
@@ -3854,7 +3854,7 @@ static void print_cfg_table(ctlr_info_t *h)
              readl(&(tb->HostWrite.CoalIntDelay)));
       dev_dbg(&h->pdev->dev, "   Coalesce Interrupt Count = 0x%x\n",
              readl(&(tb->HostWrite.CoalIntCount)));
-       dev_dbg(&h->pdev->dev, "   Max outstanding commands = 0x%d\n",
+       dev_dbg(&h->pdev->dev, "   Max outstanding commands = 0x%x\n",
              readl(&(tb->CmdsOutMax)));
       dev_dbg(&h->pdev->dev, "   Bus Types = 0x%x\n",
               readl(&(tb->BusTypes)));
Quoted 1 line

—

why not use like this : dev_dbg(&h->pdev->dev, " Max outstanding commands = %#x\n” ?
%#x will add 0x prefix automatically .

Thanks

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

#3 lore raw
Quoted 4 lines · yalin wang
Quoted 4 lines · Joe Perches

Correct misuse of 0x%d in logging messages.

[]

Quoted 3 lines

why not use like this : dev_dbg(&h->pdev->dev, " Max outstanding
commands = %#x\n” ?
%#x will add 0x prefix automatically .

It's generally a consistency thing.
A 0 value would be emitted as 0 and not 0x0.

#4 lore raw
Quoted 8 lines · Joe Perches
Quoted 4 lines · yalin wang
Quoted 4 lines · Joe Perches

Correct misuse of 0x%d in logging messages.

Quoted 8 lines

[]

Quoted 3 lines

why not use like this : dev_dbg(&h->pdev->dev, " Max outstanding
commands = %#x\n” ?
%#x will add 0x prefix automatically .

It's generally a consistency thing.
A 0 value would be emitted as 0 and not 0x0.

i try on my ubuntu ,

static int __init throtl_init(void)

  {                                                                                
         printk("module init test: %#x %p\n", 0, (void *)0x123);                  
          return 0;                                                                   
  }                                                                                   
                                                                                      
  module_init(throtl_init); 

#uname -a
Linux ubuntu 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

#dmesg

[259356.375586] module init test: 0x0 0000000000000123

it seems don’t need 0x%x for 0, just need %#x for all numbers. there are lots of use like this, i can change them if needed:

# egrep -r  -i '0x%\d*x'  .  | wc -l 
11776

Thanks

#5 lore raw

Ping ?

Quoted 43 lines · yalin wang
Quoted 9 lines · Joe Perches
Quoted 4 lines · yalin wang
Quoted 4 lines · Joe Perches

Correct misuse of 0x%d in logging messages.

Quoted 8 lines

[]

Quoted 3 lines

why not use like this : dev_dbg(&h->pdev->dev, " Max outstanding
commands = %#x\n” ?
%#x will add 0x prefix automatically .

It's generally a consistency thing.
A 0 value would be emitted as 0 and not 0x0.

i try on my ubuntu ,

static int __init throtl_init(void)

 {                                                                                
        printk("module init test: %#x %p\n", 0, (void *)0x123);                  
         return 0;                                                                   

}

module_init(throtl_init);

#uname -a
Linux ubuntu 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

#dmesg

[259356.375586] module init test: 0x0 0000000000000123

it seems don’t need 0x%x for 0, just need %#x for all numbers. there are lots of use like this, i can change them if needed:

# egrep -r  -i '0x%\d*x'  .  | wc -l 
11776

Thanks

#6 lore raw
Quoted 41 lines · yalin wang

Ping ?

Quoted 40 lines · yalin wang
Quoted 9 lines · Joe Perches
Quoted 4 lines · yalin wang
Quoted 4 lines · Joe Perches

Correct misuse of 0x%d in logging messages.

Quoted 8 lines

[]

Quoted 3 lines

why not use like this : dev_dbg(&h->pdev->dev, " Max outstanding
commands = %#x\n” ?
%#x will add 0x prefix automatically .

It's generally a consistency thing.
A 0 value would be emitted as 0 and not 0x0.

i try on my ubuntu ,

static int __init throtl_init(void)

 {                                                                                
        printk("module init test: %#x %p\n", 0, (void *)0x123);                  
         return 0;                                                                   

}

module_init(throtl_init);

#uname -a
Linux ubuntu 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

#dmesg

[259356.375586] module init test: 0x0 0000000000000123

it seems don’t need 0x%x for 0, just need %#x for all numbers. there are lots of use like this, i can change them if needed:

# egrep -r  -i '0x%\d*x'  .  | wc -l 
11776

I suggest not, it's not a standard usage and the 0 may be unexpected.

#7 lore raw
Quoted 40 lines · Joe Perches
Quoted 36 lines · yalin wang

Ping ?

Quoted 35 lines · yalin wang
Quoted 9 lines · Joe Perches
Quoted 4 lines · yalin wang
Quoted 4 lines · Joe Perches

Correct misuse of 0x%d in logging messages.

Quoted 8 lines

[]

Quoted 3 lines

why not use like this : dev_dbg(&h->pdev->dev, " Max outstanding
commands = %#x\n” ?
%#x will add 0x prefix automatically .

It's generally a consistency thing.
A 0 value would be emitted as 0 and not 0x0.

i try on my ubuntu ,

static int __init throtl_init(void)

{                                                                                
       printk("module init test: %#x %p\n", 0, (void *)0x123);                  
        return 0;                                                                   

}

module_init(throtl_init);

#uname -a
Linux ubuntu 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

#dmesg

[259356.375586] module init test: 0x0 0000000000000123
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines

it seems don’t need 0x%x for 0, just need %#x for all numbers. there are lots of use like this, i can change them if needed:

# egrep -r  -i '0x%\d*x'  .  | wc -l 
11776

I suggest not, it's not a standard usage and the 0 may be unexpected.

ok, printk for %x is really not compatible with glibc printf behavior, another is %p, printk print %p as hex but not with 0x prefix, while printf print %p as 0x…. with prefix, is this need change ? so we don’t need lots of 0x%p printk .