[Top][All Lists]

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

Re: [PATCH] build: avoid printf format mismatch warnings

From: Joel E. Denny
Subject: Re: [PATCH] build: avoid printf format mismatch warnings
Date: Tue, 29 Sep 2009 14:12:29 -0400 (EDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

Hi Eric.

On Tue, 29 Sep 2009, Eric Blake wrote:

> For this to work on all platforms, you need the gnulib module fprintf-posix 
> (sadly, %zu is not completely portable yet).

Thanks for pointing that out.

While we're on the topic and I already have two experts watching this 
thread, is snprintf-posix helpful in order to use the following portably?

  length = snprintf (NULL, 0, format, args);
  str = malloc (length + 1);
  snprintf (str, length + 1, format, args);

The snprintf man page warns of portability problems here, but 
snprintf-posix only appears to test vsnprintf's functionality for this 
purpose by invoking gl_VSNPRINTF_ZEROSIZE_C99.  Is it just assumed 
snprintf and vsnprintf will be consistent in this respect?

Also, is there any single module that ensures portability of all *printf 
functions, or should I include every *printf-posix module individually in 
order to ensure consistent behavior?

If I should add bug-gnulib, let me know.

reply via email to

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