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

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
---
8e15ce
 grub-core/kern/emu/misc.c                          |   2 +-
8e15ce
 grub-core/lib/reed_solomon.c                       |   4 +-
8e15ce
 grub-core/osdep/linux/blocklist.c                  |   2 +-
8e15ce
 grub-core/osdep/linux/getroot.c                    |   2 +-
8e15ce
 grub-core/osdep/linux/hostdisk.c                   |   2 +-
8e15ce
 util/grub-fstest.c                                 |   2 +-
8e15ce
 util/grub-menulst2cfg.c                            |   2 +-
8e15ce
 util/grub-mkfont.c                                 |  13 +-
8e15ce
 util/grub-probe.c                                  |   2 +-
8e15ce
 util/grub-rpm-sort.c                               |   2 +-
8e15ce
 util/setup.c                                       |   2 +-
8e15ce
 bootstrap.conf                                     |   3 +-
8e15ce
 .../gnulib-patches/fix-sign-compare-errors.patch   | 161 +++++++++++++++++++++
8e15ce
 13 files changed, 181 insertions(+), 18 deletions(-)
8e15ce
 create mode 100644 grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch
8e15ce
8e15ce
diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c
8e15ce
index eeea092752d..f08a1bb8415 100644
8e15ce
--- a/grub-core/kern/emu/misc.c
8e15ce
+++ b/grub-core/kern/emu/misc.c
8e15ce
@@ -189,7 +189,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
8e15ce
index 467305b46ab..79037c093f7 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
8e15ce
index c77d6085ccb..42a315031ff 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
8e15ce
index 28790307e00..9f730b35189 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
8e15ce
index da62f924e35..7bc99ac1c1d 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
8e15ce
index 83865642009..bfcef852d83 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
8e15ce
index a39f8693947..358d604210b 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
8e15ce
index 0fe45a6103d..3e09240b99f 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
8e15ce
index c08e46bbb40..c6fac732b40 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/grub-rpm-sort.c b/util/grub-rpm-sort.c
8e15ce
index f33bd1ed568..8345944105f 100644
8e15ce
--- a/util/grub-rpm-sort.c
8e15ce
+++ b/util/grub-rpm-sort.c
8e15ce
@@ -232,7 +232,7 @@ main (int argc, char *argv[])
8e15ce
   struct arguments arguments;
8e15ce
   char **package_names = NULL;
8e15ce
   size_t n_package_names = 0;
8e15ce
-  int i;
8e15ce
+  unsigned int i;
8e15ce
 
8e15ce
   grub_util_host_init (&argc, &argv);
8e15ce
 
8e15ce
diff --git a/util/setup.c b/util/setup.c
8e15ce
index da5f2c07f50..8b22bb8ccac 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
 
