[Spice-devel] [PATCH spice-gtk 10/34] win-usb-dev: fix snprintf warnings

Christophe Fergeau cfergeau at redhat.com
Mon Jan 7 13:37:20 UTC 2019


On Mon, Jan 07, 2019 at 12:00:39PM +0400, marcandre.lureau at redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>
> 
> [1/14] Compiling C object 'src/25a6634@@spice-client-glib-2.0 at sha/win-usb-dev.c.obj'.
> ../src/win-usb-dev.c: In function 'get_usb_dev_info':
> ../src/win-usb-dev.c:376:5: warning: implicit declaration of function 'snprintf' [-Wimplicit-function-declaration]
>      snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", udevinfo->class);
>      ^~~~~~~~
> ../src/win-usb-dev.c:376:5: warning: incompatible implicit declaration of built-in function 'snprintf'
> ../src/win-usb-dev.c:376:5: note: include '<stdio.h>' or provide a declaration of 'snprintf'
> ../src/win-usb-dev.c:31:1:
> +#include <stdio.h>
> 
> ../src/win-usb-dev.c:376:5:
>      snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", udevinfo->class);
>      ^~~~~~~~

A bit unexpected as this is a fallout from the #include <gtk.h> ->
#include <gio.h> change, but regardless of that,

Reviewed-by: Christophe Fergeau <cfergeau at redhat.com>

> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> ---
>  src/win-usb-dev.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
> index 9a130a3..327976d 100644
> --- a/src/win-usb-dev.c
> +++ b/src/win-usb-dev.c
> @@ -373,11 +373,11 @@ static gboolean get_usb_dev_info(libusb_device *dev, GUdevDeviceInfo *udevinfo)
>      udevinfo->class = desc.bDeviceClass;
>      udevinfo->vid   = desc.idVendor;
>      udevinfo->pid   = desc.idProduct;
> -    snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", udevinfo->class);
> -    snprintf(udevinfo->sbus,   sizeof(udevinfo->sbus),   "%d", udevinfo->bus);
> -    snprintf(udevinfo->saddr,  sizeof(udevinfo->saddr),  "%d", udevinfo->addr);
> -    snprintf(udevinfo->svid,   sizeof(udevinfo->svid),   "%d", udevinfo->vid);
> -    snprintf(udevinfo->spid,   sizeof(udevinfo->spid),   "%d", udevinfo->pid);
> +    g_snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", udevinfo->class);
> +    g_snprintf(udevinfo->sbus,   sizeof(udevinfo->sbus),   "%d", udevinfo->bus);
> +    g_snprintf(udevinfo->saddr,  sizeof(udevinfo->saddr),  "%d", udevinfo->addr);
> +    g_snprintf(udevinfo->svid,   sizeof(udevinfo->svid),   "%d", udevinfo->vid);
> +    g_snprintf(udevinfo->spid,   sizeof(udevinfo->spid),   "%d", udevinfo->pid);
>      return TRUE;
>  }
>  
> -- 
> 2.20.1.2.gb21ebb671b
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190107/1634d115/attachment.sig>


More information about the Spice-devel mailing list