scsi ips gcc 4.1 warning fix
Subsystems (3)
PATCH 1/1 scsi ips gcc 4.1 warning fix
If the ips_phase1_init fails someplace , and ips_hotplug is enabled, index would get used to access and array. This looks like definite badness.
Fixes the following warning,
drivers/scsi/ips.c: In function 'ips_register_scsi':drivers/scsi/ips.c:7043: warning: ignoring return value of 'scsi_add_host', declared with attribute warn_unused_result drivers/scsi/ips.c: In function 'ips_insert_device':drivers/scsi/ips.c:7124: warning: 'index' may be used uninitialized in this function
Signed-off-by Daniel Walker <[email protected]>
drivers/scsi/ips.c +8 -8
@@ -7121,7 +7121,7 @@ module_exit(ips_module_exit);static int __devinit ips_insert_device (struct pci_dev *pci_dev,const struct pci_device_id *ent) { -int index; +int index =0 ;int rc;METHOD_TRACE ("ips_insert_device" ,1 );
@@ -7129,17 +7129,17 @@ ips_insert_device(struct pci_dev *pci_dereturn -1 ; rc =ips_init_phase1 (pci_dev, &index); -if (rc ==SUCCESS ) +if (rc ==SUCCESS ) { rc =ips_init_phase2 (index); -if (ips_hotplug) -if (ips_register_scsi (index)) { -ips_free (ips_ha[index]); - rc =-1 ; - } +if (ips_hotplug) +if (ips_register_scsi (index)) { +ips_free (ips_ha[index]); + rc =-1 ; + } -if (rc ==SUCCESS ) ips_num_controllers++; + } ips_next_controller = ips_num_controllers;return rc;
drivers/scsi/ips.h +2 -1
@@ -109,7 +109,8 @@#else #define IPS_REGISTER_HOSTS (SHT ) (!ips_detect(SHT))#define IPS_UNREGISTER_HOSTS (SHT ) -#define IPS_ADD_HOST (shost,device) do { scsi_add_host(shost,device); scsi_scan_host(shost); } while (0) +#define IPS_ADD_HOST (shost,device) do { if (scsi_add_host(shost,device)) return -ENODEV; \ + scsi_scan_host(shost); } while (0)#define IPS_REMOVE_HOST (shost) scsi_remove_host(shost)#define IPS_SCSI_SET_DEVICE (sh,ha) do { } while (0) #define IPS_PRINTK(level, pcidev, format, arg...) \