[2197] 2009-05-08 Pavel Roskin <[email protected]>

Pavel Roskin <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2197
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2197
Author:   proski
Date:     2009-05-08 19:21:26 +0000 (Fri, 08 May 2009)
Log Message:
-----------
2009-05-08  Pavel Roskin  <[email protected]>

	* 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.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/disk/raid6_recover.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-05-08 09:43:54 UTC (rev 2196)
+++ trunk/grub2/ChangeLog	2009-05-08 19:21:26 UTC (rev 2197)
@@ -1,3 +1,10 @@
+2009-05-08  Pavel Roskin  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* util/sparc64/ieee1275/grub-ofpathname.c (main): Set progname.

Modified: trunk/grub2/disk/raid6_recover.c
===================================================================
--- trunk/grub2/disk/raid6_recover.c	2009-05-08 09:43:54 UTC (rev 2196)
+++ trunk/grub2/disk/raid6_recover.c	2009-05-08 19:21:26 UTC (rev 2197)
@@ -92,7 +92,7 @@
                     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;
@@ -115,11 +115,10 @@
   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]) &&
@@ -131,10 +130,11 @@
             }
           else
             {
-              if (nerr >= 2)
+              /* Too many bad devices */
+              if (bad2 >= 0)
                 goto quit;
 
-              err[nerr++] = i;
+              bad2 = i;
               grub_errno = GRUB_ERR_NONE;
             }
         }
@@ -144,8 +144,13 @@
         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)))
         {
@@ -164,11 +169,12 @@
         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]))
@@ -187,10 +193,10 @@
 
       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);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.