trim: avoid a warning from -O2 -Wstrict-overflow
authorJim Meyering <meyering@redhat.com>
Sat, 28 May 2011 14:00:20 +0000 (16:00 +0200)
committerIan Beckwith <ianb@erislabs.net>
Thu, 9 Jun 2011 19:48:15 +0000 (20:48 +0100)
* lib/trim.c (trim2): Declare local to be "unsigned int", not "int".
(cherry picked from commit 244906802a300a1744de8881857a3a2897b3db8b)

ChangeLog
lib/trim.c

index 8d20573..3f5235a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-28  Jim Meyering  <meyering@redhat.com>
+
+       trim: avoid a warning from -O2 -Wstrict-overflow
+       * lib/trim.c (trim2): Declare local to be "unsigned int", not "int".
+
 2011-05-28  Bruno Haible  <bruno@clisp.org>
 
        getloadavg: Remove an unreliable safety check.
index 1f4d0c1..6515cfa 100644 (file)
@@ -65,7 +65,7 @@ trim2 (const char *s, int how)
       /* Trim trailing whitespaces. */
       if (how != TRIM_LEADING)
         {
-          int state = 0;
+          unsigned int state = 0;
           char *r IF_LINT (= NULL); /* used only while state = 2 */
 
           mbi_init (i, d, strlen (d));
@@ -130,4 +130,3 @@ trim2 (const char *s, int how)
 
   return d;
 }
-