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.
This commit is contained in:
proski 2009-05-08 19:21:26 +00:00
parent 172800ce74
commit 041b8094ac
2 changed files with 22 additions and 9 deletions

View file

@ -1,3 +1,10 @@
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> 2009-05-08 David S. Miller <davem@davemloft.net>
* util/sparc64/ieee1275/grub-ofpathname.c (main): Set progname. * util/sparc64/ieee1275/grub-ofpathname.c (main): Set progname.

View file

@ -92,7 +92,7 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
char *buf, grub_disk_addr_t sector, int size) char *buf, grub_disk_addr_t sector, int size)
{ {
int i, q, pos; int i, q, pos;
int err[2], nerr; int bad1 = -1, bad2 = -1;
char *pbuf = 0, *qbuf = 0; char *pbuf = 0, *qbuf = 0;
size <<= GRUB_DISK_SECTOR_BITS; size <<= GRUB_DISK_SECTOR_BITS;
@ -115,11 +115,10 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
if (pos == (int) array->total_devs) if (pos == (int) array->total_devs)
pos = 0; pos = 0;
nerr = 1;
for (i = 0; i < (int) array->total_devs - 2; i++) for (i = 0; i < (int) array->total_devs - 2; i++)
{ {
if (pos == disknr) if (pos == disknr)
err[0] = i; bad1 = i;
else else
{ {
if ((array->device[pos]) && if ((array->device[pos]) &&
@ -131,10 +130,11 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
} }
else else
{ {
if (nerr >= 2) /* Too many bad devices */
if (bad2 >= 0)
goto quit; goto quit;
err[nerr++] = i; bad2 = i;
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
} }
} }
@ -144,8 +144,13 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
pos = 0; pos = 0;
} }
if (nerr == 1) /* Invalid disknr or p */
if (bad1 < 0)
goto quit;
if (bad2 < 0)
{ {
/* One bad device */
if ((array->device[p]) && if ((array->device[p]) &&
(! grub_disk_read (array->device[p], sector, 0, size, buf))) (! grub_disk_read (array->device[p], sector, 0, size, buf)))
{ {
@ -164,11 +169,12 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
goto quit; goto quit;
grub_raid_block_xor (buf, qbuf, size); 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); size);
} }
else else
{ {
/* Two bad devices */
grub_uint8_t c; grub_uint8_t c;
if ((! array->device[p]) || (! array->device[q])) if ((! array->device[p]) || (! array->device[q]))
@ -187,10 +193,10 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
grub_raid_block_xor (qbuf, buf, size); 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); 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_mul (c, pbuf, size);
grub_raid_block_xor (pbuf, qbuf, size); grub_raid_block_xor (pbuf, qbuf, size);