bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] vasnprintf: silence mingw compiler warning


From: Eric Blake
Subject: [PATCH] vasnprintf: silence mingw compiler warning
Date: Thu, 30 May 2013 11:29:46 -0600

On mingw, vasnprintf is able to use snprintf, but not its return
value; this led to a situation where gcc warns:

vasnprintf.c: In function 'vasnprintf':
vasnprintf.c:4609:21: error: variable 'has_width' set but not used 
[-Werror=unused-but-set-variable]

Rather than hacking through a bunch of #ifdefs, where some used both
variables and others only used one, I changed the lone use of just
'width' to also use 'has_width'.

* lib/vasnprintf.c (VASNPRINTF): Avoid unused variable warning.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog        | 5 +++++
 lib/vasnprintf.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index aa74ea4..617901a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-05-29  Eric Blake  <address@hidden>
+
+       vasnprintf: silence mingw compiler warning
+       * lib/vasnprintf.c (VASNPRINTF): Avoid unused variable warning.
+
 2013-05-22  Eric Blake  <address@hidden>

        getgroups: document portability issues
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 4e64591..21f9169 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -5153,7 +5153,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                                 size_t tmp_length =
                                   MAX_ROOM_NEEDED (&a, dp->arg_index,
                                                    dp->conversion, type, flags,
-                                                   width, has_precision,
+                                                   has_width ? width : 0,
+                                                   has_precision,
                                                    precision, pad_ourselves);

                                 if (maxlen < tmp_length)
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]