+2009-05-08 Pavel Roskin <proski@gnu.org>
+
+ * disk/raid6_recover.c (grub_raid6_recover): Fix warnings about
+ uninitialized err[0] and err[1]. Rename them to bad1 and bad2.
+ Initialize them with -1. Add sanity check for bad1. Eliminate
+ nerr variable.
+
2009-05-08 David S. Miller <davem@davemloft.net>
* util/sparc64/ieee1275/grub-ofpathname.c (main): Set progname.
char *buf, grub_disk_addr_t sector, int size)
{
int i, q, pos;
- int err[2], nerr;
+ int bad1 = -1, bad2 = -1;
char *pbuf = 0, *qbuf = 0;
size <<= GRUB_DISK_SECTOR_BITS;
if (pos == (int) array->total_devs)
pos = 0;
- nerr = 1;
for (i = 0; i < (int) array->total_devs - 2; i++)
{
if (pos == disknr)
- err[0] = i;
+ bad1 = i;
else
{
if ((array->device[pos]) &&
}
else
{
- if (nerr >= 2)
+ /* Too many bad devices */
+ if (bad2 >= 0)
goto quit;
- err[nerr++] = i;
+ bad2 = i;
grub_errno = GRUB_ERR_NONE;
}
}
pos = 0;
}
- if (nerr == 1)
+ /* Invalid disknr or p */
+ if (bad1 < 0)
+ goto quit;
+
+ if (bad2 < 0)
{
+ /* One bad device */
if ((array->device[p]) &&
(! grub_disk_read (array->device[p], sector, 0, size, buf)))
{
goto quit;
grub_raid_block_xor (buf, qbuf, size);
- grub_raid_block_mul (raid6_table2[255 - err[0]][255 - err[0]], buf,
+ grub_raid_block_mul (raid6_table2[255 - bad1][255 - bad1], buf,
size);
}
else
{
+ /* Two bad devices */
grub_uint8_t c;
if ((! array->device[p]) || (! array->device[q]))
grub_raid_block_xor (qbuf, buf, size);
- c = raid6_table2[err[1]][err[0]];
+ c = raid6_table2[bad2][bad1];
grub_raid_block_mul (c, qbuf, size);
- c = raid6_table1[raid6_table2[err[1]][err[1]]][c];
+ c = raid6_table1[raid6_table2[bad2][bad2]][c];
grub_raid_block_mul (c, pbuf, size);
grub_raid_block_xor (pbuf, qbuf, size);