From 857227b38e1953a9f42be3a1deb5b7b6e0c720b3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 30 Sep 2018 23:16:45 +0200 Subject: [PATCH] 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. --- ChangeLog | 8 ++++++++ lib/vasnprintf.c | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) 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. */ -- 2.39.5