]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/disk/raid6_recover.c: Use unsigned arithmetics when
authorVladimir Serbinenko <phcoder@gmail.com>
Fri, 25 Oct 2013 20:51:03 +0000 (22:51 +0200)
committerVladimir Serbinenko <phcoder@gmail.com>
Fri, 25 Oct 2013 20:51:03 +0000 (22:51 +0200)
appropriate.

ChangeLog
grub-core/disk/raid6_recover.c

index d7235e3685220bcc08bc454eeedd12de22a16d06..2cc67a772d96868aa34249fd5666667f90f44228 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-25  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/disk/raid6_recover.c: Use unsigned arithmetics when
+       appropriate.
+
 2013-10-25  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/video/bitmap_scale.c: Use unsigned arithmetics when
index ba889ba3de37cafbb1dba77e54086288516af0bc..61a8ba6665b465c2477e90dd6f74449da90328ed 100644 (file)
@@ -30,11 +30,11 @@ GRUB_MOD_LICENSE ("GPLv3+");
 /* x**y.  */
 static grub_uint8_t powx[255 * 2];
 /* Such an s that x**s = y */
-static int powx_inv[256];
+static unsigned powx_inv[256];
 static const grub_uint8_t poly = 0x1d;
 
 static void
-grub_raid_block_mulx (int mul, char *buf, int size)
+grub_raid_block_mulx (unsigned mul, char *buf, int size)
 {
   int i;
   grub_uint8_t *p;
@@ -48,7 +48,7 @@ grub_raid_block_mulx (int mul, char *buf, int size)
 static void
 grub_raid6_init_table (void)
 {
-  int i;
+  unsigned i;
 
   grub_uint8_t cur = 1;
   for (i = 0; i < 255; i++)
@@ -148,7 +148,7 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
   else
     {
       /* Two bad devices */
-      int c;
+      unsigned c;
 
       if (grub_diskfilter_read_node (&array->nodes[p], sector,
                                     size >> GRUB_DISK_SECTOR_BITS, buf))
@@ -162,10 +162,11 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
 
       grub_crypto_xor (qbuf, qbuf, buf, size);
 
-      c = (255 - bad1 + (255 - powx_inv[(powx[bad2 - bad1 + 255] ^ 1)])) % 255;
+      c = ((255 ^ bad1)
+          + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])) % 255;
       grub_raid_block_mulx (c, qbuf, size);
 
-      c = (bad2 + c) % 255;
+      c = ((unsigned) bad2 + c) % 255;
       grub_raid_block_mulx (c, pbuf, size);
 
       grub_crypto_xor (pbuf, pbuf, qbuf, size);