[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] lib/vasnprintf.c: Add information to make integer comparison log
From: |
Bjarni Ingi Gislason |
Subject: |
[PATCH] lib/vasnprintf.c: Add information to make integer comparison logical |
Date: |
Sat, 22 Sep 2018 18:16:59 +0000 |
User-agent: |
Mutt/1.5.20 (2009-12-10) |
A question (comment) from the compiler (gcc 8.2):
../lib/vasnprintf.c:5107:35: warning: comparison of integer expressions of
different signedness: 'int' and 'size_t' {aka 'long unsigned int'}
[-Wsign-compare]
if (count < maxlen
^
The value of "count" is tested to be non-negative, so a cast to
"size_t" is valid.
Signed-off-by: Bjarni Ingi Gislason <address@hidden>
---
lib/vasnprintf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 56ffbe308..bf9d6dea9 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -5125,7 +5125,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
{
/* Verify that snprintf() has NUL-terminated its
result. */
- if (count < maxlen
+ if ((size_t) count < maxlen
&& ((TCHAR_T *) (result + length)) [count] != '\0')
abort ();
/* Portability hack. */
--
2.19.0
--
Bjarni I. Gislason
- [PATCH] lib/vasnprintf.c: Add information to make integer comparison logical,
Bjarni Ingi Gislason <=