8e15ce
diff --git a/bootstrap.conf b/bootstrap.conf
8e15ce
index 6b043fc354c..186be9c48ce 100644
8e15ce
--- a/bootstrap.conf
8e15ce
+++ b/bootstrap.conf
8e15ce
@@ -80,7 +80,8 @@ cp -a INSTALL INSTALL.grub
8e15ce
 bootstrap_post_import_hook () {
8e15ce
   set -e
8e15ce
   for patchname in fix-base64 fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \
8e15ce
-      fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do
8e15ce
+      fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort \
8e15ce
+      fix-sign-compare-errors; do
8e15ce
     patch -d grub-core/lib/gnulib -p2 \
8e15ce
       < "grub-core/lib/gnulib-patches/$patchname.patch"
8e15ce
   done
8e15ce
diff --git a/grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch b/grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch
8e15ce
new file mode 100644
8e15ce
index 00000000000..479029c0565
8e15ce
--- /dev/null
8e15ce
+++ b/grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch
8e15ce
@@ -0,0 +1,161 @@
8e15ce
+diff --git a/lib/regcomp.c b/lib/regcomp.c
8e15ce
+index cc85f35ac58..361079d82d6 100644
8e15ce
+--- a/lib/regcomp.c
8e15ce
++++ b/lib/regcomp.c
8e15ce
+@@ -322,7 +322,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
8e15ce
+ 		*p++ = dfa->nodes[node].opr.c;
8e15ce
+ 	      memset (&state, '\0', sizeof (state));
8e15ce
+ 	      if (__mbrtowc (&wc, (const char *) buf, p - buf,
8e15ce
+-			     &state) == p - buf
8e15ce
++			     &state) == (size_t)(p - buf)
8e15ce
+ 		  && (__wcrtomb ((char *) buf, __towlower (wc), &state)
8e15ce
+ 		      != (size_t) -1))
8e15ce
+ 		re_set_fastmap (fastmap, false, buf[0]);
8e15ce
+@@ -3778,7 +3778,7 @@ fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
8e15ce
+       num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
8e15ce
+ 	     ? -2
8e15ce
+ 	     : num == -1
8e15ce
+-	     ? c - '0'
8e15ce
++	     ? (Idx)(c - '0')
8e15ce
+ 	     : MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
8e15ce
+     }
8e15ce
+   return num;
8e15ce
+diff --git a/lib/regex_internal.c b/lib/regex_internal.c
8e15ce
+index 9004ce809eb..193a1e3d332 100644
8e15ce
+--- a/lib/regex_internal.c
8e15ce
++++ b/lib/regex_internal.c
8e15ce
+@@ -233,7 +233,7 @@ build_wcs_buffer (re_string_t *pstr)
8e15ce
+       /* Apply the translation if we need.  */
8e15ce
+       if (__glibc_unlikely (pstr->trans != NULL))
8e15ce
+ 	{
8e15ce
+-	  int i, ch;
8e15ce
++	  unsigned int i, ch;
8e15ce
+ 
8e15ce
+ 	  for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
8e15ce
+ 	    {
8e15ce
+@@ -376,7 +376,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
8e15ce
+ 	prev_st = pstr->cur_state;
8e15ce
+ 	if (__glibc_unlikely (pstr->trans != NULL))
8e15ce
+ 	  {
8e15ce
+-	    int i, ch;
8e15ce
++	    unsigned int i, ch;
8e15ce
+ 
8e15ce
+ 	    for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
8e15ce
+ 	      {
8e15ce
+@@ -754,7 +754,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
8e15ce
+ 			  memset (&cur_state, 0, sizeof (cur_state));
8e15ce
+ 			  mbclen = __mbrtowc (&wc2, (const char *) pp, mlen,
8e15ce
+ 					      &cur_state);
8e15ce
+-			  if (raw + offset - p <= mbclen
8e15ce
++			  if ((size_t)(raw + offset - p) <= mbclen
8e15ce
+ 			      && mbclen < (size_t) -2)
8e15ce
+ 			    {
8e15ce
+ 			      memset (&pstr->cur_state, '\0',
8e15ce
+diff --git a/lib/regex_internal.h b/lib/regex_internal.h
8e15ce
+index 5462419b787..e0f8292395d 100644
8e15ce
+--- a/lib/regex_internal.h
8e15ce
++++ b/lib/regex_internal.h
8e15ce
+@@ -425,7 +425,7 @@ struct re_string_t
8e15ce
+   unsigned char offsets_needed;
8e15ce
+   unsigned char newline_anchor;
8e15ce
+   unsigned char word_ops_used;
8e15ce
+-  int mb_cur_max;
8e15ce
++  unsigned int mb_cur_max;
8e15ce
+ };
8e15ce
+ typedef struct re_string_t re_string_t;
8e15ce
+ 
8e15ce
+@@ -702,7 +702,7 @@ struct re_dfa_t
8e15ce
+   unsigned int is_utf8 : 1;
8e15ce
+   unsigned int map_notascii : 1;
8e15ce
+   unsigned int word_ops_used : 1;
8e15ce
+-  int mb_cur_max;
8e15ce
++  unsigned int mb_cur_max;
8e15ce
+   bitset_t word_char;
8e15ce
+   reg_syntax_t syntax;
8e15ce
+   Idx *subexp_map;
8e15ce
+diff --git a/lib/regexec.c b/lib/regexec.c
8e15ce
+index 0a7a27b772e..b57d4f9141d 100644
8e15ce
+--- a/lib/regexec.c
8e15ce
++++ b/lib/regexec.c
8e15ce
+@@ -443,7 +443,7 @@ re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
8e15ce
+     {
8e15ce
+       if (ret_len)
8e15ce
+ 	{
8e15ce
+-	  assert (pmatch[0].rm_so == start);
8e15ce
++	  assert (pmatch[0].rm_so == (long)start);
8e15ce
+ 	  rval = pmatch[0].rm_eo - start;
8e15ce
+ 	}
8e15ce
+       else
8e15ce
+@@ -877,11 +877,11 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
8e15ce
+ 	    if (__glibc_unlikely (mctx.input.offsets_needed != 0))
8e15ce
+ 	      {
8e15ce
+ 		pmatch[reg_idx].rm_so =
8e15ce
+-		  (pmatch[reg_idx].rm_so == mctx.input.valid_len
8e15ce
++		  (pmatch[reg_idx].rm_so == (long)mctx.input.valid_len
8e15ce
+ 		   ? mctx.input.valid_raw_len
8e15ce
+ 		   : mctx.input.offsets[pmatch[reg_idx].rm_so]);
8e15ce
+ 		pmatch[reg_idx].rm_eo =
8e15ce
+-		  (pmatch[reg_idx].rm_eo == mctx.input.valid_len
8e15ce
++		  (pmatch[reg_idx].rm_eo == (long)mctx.input.valid_len
8e15ce
+ 		   ? mctx.input.valid_raw_len
8e15ce
+ 		   : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
8e15ce
+ 	      }
8e15ce
+@@ -1418,11 +1418,11 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
8e15ce
+     }
8e15ce
+   memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
8e15ce
+ 
8e15ce
+-  for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
8e15ce
++  for (idx = pmatch[0].rm_so; idx <= (long)pmatch[0].rm_eo ;)
8e15ce
+     {
8e15ce
+       update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
8e15ce
+ 
8e15ce
+-      if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
8e15ce
++      if (idx == (long)pmatch[0].rm_eo && cur_node == mctx->last_node)
8e15ce
+ 	{
8e15ce
+ 	  Idx reg_idx;
8e15ce
+ 	  if (fs)
8e15ce
+@@ -1519,7 +1519,7 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
8e15ce
+       if (reg_num < nmatch)
8e15ce
+ 	{
8e15ce
+ 	  /* We are at the last node of this sub expression.  */
8e15ce
+-	  if (pmatch[reg_num].rm_so < cur_idx)
8e15ce
++	  if (pmatch[reg_num].rm_so < (long)cur_idx)
8e15ce
+ 	    {
8e15ce
+ 	      pmatch[reg_num].rm_eo = cur_idx;
8e15ce
+ 	      /* This is a non-empty match or we are not inside an optional
8e15ce
+@@ -2938,7 +2938,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
8e15ce
+       mctx->state_log[str_idx] = cur_state;
8e15ce
+     }
8e15ce
+ 
8e15ce
+-  for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;)
8e15ce
++  for (null_cnt = 0; str_idx < last_str && null_cnt <= (long)mctx->max_mb_elem_len;)
8e15ce
+     {
8e15ce
+       re_node_set_empty (&next_nodes);
8e15ce
+       if (mctx->state_log[str_idx + 1])
8e15ce
+@@ -3718,7 +3718,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
8e15ce
+ 			 const re_string_t *input, Idx str_idx)
8e15ce
+ {
8e15ce
+   const re_token_t *node = dfa->nodes + node_idx;
8e15ce
+-  int char_len, elem_len;
8e15ce
++  unsigned int char_len, elem_len;
8e15ce
+   Idx i;
8e15ce
+ 
8e15ce
+   if (__glibc_unlikely (node->type == OP_UTF8_PERIOD))
8e15ce
+@@ -4066,7 +4066,7 @@ extend_buffers (re_match_context_t *mctx, int min_len)
8e15ce
+   /* Double the lengths of the buffers, but allocate at least MIN_LEN.  */
8e15ce
+   ret = re_string_realloc_buffers (pstr,
8e15ce
+ 				   MAX (min_len,
8e15ce
+-					MIN (pstr->len, pstr->bufs_len * 2)));
8e15ce
++					MIN ((long)pstr->len, pstr->bufs_len * 2)));
8e15ce
+   if (__glibc_unlikely (ret != REG_NOERROR))
8e15ce
+     return ret;
8e15ce
+ 
8e15ce
+@@ -4236,7 +4236,7 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
8e15ce
+     = (from == to ? -1 : 0);
8e15ce
+ 
8e15ce
+   mctx->bkref_ents[mctx->nbkref_ents++].more = 0;
8e15ce
+-  if (mctx->max_mb_elem_len < to - from)
8e15ce
++  if (mctx->max_mb_elem_len < (long)(to - from))
8e15ce
+     mctx->max_mb_elem_len = to - from;
8e15ce
+   return REG_NOERROR;
8e15ce
+ }