Blame SOURCES/0099-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch

5593c8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5593c8
From: Peter Jones <pjones@redhat.com>
5593c8
Date: Thu, 11 Jul 2019 18:03:25 +0200
5593c8
Subject: [PATCH] Attempt to fix up all the places -Wsign-compare=error finds.
5593c8
5593c8
Signed-off-by: Peter Jones <pjones@redhat.com>
5593c8
---
fd0330
 grub-core/kern/emu/misc.c         |  2 +-
fd0330
 grub-core/lib/reed_solomon.c      |  4 ++--
fd0330
 grub-core/osdep/linux/blocklist.c |  2 +-
fd0330
 grub-core/osdep/linux/getroot.c   |  2 +-
fd0330
 grub-core/osdep/linux/hostdisk.c  |  2 +-
fd0330
 util/grub-fstest.c                |  2 +-
fd0330
 util/grub-menulst2cfg.c           |  2 +-
fd0330
 util/grub-mkfont.c                | 13 +++++++------
fd0330
 util/grub-probe.c                 |  2 +-
fd0330
 util/setup.c                      |  2 +-
fd0330
 10 files changed, 17 insertions(+), 16 deletions(-)
5593c8
5593c8
diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c
fd0330
index 0ff13bcaf8..d278c2921f 100644
5593c8
--- a/grub-core/kern/emu/misc.c
5593c8
+++ b/grub-core/kern/emu/misc.c
fd0330
@@ -185,7 +185,7 @@ grub_util_get_image_size (const char *path)
5593c8
   sz = ftello (f);
5593c8
   if (sz < 0)
5593c8
     grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
5593c8
-  if (sz != (size_t) sz)
5593c8
+  if (sz > (off_t)(GRUB_SIZE_MAX >> 1))
5593c8
     grub_util_error (_("file `%s' is too big"), path);
5593c8
   ret = (size_t) sz;
5593c8
 
5593c8
diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c
fd0330
index 467305b46a..79037c093f 100644
5593c8
--- a/grub-core/lib/reed_solomon.c
5593c8
+++ b/grub-core/lib/reed_solomon.c
5593c8
@@ -157,7 +157,7 @@ static void
5593c8
 rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs)
