Skip to contentSkip to conversation

libata-core: disable uninitialized var warning

PATCH In review Dirk Behme 1 participant 3 messages Dec 20, 2012 libata

lore
Share & tools
lore
author
#1 lore raw
In reply to Dirk Behme

Am 20.12.2012 15:10, schrieb Dirk Behme:

Quoted 10 lines

Make GCC happy by disabling the warning

drivers/ata/libata-core.c: In function 'ata_hpa_resize':
drivers/ata/libata-core.c:1394:3: warning: 'native_sectors' may be used uninitialized in this function [-Wmaybe-uninitialized]

Looking on the code, 'native_sectors' is always initialized by calling ata_read_native_max_address(dev, &native_sectors).

Ah, sorry, just saw that there is already a similar discussion from today. Seems this didn't make it to Google, yet ;)

Dirk

Quoted 18 lines
---
  drivers/ata/libata-core.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-core.c +1 -1
index 9e8b99a..21623cf 100644
@@ -1324,7 +1324,7 @@ static int ata_hpa_resize(struct ata_device *dev)
  	int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
  	bool unlock_hpa = ata_ignore_hpa || dev->flags & ATA_DFLAG_UNLOCK_HPA;
  	u64 sectors = ata_id_n_sectors(dev->id);
-	u64 native_sectors;
+	u64 native_sectors = 0 /* GCC */;
  	int rc;
 
  	/* do we need to do it? */

Dirk Behme

author
#0 lore raw

PATCH 1/1 libata-core: disable uninitialized var warning

Make GCC happy by disabling the warning

drivers/ata/libata-core.c: In function 'ata_hpa_resize':
drivers/ata/libata-core.c:1394:3: warning: 'native_sectors' may be used uninitialized in this function [-Wmaybe-uninitialized]

Looking on the code, 'native_sectors' is always initialized by calling ata_read_native_max_address(dev, &native_sectors).

---
 drivers/ata/libata-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-core.c +1 -1
index 9e8b99a..21623cf 100644
@@ -1324,7 +1324,7 @@ static int ata_hpa_resize(struct ata_device *dev)
 	int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
 	bool unlock_hpa = ata_ignore_hpa || dev->flags & ATA_DFLAG_UNLOCK_HPA;
 	u64 sectors = ata_id_n_sectors(dev->id);
-	u64 native_sectors;
+	u64 native_sectors = 0 /* GCC */;
 	int rc;
 
 	/* do we need to do it? */
Signature · 1 line
1.7.10.4
author
#2 lore raw
In reply to Dirk Behme

Am 20.12.2012 15:14, schrieb Dirk Behme:

Quoted 7 lines

Am 20.12.2012 15:10, schrieb Dirk Behme:

Quoted 6 lines

Make GCC happy by disabling the warning

drivers/ata/libata-core.c: In function 'ata_hpa_resize':
drivers/ata/libata-core.c:1394:3: warning: 'native_sectors' may be used uninitialized in this function [-Wmaybe-uninitialized]

Quoted 8 lines
Quoted 5 lines

Looking on the code, 'native_sectors' is always initialized by calling ata_read_native_max_address(dev, &native_sectors).

Ah, sorry, just saw that there is already a similar discussion from today. Seems this didn't make it to Google, yet ;)

Btw, regarding the "better to file a gcc bug report" in the previous thread:

Yes, agreed.

But looking at

http://lwn.net/Articles/529963/

there seem to be ~185 places in the kernel which don't want to wait for the GCC to be fixed.

Best regards

Dirk

Quoted 20 lines
Quoted 19 lines
---
  drivers/ata/libata-core.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-core.c +1 -1
index 9e8b99a..21623cf 100644
@@ -1324,7 +1324,7 @@ static int ata_hpa_resize(struct ata_device *dev)
      int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
      bool unlock_hpa = ata_ignore_hpa || dev->flags &
 ATA_DFLAG_UNLOCK_HPA;
      u64 sectors = ata_id_n_sectors(dev->id);
-    u64 native_sectors;
+    u64 native_sectors = 0 /* GCC */;
      int rc;
 
      /* do we need to do it? */