dc395x: use NULL instead of 0
Subsystems (2)
PATCH 3/8 dc395x: use NULL instead of 0
%p is used, thus NULL should be used instead of 0. Also, bit maskings are added in order to fix the following sparse warnings:
drivers/scsi/dc395x.c:1525:17: warning: Using plain integer as NULL pointer drivers/scsi/dc395x.c:4186:48: warning: cast truncates bits from constant value (1de1 becomes e1) drivers/scsi/dc395x.c:4188:45: warning: cast truncates bits from constant value (391 becomes 91) drivers/scsi/dc395x.c:4192:44: warning: cast truncates bits from constant value (1de1 becomes e1) drivers/scsi/dc395x.c:4194:44: warning: cast truncates bits from constant value (391 becomes 91)
--- drivers/scsi/dc395x.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/scsi/dc395x.c +7 -5
@@ -1526,7 +1526,7 @@ static u8 start_scsi(struct AdapterCtlBlk* acb, struct DeviceCtlBlk* dcb,"command while another command (0x%p) is active." , srb->cmd, acb->active_dcb->active_srb ? - acb->active_dcb->active_srb->cmd : 0); + acb->active_dcb->active_srb->cmd : NULL);return 1 ; }if (DC395x_read16 (acb,TRM_S1040_SCSI_STATUS ) &SCSIINTERRUPT ) {
@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port)*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff ); eeprom->sub_vendor_id[1 ] = (u8)(PCI_VENDOR_ID_TEKRAM >>8 ); - eeprom->sub_sys_id[0 ] = (u8 )PCI_DEVICE_ID_TEKRAM_TRMS1040 ; + eeprom->sub_sys_id[0 ] = + (u8)(PCI_DEVICE_ID_TEKRAM_TRMS1040 &0xff ); eeprom->sub_sys_id[1 ] = (u8)(PCI_DEVICE_ID_TEKRAM_TRMS1040 >>8 ); eeprom->sub_class =0x00 ; - eeprom->vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff ); eeprom->vendor_id[1 ] = (u8)(PCI_VENDOR_ID_TEKRAM >>8 ); - eeprom->device_id[0 ] = (u8 )PCI_DEVICE_ID_TEKRAM_TRMS1040 ; + eeprom->device_id[0 ] = + (u8)(PCI_DEVICE_ID_TEKRAM_TRMS1040 &0xff ); eeprom->device_id[1 ] = (u8)(PCI_DEVICE_ID_TEKRAM_TRMS1040 >>8 ); eeprom->reserved =0x00 ;
Signature · 1 line
1.7.10.4
Oliver Neukum
maintainerdrivers/scsi/dc395x.c static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port) · line 4186
Quoted 6 lines · Jingoo Han
drivers/scsi/dc395x.c +1
-1@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port)*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff );
Hi,
if you are fixing these issues please use the proper macros for conversion of endianness.
Regards
Oliver
Quoted 11 lines · Oliver Neukum
drivers/scsi/dc395x.c static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port) · line 4186
Quoted 6 lines · Jingoo Han
drivers/scsi/dc395x.c +1
-1@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port)*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff );Hi,
Quoted 2 lines
if you are fixing these issues please use the proper macros for conversion of endianness.
Sorry, I cannot understand exactly what you mean. :( Would you please let me know which macros can be used?
Best regards,
Jingoo Han
Oliver Neukum
maintainerQuoted 12 lines · Jingoo Han
Quoted 11 lines · Oliver Neukum
drivers/scsi/dc395x.c static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port) · line 4186
Quoted 6 lines · Jingoo Han
drivers/scsi/dc395x.c +1
-1@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port)*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff );Hi,
Quoted 5 lines
Quoted 2 lines
if you are fixing these issues please use the proper macros for conversion of endianness.
Sorry, I cannot understand exactly what you mean. :( Would you please let me know which macros can be used?
In this case constant_cpu_to_le16() would be the macro you want. Have a look at include/uapi/linux/byteorder/
Regards
Oliver
Quoted 11 lines · Oliver Neukum
drivers/scsi/dc395x.c static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port) · line 4186
Quoted 6 lines · Jingoo Han
drivers/scsi/dc395x.c +1
-1@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port)*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff );Hi,
Quoted 2 lines
if you are fixing these issues please use the proper macros for conversion of endianness.
Then, do you mean the following? :)
- prom->sub_vendor_id[0] = (u8)PCI_VENDOR_ID_TEKRAM;
+ eprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & le16_to_cpu(0xff));
Best regards,
Jingoo Han
Hi Jingoo,
Quoted 17 lines · Jingoo Han
Quoted 11 lines · Oliver Neukum
drivers/scsi/dc395x.c static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port) · line 4186
Quoted 6 lines · Jingoo Han
drivers/scsi/dc395x.c +1
-1@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port)*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff );Hi,
Quoted 2 lines
if you are fixing these issues please use the proper macros for conversion of endianness.
Then, do you mean the following? :)
Review
Quoted 2 lines
(quoted diff) +1
-1- prom->sub_vendor_id[0] = (u8)PCI_VENDOR_ID_TEKRAM; + eprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & le16_to_cpu(0xff));
No.
The issue is that the driver is doing things like this:
eeprom->member[0] = (u8)(CONSTANT & 0xff);
eeprom->member[1] = (u8)(CONSTANT >> 8);
Which is exactly the same as code along the lines of:
eeprom->member = cpu_to_le16(CONSTANT);
Thanks,
Signature · 5 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/ .Plan: http://sites.google.com/site/juliancalaby/
Quoted 35 lines
-----Original Message-----
From: Julian Calaby [mailto:[email protected]]
Sent: Wednesday, August 07, 2013 5:21 PM
To: Jingoo Han
Cc: Oliver Neukum; James Bottomley; Ali Akcaagac; Jamie Lenehan; [email protected]; James Bottomley; linux-scsi
Subject: Re: [PATCH 3/8] [SCSI] dc395x: use NULL instead of 0Hi Jingoo,
Quoted 17 lines · Jingoo Han
Quoted 11 lines · Oliver Neukum
drivers/scsi/dc395x.c static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port) · line 4186
Quoted 6 lines · Jingoo Han
drivers/scsi/dc395x.c +1
-1@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port)*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff );Hi,
Quoted 2 lines
if you are fixing these issues please use the proper macros for conversion of endianness.
Then, do you mean the following? :)
Review
Quoted 2 lines
(quoted diff) +1
-1- prom->sub_vendor_id[0] = (u8)PCI_VENDOR_ID_TEKRAM; + eprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & le16_to_cpu(0xff));No.
Quoted 8 lines
The issue is that the driver is doing things like this:
eeprom->member[0] = (u8)(CONSTANT &
0xff);
eeprom->member[1] = (u8)(CONSTANT >> 8);Which is exactly the same as code along the lines of:
eeprom->member=cpu_to_le16(CONSTANT);
However, when I compile the following, it makes build error.
- eeprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & 0xff); - eeprom->sub_vendor_id[1] = (u8)(PCI_VENDOR_ID_TEKRAM >> 8); + eeprom->sub_vendor_id = cpu_to_le16(PCI_VENDOR_ID_TEKRAM);
Best regards,
Jingoo Han
Hi Jingoo,
Quoted 46 lines · Jingoo Han
Quoted 35 lines
-----Original Message-----
From: Julian Calaby [mailto:[email protected]]
Sent: Wednesday, August 07, 2013 5:21 PM
To: Jingoo Han
Cc: Oliver Neukum; James Bottomley; Ali Akcaagac; Jamie Lenehan; [email protected]; James Bottomley; linux-scsi
Subject: Re: [PATCH 3/8] [SCSI] dc395x: use NULL instead of 0Hi Jingoo,
Quoted 17 lines · Jingoo Han
Quoted 11 lines · Oliver Neukum
drivers/scsi/dc395x.c static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port) · line 4186
Quoted 6 lines · Jingoo Han
drivers/scsi/dc395x.c +1
-1@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port)*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff );Hi,
Quoted 2 lines
if you are fixing these issues please use the proper macros for conversion of endianness.
Then, do you mean the following? :)
Review
Quoted 2 lines
(quoted diff) +1
-1- prom->sub_vendor_id[0] = (u8)PCI_VENDOR_ID_TEKRAM; + eprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & le16_to_cpu(0xff));No.
Quoted 8 lines
The issue is that the driver is doing things like this:
eeprom->member[0] = (u8)(CONSTANT &
0xff);
eeprom->member[1] = (u8)(CONSTANT >> 8);Which is exactly the same as code along the lines of:
eeprom->member=cpu_to_le16(CONSTANT);However, when I compile the following, it makes build error.
Review
Quoted 3 lines
(quoted diff) +1
-2- eeprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & 0xff); - eeprom->sub_vendor_id[1] = (u8)(PCI_VENDOR_ID_TEKRAM >> 8); + eeprom->sub_vendor_id = cpu_to_le16(PCI_VENDOR_ID_TEKRAM);
Of course it does.
I said code along the lines of. You'll need to do more than just what I suggested, including changing the definition of the eeprom struct and fixing any other places where it's used / set.
Thanks,
Signature · 5 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/ .Plan: http://sites.google.com/site/juliancalaby/
Quoted 41 lines · On Wed, Wednesday, August 07, 2013 5:40 PM, Julian Calaby > wrote:
Quoted 6 lines · Jingoo Han
Quoted 5 lines · Julian Calaby
Quoted 4 lines · Jingoo Han
Quoted 3 lines · Oliver Neukum
Review static void check_eeprom(struct NvRamType *eeprom, unsigned long
Quoted 1 line · Jingoo Han
(quoted diff) +0
-0@@ -4183,15 +4183,17 @@ static void check_eeprom(struct NvRamType *eeprom, unsigned long
io_port)Quoted 29 lines
Quoted 18 lines
Quoted 13 lines
Quoted 10 lines
drivers/scsi/dc395x.c static void check_eeprom(struct NvRamType *eeprom, unsigned long io_port) · line 4186
Quoted 5 lines
drivers/scsi/dc395x.c +1
-1*/ dprintkl (KERN_WARNING ,"EEProm checksum error: using default values and options.\n" ); - eeprom->sub_vendor_id[0 ] = (u8 )PCI_VENDOR_ID_TEKRAM ; + eeprom->sub_vendor_id[0 ] = (u8)(PCI_VENDOR_ID_TEKRAM &0xff );Hi,
if you are fixing these issues please use the proper macros for conversion of endianness.
Then, do you mean the following? :)
Review
Quoted 2 lines
(quoted diff) +1
-1- prom->sub_vendor_id[0] = (u8)PCI_VENDOR_ID_TEKRAM; + eprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & le16_to_cpu(0xff));No.
Quoted 8 lines
The issue is that the driver is doing things like this:
eeprom->member[0] = (u8)(CONSTANT &
0xff);
eeprom->member[1] = (u8)(CONSTANT >> 8);Which is exactly the same as code along the lines of:
eeprom->member=cpu_to_le16(CONSTANT);However, when I compile the following, it makes build error.
Review
Quoted 3 lines
(quoted diff) +1
-2- eeprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & 0xff); - eeprom->sub_vendor_id[1] = (u8)(PCI_VENDOR_ID_TEKRAM >> 8); + eeprom->sub_vendor_id = cpu_to_le16(PCI_VENDOR_ID_TEKRAM);
Quoted 5 lines
Of course it does.
I said code along the lines of. You'll need to do more than just what I suggested, including changing the definition of the eeprom struct and fixing any other places where it's used / set.
I fixed it as below. In this case, it does not make any warnings. Oliver Neukum, do you mean the following?
struct NvRamType {
- u8 sub_vendor_id[2]; /* 0,1 Sub Vendor ID */ + u16 sub_vendor_id; /* 0,1 Sub Vendor ID */
- eeprom->sub_vendor_id[0] = (u8)(PCI_VENDOR_ID_TEKRAM & 0xff);
- eeprom->sub_vendor_id[1] = (u8)(PCI_VENDOR_ID_TEKRAM >> 8);
+ eeprom->sub_vendor_id = cpu_to_le16(PCI_VENDOR_ID_TEKRAM);
Best regards,
Jingoo Han