5593c8
 {
5593c8
   gf_single_t *rs_polynomial;
5593c8
-  int i, j;
5593c8
+  unsigned int i, j;
5593c8
   gf_single_t *m;
5593c8
   m = xcalloc (s + rs, sizeof (gf_single_t));
5593c8
   grub_memcpy (m, data, s * sizeof (gf_single_t));
5593c8
@@ -324,7 +324,7 @@ static void
5593c8
 encode_block (gf_single_t *ptr, grub_size_t s,
5593c8
 	      gf_single_t *rptr, grub_size_t rs)
5593c8
 {
5593c8
-  int i, j;
5593c8
+  unsigned int i, j;
5593c8
   for (i = 0; i < SECTOR_SIZE; i++)
5593c8
     {
5593c8
       grub_size_t ds = (s + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
5593c8
diff --git a/grub-core/osdep/linux/blocklist.c b/grub-core/osdep/linux/blocklist.c
fd0330
index c77d6085cc..42a315031f 100644
5593c8
--- a/grub-core/osdep/linux/blocklist.c
5593c8
+++ b/grub-core/osdep/linux/blocklist.c
5593c8
@@ -109,7 +109,7 @@ grub_install_get_blocklist (grub_device_t root_dev,
5593c8
   else
5593c8
     {
5593c8
       struct fiemap *fie2;
5593c8
-      int i;
5593c8
+      unsigned int i;
5593c8
       fie2 = xmalloc (sizeof (*fie2)
5593c8
 		      + fie1.fm_mapped_extents
5593c8
 		      * sizeof (fie1.fm_extents[1]));
5593c8
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
fd0330
index 28790307e0..9f730b3518 100644
5593c8
--- a/grub-core/osdep/linux/getroot.c
5593c8
+++ b/grub-core/osdep/linux/getroot.c
5593c8
@@ -236,7 +236,7 @@ grub_find_root_devices_from_btrfs (const char *dir)
5593c8
 {
5593c8
   int fd;
5593c8
   struct btrfs_ioctl_fs_info_args fsi;
5593c8
-  int i, j = 0;
5593c8
+  unsigned int i, j = 0;
5593c8
   char **ret;
5593c8
 
5593c8
   fd = open (dir, 0);
5593c8
diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c
fd0330
index da62f924e3..7bc99ac1c1 100644
5593c8
--- a/grub-core/osdep/linux/hostdisk.c
5593c8
+++ b/grub-core/osdep/linux/hostdisk.c
5593c8
@@ -83,7 +83,7 @@ grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_sec
5593c8
   if (sector_size & (sector_size - 1) || !sector_size)
5593c8
     return -1;
5593c8
   for (log_sector_size = 0;
5593c8
-       (1 << log_sector_size) < sector_size;
5593c8
+       (1U << log_sector_size) < sector_size;
5593c8
        log_sector_size++);
5593c8
 
5593c8
   if (log_secsize)
5593c8
diff --git a/util/grub-fstest.c b/util/grub-fstest.c
fd0330
index 8386564200..bfcef852d8 100644
5593c8
--- a/util/grub-fstest.c
5593c8
+++ b/util/grub-fstest.c
5593c8
@@ -323,7 +323,7 @@ cmd_cmp (char *src, char *dest)
5593c8
   read_file (src, cmp_hook, ff);
5593c8
 
5593c8
   {
5593c8
-    grub_uint64_t pre;
5593c8
+    long long pre;
5593c8
     pre = ftell (ff);
5593c8
     fseek (ff, 0, SEEK_END);
5593c8
     if (pre != ftell (ff))
5593c8
diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c
fd0330
index a39f869394..358d604210 100644
5593c8
--- a/util/grub-menulst2cfg.c
5593c8
+++ b/util/grub-menulst2cfg.c
5593c8
@@ -34,7 +34,7 @@ main (int argc, char **argv)
5593c8
   char *buf = NULL;
5593c8
   size_t bufsize = 0;
5593c8
   char *suffix = xstrdup ("");
5593c8
-  int suffixlen = 0;
5593c8
+  size_t suffixlen = 0;
5593c8
   const char *out_fname = 0;
5593c8
 
5593c8
   grub_util_host_init (&argc, &argv);
5593c8
diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c
fd0330
index 0fe45a6103..3e09240b99 100644
5593c8
--- a/util/grub-mkfont.c
5593c8
+++ b/util/grub-mkfont.c
5593c8
@@ -138,7 +138,8 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
5593c8
   int width, height;
5593c8
   int cuttop, cutbottom, cutleft, cutright;
5593c8
   grub_uint8_t *data;
5593c8
-  int mask, i, j, bitmap_size;
5593c8
+  int mask, i, bitmap_size;
5593c8
+  unsigned int j;
5593c8
   FT_GlyphSlot glyph;
5593c8
   int flag = FT_LOAD_RENDER | FT_LOAD_MONOCHROME;
5593c8
   FT_Error err;
5593c8
@@ -183,7 +184,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
5593c8
     cuttop = cutbottom = cutleft = cutright = 0;
5593c8
   else
5593c8
     {
5593c8
-      for (cuttop = 0; cuttop < glyph->bitmap.rows; cuttop++)
5593c8
+      for (cuttop = 0; cuttop < (long)glyph->bitmap.rows; cuttop++)
5593c8
 	{
5593c8
 	  for (j = 0; j < glyph->bitmap.width; j++)
5593c8
 	    if (glyph->bitmap.buffer[j / 8 + cuttop * glyph->bitmap.pitch]
5593c8
@@ -203,10 +204,10 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
5593c8
 	    break;
5593c8
 	}
5593c8
       cutbottom = glyph->bitmap.rows - 1 - cutbottom;
5593c8
-      if (cutbottom + cuttop >= glyph->bitmap.rows)
5593c8
+      if (cutbottom + cuttop >= (long)glyph->bitmap.rows)
5593c8
 	cutbottom = 0;
5593c8
 
5593c8
-      for (cutleft = 0; cutleft < glyph->bitmap.width; cutleft++)
5593c8
+      for (cutleft = 0; cutleft < (long)glyph->bitmap.width; cutleft++)
5593c8
 	{
5593c8
 	  for (j = 0; j < glyph->bitmap.rows; j++)
5593c8
 	    if (glyph->bitmap.buffer[cutleft / 8 + j * glyph->bitmap.pitch]
5593c8
@@ -225,7 +226,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
5593c8
 	    break;
5593c8
 	}
5593c8
       cutright = glyph->bitmap.width - 1 - cutright;
5593c8
-      if (cutright + cutleft >= glyph->bitmap.width)
5593c8
+      if (cutright + cutleft >= (long)glyph->bitmap.width)
5593c8
 	cutright = 0;
5593c8
     }
5593c8
 
5593c8
@@ -262,7 +263,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
5593c8
 
5593c8
   mask = 0;
5593c8
   data = &glyph_info->bitmap[0] - 1;
5593c8
-  for (j = cuttop; j < height + cuttop; j++)
5593c8
+  for (j = cuttop; j < (long)height + cuttop; j++)
5593c8
     for (i = cutleft; i < width + cutleft; i++)
5593c8
       add_pixel (&data, &mask,
5593c8
 		 glyph->bitmap.buffer[i / 8 + j * glyph->bitmap.pitch] &
5593c8
diff --git a/util/grub-probe.c b/util/grub-probe.c
fd0330
index c08e46bbb4..c6fac732b4 100644
5593c8
--- a/util/grub-probe.c
5593c8
+++ b/util/grub-probe.c
5593c8
@@ -798,7 +798,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
5593c8
 
5593c8
     case 't':
5593c8
       {
5593c8
-	int i;
5593c8
+	unsigned int i;
5593c8
 
5593c8
 	for (i = PRINT_FS; i < ARRAY_SIZE (targets); i++)
5593c8
 	  if (strcmp (arg, targets[i]) == 0)
5593c8
diff --git a/util/setup.c b/util/setup.c
fd0330
index da5f2c07f5..8b22bb8cca 100644
5593c8
--- a/util/setup.c
5593c8
+++ b/util/setup.c
5593c8
@@ -406,7 +406,7 @@ SETUP (const char *dir,
5593c8
     int is_ldm;
5593c8
     grub_err_t err;
5593c8
     grub_disk_addr_t *sectors;
5593c8
-    int i;
5593c8
+    unsigned int i;
5593c8
     grub_fs_t fs;
5593c8
     unsigned int nsec, maxsec;
5593c8