[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] lib/vasnprintf.c: Add information to make integer comparison
From: |
Bruno Haible |
Subject: |
Re: [PATCH] lib/vasnprintf.c: Add information to make integer comparison logical |
Date: |
Sun, 30 Sep 2018 23:17:41 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-134-generic; KDE/5.18.0; x86_64; ; ) |
Hi Bjarni,
Haven't heard back from you in a week. So I'm applying this patch.
2018-09-30 Bruno Haible <address@hidden>
vasnprintf: Avoid warnings from GCC's -Wsign-compare.
Reported by Bjarni Ingi Gislason <address@hidden> 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.
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 30d021b..af3fcd1 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. */