[Spice-devel] [PATCH spice-gtk v5 3/5] Avoid warning about snprintf on non-Linux platforms

Christophe Fergeau cfergeau at redhat.com
Tue May 30 13:37:16 UTC 2017


On Tue, May 30, 2017 at 03:03:17PM +0200, Christophe de Dinechin wrote:
> 
> > On 30 May 2017, at 14:57, Frediano Ziglio <fziglio at redhat.com> wrote:
> > 
> >> 
> >> From: Christophe de Dinechin <dinechin at redhat.com>
> >> 
> >> Without #include <stdio.h>, calls to snprintf in the file
> >> cause a warning. The file <unistd.h> is left aside on purpose,
> >> since src/usbutil.c may be compiled on Windows where this
> >> file does not exist.
> >> 
> >> Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
> >> ---
> >> src/usbutil.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >> 
> >> diff --git a/src/usbutil.c b/src/usbutil.c
> >> index b68a2e1..e96ab11 100644
> >> --- a/src/usbutil.c
> >> +++ b/src/usbutil.c
> >> @@ -27,8 +27,8 @@
> >> #include <stdlib.h>
> >> 
> >> #ifdef USE_USBREDIR
> >> -#ifdef __linux__
> >> #include <stdio.h>
> >> +#ifdef __linux__
> >> #include <unistd.h>
> >> #include <sys/sysmacros.h>
> >> #ifndef major /* major and minor macros were moved to sys/sysmacros.h from
> >> sys/types.h */
> > 
> > For me is still ack, there was a comment from Christophe Fergeau.
> 
> What are the benefits of g_snprintf vs. snprintf? Both have variations in the output value, and both appear to do exactly the same thing.

Oh I did not follow up on g_snprintf because it was not really
important, and there was a consensus against it.
Main benefit is that you know it's there and has a given behaviour, you
don't need more headers besides glib, ... But yeah, these are minor
benefits.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170530/eb858316/attachment.sig>


More information about the Spice-devel mailing list