diff --git a/gnu/dist/grep/lib/getopt.c b/gnu/dist/grep/lib/getopt.c
index 6d7b10b3e9..f3d69bc07e 100644
--- a/gnu/dist/grep/lib/getopt.c
+++ b/gnu/dist/grep/lib/getopt.c
@@ -431,7 +431,7 @@ _getopt_initialize (argc, argv, optstring)
         else
           {
             const char *orig_str = __getopt_nonoption_flags;
-             int len = nonoption_flags_max_len = strlen (orig_str);
+             size_t len = nonoption_flags_max_len = strlen (orig_str);
             if (nonoption_flags_max_len < argc)
               nonoption_flags_max_len = argc;
             __getopt_nonoption_flags =
diff --git a/gnu/dist/grep/lib/regex.c b/gnu/dist/grep/lib/regex.c
index 169890f491..ac0512da38 100644
--- a/gnu/dist/grep/lib/regex.c
+++ b/gnu/dist/grep/lib/regex.c
@@ -1127,7 +1127,7 @@ print_double_string (where, string1, size1, string2, size2)
    int size1;
    int size2;
{
-  int this_char;
+  ptrdiff_t this_char;

  if (where == NULL)
    printf ("(null)");
diff --git a/gnu/dist/grep/src/ansi2knr.c b/gnu/dist/grep/src/ansi2knr.c
index bacb6f9894..e014720825 100644
--- a/gnu/dist/grep/src/ansi2knr.c
+++ b/gnu/dist/grep/src/ansi2knr.c
@@ -461,7 +461,7 @@ test1(buf)
          }
          {
              char *id = p;
-              int len;
+              ptrdiff_t len;
              /*
               * Check for identifier1(identifier2) and not
               * identifier1(void), or identifier1(identifier2, xxxx).
diff --git a/gnu/dist/grep/src/dfa.c b/gnu/dist/grep/src/dfa.c
index 9220bfeb46..7c4050b71e 100644
--- a/gnu/dist/grep/src/dfa.c
+++ b/gnu/dist/grep/src/dfa.c
@@ -334,9 +334,10 @@ static int hard_LC_COLLATE;        /* Nonzero if LC_COLLATE is hard.  */
#ifdef MBS_SUPPORT
/* These variables are used only if (MB_CUR_MAX > 1).  */
static mbstate_t mbs;          /* Mbstate for mbrlen().  */
-static int cur_mb_len;         /* Byte length of the current scanning
-                                  multibyte character.  */
-static int cur_mb_index;        /* Byte index of the current scanning multibyte
+static ssize_t cur_mb_len;     /* Byte length of the current scanning
+                                  multibyte character.  Must also handle
+                                  negative result from mbrlen().  */
+static ssize_t cur_mb_index;    /* Byte index of the current scanning multibyte
                                   character.

                                  singlebyte character : cur_mb_index = 0
@@ -369,7 +370,7 @@ static unsigned char const *buf_end;        /* refference to end in dfaexec().  */
/* This function update cur_mb_len, and cur_mb_index.
   p points current lexptr, len is the remaining buffer length.  */
static void
-update_mb_len_index (unsigned char const *p, int len)
+update_mb_len_index (unsigned char const *p, size_t len)
{
  /* If last character is a part of a multibyte character,
     we update cur_mb_index.  */
@@ -2465,7 +2466,7 @@ match_mb_charset (struct dfa *d, int s, position pos, int index)
  int match;           /* Flag which represent that matching succeed.  */
  int match_len;       /* Length of the character (or collating element)
                          with which this operator match.  */
-  int op_len;          /* Length of the operator.  */
+  size_t op_len;       /* Length of the operator.  */
  char buffer[128];
  wchar_t wcbuf[6];

diff --git a/gnu/dist/grep/src/grep.c b/gnu/dist/grep/src/grep.c
index 3051d52037..5bc636eb0c 100644
--- a/gnu/dist/grep/src/grep.c
+++ b/gnu/dist/grep/src/grep.c
@@ -1286,9 +1286,9 @@ int
main (int argc, char **argv)
{
  char *keys;
-  size_t keycc, oldcc, keyalloc;
+  size_t cc, keycc, oldcc, keyalloc;
  int with_filenames;
-  int opt, cc, status;
+  int opt, status;
  int default_context;
  FILE *fp;
  extern char *optarg;
diff --git a/gnu/dist/grep/src/search.c b/gnu/dist/grep/src/search.c
index b7768f8c4d..6cb836c15f 100644
--- a/gnu/dist/grep/src/search.c
+++ b/gnu/dist/grep/src/search.c
@@ -153,7 +153,7 @@ check_multibyte_string(char const *buf, size_t size)
{
  char *mb_properties = malloc(size);
  mbstate_t cur_state;
-  int i;
+  size_t i;
  memset(&cur_state, 0, sizeof(mbstate_t));
  memset(mb_properties, 0, sizeof(char)*size);
  for (i = 0; i < size ;)
@@ -339,7 +339,8 @@ EGexecute (char const *buf, size_t size, size_t *match_size, int exact)
{
  register char const *buflim, *beg, *end;
  char eol = eolbyte;
-  int backref, start, len;
+  int backref;
+  ptrdiff_t start, len;
  struct kwsmatch kwsm;
  size_t i;
#ifdef MBS_SUPPORT