[Piglit] [PATCH] util: Do not define asprintf for MinGW.

Brian Paul brianp at vmware.com
Fri Dec 20 15:33:37 PST 2013


On 12/19/2013 05:39 PM, Vinson Lee wrote:
> MinGW provides asprintf in stdio.h.
>
> Bugzilla: https://urldefense.proofpoint.com/v1/url?u=https://bugs.freedesktop.org/show_bug.cgi?id%3D72556&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=lGQMzzTgII0I7jefp2FHq7WtZ%2BTLs8wadB%2BiIj9xpBY%3D%0A&m=OrHWJ9GIP9EIrk176XOZS9JGrUT%2B7HISc4lSVkuMhGg%3D%0A&s=a79ce4cd2796d1b58a32d5ede65eeb342a943b935d6dded8915662b82dab1699
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>   tests/util/piglit-util.c | 16 ++--------------
>   1 file changed, 2 insertions(+), 14 deletions(-)
>
> diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
> index 1c7f118..fbc8723 100644
> --- a/tests/util/piglit-util.c
> +++ b/tests/util/piglit-util.c
> @@ -56,14 +56,7 @@
>   #include "piglit-util.h"
>
>
> -#if defined(_WIN32)
> -
> -/* Some versions of MinGW are missing _vscprintf's declaration, although they
> - * still provide the symbol in the import library.
> - */
> -#ifdef __MINGW32__
> -_CRTIMP int _vscprintf(const char *format, va_list argptr);
> -#endif
> +#if defined(_MSC_VER)
>
>   int asprintf(char **strp, const char *fmt, ...)
>   {
> @@ -76,15 +69,10 @@ int asprintf(char **strp, const char *fmt, ...)
>
>   	va_copy(args_copy, args);
>
> -#ifdef _WIN32
>   	/* We need to use _vcsprintf to calculate the length as vsnprintf returns -1
>   	 * if the number of characters to write is greater than count.
>   	 */
>   	length = _vscprintf(fmt, args_copy);
> -#else
> -	char dummy;
> -	length = vsnprintf(&dummy, sizeof dummy, fmt, args_copy);
> -#endif
>
>   	va_end(args_copy);
>
> @@ -103,7 +91,7 @@ int asprintf(char **strp, const char *fmt, ...)
>   	return length;
>   }
>
> -#endif /* _WIN32 */
> +#endif /* _MSC_VER */
>
>   /**
>    * \brief Split \a string into an array of strings.
>

Looks OK, but I'll be on the alert for any regressions here.

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the Piglit mailing list