[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] vasnprintf: avoid a warning from gcc -Wsign-compare
From: |
Jim Meyering |
Subject: |
[PATCH] vasnprintf: avoid a warning from gcc -Wsign-compare |
Date: |
Wed, 15 Jun 2011 17:17:57 +0200 |
Hi Bruno,
I'm using -Wsign-compare in iwhd, and this is the sole warning
on F15 using gcc-4.7.x built from yesterday's upstream sources.
vasnprintf.c: In function 'vasnprintf':
vasnprintf.c:5093:35: error: comparison between signed and unsigned\
integer expressions [-Werror=sign-compare]
I know that we don't like to placate compilers, but...
Ok to commit?
>From 1213c3e195e1bc7def58c044f42d605086dea72d Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 15 Jun 2011 17:14:59 +0200
Subject: [PATCH] vasnprintf: avoid a warning from gcc -Wsign-compare
* lib/vasnprintf.c (VASNPRINTF): Cast a known-positive quantity to
size_t in order to avoid a warning from gcc -Wsign-compare.
---
ChangeLog | 6 ++++++
lib/vasnprintf.c | 2 +-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0669e49..e15a8cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-15 Jim Meyering <address@hidden>
+
+ vasnprintf: avoid a warning from gcc -Wsign-compare
+ * lib/vasnprintf.c (VASNPRINTF): Cast a known-positive quantity to
+ size_t in order to avoid a warning from gcc -Wsign-compare.
+
2011-06-14 Jim Meyering <address@hidden>
init.sh: give more portable redirection-related advice in a comment
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index d1eeaa5..03a5715 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -5088,7 +5088,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. */
--
1.7.6.rc0.293.g40857
- [PATCH] vasnprintf: avoid a warning from gcc -Wsign-compare,
Jim Meyering <=