Skip to contentSkip to conversation

diskfilter: Treat an unrecognized RAID level as an error

PATCH In review Richard Laager 2 participants 3 messages Feb 4, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 diskfilter: Treat an unrecognized RAID level as an error

disk/diskfilter.c: In function 'grub_diskfilter_make_raid':
disk/diskfilter.c:847:21: error: 'totsize' may be used uninitialized in this function [-Werror=uninitialized]

Perhaps my patch should use assert() instead of return NULL?

Signature · 1 line
Richard

diskfilter: Treat an unrecognized RAID level as an error

disk/diskfilter.c: In function 'grub_diskfilter_make_raid':
disk/diskfilter.c:847:21: error: 'totsize' may be used uninitialized in this function [-Werror=uninitialized]

Perhaps this should be an assert() instead of return NULL?

=== modified file 'grub-core/disk/diskfilter.c'

grub-core/disk/diskfilter.c +3 -0
Index: grub/grub-core/disk/diskfilter.c
===================================================================
@@ -837,6 +837,9 @@ grub_diskfilter_make_raid (grub_size_t u
     case 6:
       totsize = (nmemb - level / 3) * disk_size;
       break;
+
+    default:
+      return NULL;
     }
 
   array = grub_diskfilter_get_vg_by_uuid (uuidlen, uuid);
#1 lore raw
Quoted 5 lines · Richard Laager

disk/diskfilter.c: In function 'grub_diskfilter_make_raid':
disk/diskfilter.c:847:21: error: 'totsize' may be used uninitialized in this function [-Werror=uninitialized]

Perhaps my patch should use assert() instead of return NULL?

We don't use assert since assert failures are usually not fatal. And failing to boot just because some otherwise unused disk has a RAID-9 isn't reasonable.

Quoted 6 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#2 lore raw
Quoted 9 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 5 lines · Richard Laager

disk/diskfilter.c: In function 'grub_diskfilter_make_raid':
disk/diskfilter.c:847:21: error: 'totsize' may be used uninitialized in this function [-Werror=uninitialized]

Perhaps my patch should use assert() instead of return NULL?

We don't use assert since assert failures are usually not fatal. And failing to boot just because some otherwise unused disk has a RAID-9 isn't reasonable.

Noted. I see now that Grégoire Sutre already submitted the same fix. I don't know how I missed that mail before. Sorry for the noise. At least I learned about GRUB's take on assert().

Signature · 1 line
Richard