Răsfoiți Sursa

[libata] pata_artop: kill gcc warning

gcc complains thusly:

drivers/ata/pata_artop.c: In function ‘artop_init_one’:
drivers/ata/pata_artop.c:429: warning: ‘info’ may be used uninitialized in this function

While this warning is indeed bogus, even with improved static analysis
and value range propagation, gcc will probably never be able to detect
this.

Add a BUG_ON() to trap invalid driver_data entries in the PCI table.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Jeff Garzik 18 ani în urmă
părinte
comite
15a7c3bbe3
1 a modificat fișierele cu 4 adăugiri și 1 ștergeri
  1. 4 1
      drivers/ata/pata_artop.c

+ 4 - 1
drivers/ata/pata_artop.c

@@ -426,7 +426,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
 		.port_ops	= &artop6260_ops,
 		.port_ops	= &artop6260_ops,
 	};
 	};
 	struct ata_port_info *port_info[2];
 	struct ata_port_info *port_info[2];
-	struct ata_port_info *info;
+	struct ata_port_info *info = NULL;
 	int ports = 2;
 	int ports = 2;
 
 
 	if (!printed_version++)
 	if (!printed_version++)
@@ -470,6 +470,9 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
 		pci_write_config_byte(pdev, 0x4a, (reg & ~0x01) | 0x80);
 		pci_write_config_byte(pdev, 0x4a, (reg & ~0x01) | 0x80);
 
 
 	}
 	}
+
+	BUG_ON(info == NULL);
+
 	port_info[0] = port_info[1] = info;
 	port_info[0] = port_info[1] = info;
 	return ata_pci_init_one(pdev, port_info, ports);
 	return ata_pci_init_one(pdev, port_info, ports);
 }
 }