From ed893045a0d0f3c48d3f562075d15905452b94e5 Mon Sep 17 00:00:00 2001
From: Eric Blake <ebb9@byu.net>
Date: Fri, 30 Oct 2009 10:24:45 -0600
Subject: [PATCH] vasnprintf: avoid compiler warnings

* lib/vasnprintf.c (VASNPRINTF): Avoid shadowing our own local
variables.
* lib/printf-args.c (PRINTF_FETCHARGS): Avoid type mismatch.

Signed-off-by: Eric Blake <ebb9@byu.net>
---
 ChangeLog         |  7 +++++++
 lib/printf-args.c |  5 +++--
 lib/vasnprintf.c  | 36 ++++++++++++++++++------------------
 3 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 812f3e506f..e4179347a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-11-17  Eric Blake  <ebb9@byu.net>
+
+	vasnprintf: avoid compiler warnings
+	* lib/vasnprintf.c (VASNPRINTF): Avoid shadowing our own local
+	variables.
+	* lib/printf-args.c (PRINTF_FETCHARGS): Avoid type mismatch.
+
 2009-11-17  Simon Josefsson  <simon@josefsson.org>
 
 	* modules/xalloc-die-tests (Makefile.am): Drop XFAIL_TESTS
diff --git a/lib/printf-args.c b/lib/printf-args.c
index 4978914662..e9942397ad 100644
--- a/lib/printf-args.c
+++ b/lib/printf-args.c
@@ -1,5 +1,6 @@
 /* Decomposed printf argument list.
-   Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2003, 2005-2007, 2009 Free Software
+   Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -89,7 +90,7 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
 	   where wint_t is 'unsigned short'.  */
 	ap->a.a_wide_char =
 	  (sizeof (wint_t) < sizeof (int)
-	   ? va_arg (args, int)
+	   ? (wint_t) va_arg (args, int)
 	   : va_arg (args, wint_t));
 	break;
 #endif
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 661445cb41..ab662888b0 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -2375,16 +2375,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 		      characters = 0;
 		      while (precision > 0)
 			{
-			  char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			  char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
 			  int count;
 
 			  if (*arg_end == 0)
 			    /* Found the terminating null wide character.  */
 			    break;
 #  if HAVE_WCRTOMB
-			  count = wcrtomb (buf, *arg_end, &state);
+			  count = wcrtomb (cbuf, *arg_end, &state);
 #  else
-			  count = wctomb (buf, *arg_end);
+			  count = wctomb (cbuf, *arg_end);
 #  endif
 			  if (count < 0)
 			    {
@@ -2420,16 +2420,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 		      characters = 0;
 		      for (;;)
 			{
-			  char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			  char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
 			  int count;
 
 			  if (*arg_end == 0)
 			    /* Found the terminating null wide character.  */
 			    break;
 #  if HAVE_WCRTOMB
-			  count = wcrtomb (buf, *arg_end, &state);
+			  count = wcrtomb (cbuf, *arg_end, &state);
 #  else
-			  count = wctomb (buf, *arg_end);
+			  count = wctomb (cbuf, *arg_end);
 #  endif
 			  if (count < 0)
 			    {
@@ -2470,20 +2470,20 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 #   endif
 		    for (remaining = characters; remaining > 0; )
 		      {
-			char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
 			int count;
 
 			if (*arg == 0)
 			  abort ();
 #   if HAVE_WCRTOMB
-			count = wcrtomb (buf, *arg, &state);
+			count = wcrtomb (cbuf, *arg, &state);
 #   else
-			count = wctomb (buf, *arg);
+			count = wctomb (cbuf, *arg);
 #   endif
 			if (count <= 0)
 			  /* Inconsistency.  */
 			  abort ();
-			memcpy (tmpptr, buf, count);
+			memcpy (tmpptr, cbuf, count);
 			tmpptr += count;
 			arg++;
 			remaining -= count;
@@ -2552,20 +2552,20 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 		      ENSURE_ALLOCATION (xsum (length, characters));
 		      for (remaining = characters; remaining > 0; )
 			{
-			  char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			  char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
 			  int count;
 
 			  if (*arg == 0)
 			    abort ();
 #   if HAVE_WCRTOMB
-			  count = wcrtomb (buf, *arg, &state);
+			  count = wcrtomb (cbuf, *arg, &state);
 #   else
-			  count = wctomb (buf, *arg);
+			  count = wctomb (cbuf, *arg);
 #   endif
 			  if (count <= 0)
 			    /* Inconsistency.  */
 			    abort ();
-			  memcpy (result + length, buf, count);
+			  memcpy (result + length, cbuf, count);
 			  length += count;
 			  arg++;
 			  remaining -= count;
@@ -2581,21 +2581,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 #   endif
 		      while (arg < arg_end)
 			{
-			  char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			  char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
 			  int count;
 
 			  if (*arg == 0)
 			    abort ();
 #   if HAVE_WCRTOMB
-			  count = wcrtomb (buf, *arg, &state);
+			  count = wcrtomb (cbuf, *arg, &state);
 #   else
-			  count = wctomb (buf, *arg);
+			  count = wctomb (cbuf, *arg);
 #   endif
 			  if (count <= 0)
 			    /* Inconsistency.  */
 			    abort ();
 			  ENSURE_ALLOCATION (xsum (length, count));
-			  memcpy (result + length, buf, count);
+			  memcpy (result + length, cbuf, count);
 			  length += count;
 			  arg++;
 			}
-- 
2.30.2