Hello! This is an fix for this warning:
disk/raid6_recover.c: In function 'grub_raid6_recover': disk/raid6_recover.c:95: warning: 'err[1]' may be used uninitialized in this function disk/raid6_recover.c:95: warning: 'err[0]' may be used uninitialized in this function The warning about err[0] appears to be legitimate. For some values of disknr err[0] will never be set. Namely, it will happen if disknr is equal p or p+1, for negative disknr and for disknr being more or equal array->total_devs. It's better to have a check for that case. The warning about err[1] is incorrect and can be easily eliminated once we realize that err[nerr++] is always err[1]. Since both err[0] and err[1] are only assigned positive values, we can initialize them with -1. This would also eliminate nerr, as we can check err[1] instead. It would be great to give better names to most variables. err[0] and err[1] could become separate variables. There is no need for them to be an array. And they are not error codes, despite what their names imply. Unfortunately, I'm not familiar enough with RAID6 to suggest better names. ChangeLog: * disk/raid6_recover.c (grub_raid6_recover): Fix warnings about uninitialized err[0] and err[1]. Initialize them with -1. Add sanity check for err[0]. Eliminate nerr variable. Index: disk/raid6_recover.c =================================================================== --- disk/raid6_recover.c (revision 2191) +++ disk/raid6_recover.c (working copy) @@ -92,7 +92,7 @@ char *buf, grub_disk_addr_t sector, int size) { int i, q, pos; - int err[2], nerr; + int err[2] = { -1, -1 }; char *pbuf = 0, *qbuf = 0; size <<= GRUB_DISK_SECTOR_BITS; @@ -115,7 +115,6 @@ if (pos == (int) array->total_devs) pos = 0; - nerr = 1; for (i = 0; i < (int) array->total_devs - 2; i++) { if (pos == disknr) @@ -131,10 +130,11 @@ } else { - if (nerr >= 2) + /* Too many bad devices */ + if (err[1] >= 0) goto quit; - err[nerr++] = i; + err[1] = i; grub_errno = GRUB_ERR_NONE; } } @@ -144,8 +144,13 @@ pos = 0; } - if (nerr == 1) + /* Invalid disknr or p */ + if (err[0] < 0) + goto quit; + + if (err[1] < 0) { + /* One bad device */ if ((array->device[p]) && (! grub_disk_read (array->device[p], sector, 0, size, buf))) { @@ -169,6 +174,7 @@ } else { + /* Two bad devices */ grub_uint8_t c; if ((! array->device[p]) || (! array->device[q])) -- Regards, Pavel Roskin _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel