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