]> Savannah Git Hosting - gnulib.git/commitdiff
vasnprintf: Avoid warnings from GCC's -Wsign-compare.
authorBruno Haible <bruno@clisp.org>
Sun, 30 Sep 2018 21:16:45 +0000 (23:16 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 30 Sep 2018 21:16:45 +0000 (23:16 +0200)
Reported by Bjarni Ingi Gislason <bjarniig@rhi.hi.is> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00105.html>.

* lib/vasnprintf.c (VASNPRINTF): Cast 'count' from 'int' to
'unsigned int' before comparison with an unsigned value.

ChangeLog
lib/vasnprintf.c

index 650e2a0db4d0330c1bbd1fe8d0b25755ec1d3c2b..7f65662452214bb7b838da981922fc8b05c2febe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-09-30  Bruno Haible  <bruno@clisp.org>
+
+       vasnprintf: Avoid warnings from GCC's -Wsign-compare.
+       Reported by Bjarni Ingi Gislason <bjarniig@rhi.hi.is> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00105.html>.
+       * lib/vasnprintf.c (VASNPRINTF): Cast 'count' from 'int' to
+       'unsigned int' before comparison with an unsigned value.
+
 2018-09-30  Bruno Haible  <bruno@clisp.org>
 
        grantpt: Remove unnecessary dependency.
index 30d021b2847d47ee73611f4f52c7028d0b999d9a..af3fcd1c7c8d8b5e139c04460da83635c999ad55 100644 (file)
@@ -2696,7 +2696,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                               errno = EILSEQ;
                               return NULL;
                             }
-                          if (precision < count)
+                          if (precision < (unsigned int) count)
                             break;
                           arg_end++;
                           characters += count;
@@ -5127,7 +5127,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                       {
                         /* Verify that snprintf() has NUL-terminated its
                            result.  */
-                        if (count < maxlen
+                        if ((unsigned int) count < maxlen
                             && ((TCHAR_T *) (result + length)) [count] != '\0')
                           abort ();
                         /* Portability hack.  */