[PATCH -mm] scsi ips gcc 4.1 warning fix

From: Daniel Walker
Date: Tue May 09 2006 - 22:59:53 EST


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 <dwalker@xxxxxxxxxx>

Index: linux-2.6.16/drivers/scsi/ips.c
===================================================================
--- linux-2.6.16.orig/drivers/scsi/ips.c
+++ linux-2.6.16/drivers/scsi/ips.c
@@ -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_de
return -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;
Index: linux-2.6.16/drivers/scsi/ips.h
===================================================================
--- linux-2.6.16.orig/drivers/scsi/ips.h
+++ linux-2.6.16/drivers/scsi/ips.h
@@ -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...) \
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/