From: Bruno Haible Date: Sun, 30 Sep 2018 21:16:45 +0000 (+0200) Subject: vasnprintf: Avoid warnings from GCC's -Wsign-compare. X-Git-Tag: v1.0~5390 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=857227b38e1953a9f42be3a1deb5b7b6e0c720b3;p=gnulib.git vasnprintf: Avoid warnings from GCC's -Wsign-compare. Reported by Bjarni Ingi Gislason in . * lib/vasnprintf.c (VASNPRINTF): Cast 'count' from 'int' to 'unsigned int' before comparison with an unsigned value. --- diff --git a/ChangeLog b/ChangeLog index 650e2a0db4..7f65662452 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2018-09-30 Bruno Haible + + vasnprintf: Avoid warnings from GCC's -Wsign-compare. + Reported by Bjarni Ingi Gislason in + . + * lib/vasnprintf.c (VASNPRINTF): Cast 'count' from 'int' to + 'unsigned int' before comparison with an unsigned value. + 2018-09-30 Bruno Haible grantpt: Remove unnecessary dependency. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 30d021b284..af3fcd1c7c 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -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. */