changeset 39873:6b0218435966

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.
author Bruno Haible <bruno@clisp.org>
date Sun, 30 Sep 2018 23:16:45 +0200
parents 7e5e23ac78b6
children 96d0c10a7473
files ChangeLog lib/vasnprintf.c
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Sep 30 19:50:34 2018 +0200
+++ b/ChangeLog	Sun Sep 30 23:16:45 2018 +0200
@@ -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.
--- a/lib/vasnprintf.c	Sun Sep 30 19:50:34 2018 +0200
+++ b/lib/vasnprintf.c	Sun Sep 30 23:16:45 2018 +0200
@@ -2696,7 +2696,7 @@
                               errno = EILSEQ;
                               return NULL;
                             }
-                          if (precision < count)
+                          if (precision < (unsigned int) count)
                             break;
                           arg_end++;
                           characters += count;
@@ -5127,7 +5127,7 @@
                       {
                         /* 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.  */