[Qemu-devel] [PATCH] Fix libusb-1.0.22 deprecated libusb_set_debug with libusb_set_option

John Thomson posted 1 patch 5 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180405132046.4968-1-git@johnthomson.fastmail.com.au
Test checkpatch passed
Test docker-build@min-glib passed
Test docker-mingw@fedora passed
Test s390x passed
hw/usb/host-libusb.c | 4 ++++
1 file changed, 4 insertions(+)
[Qemu-devel] [PATCH] Fix libusb-1.0.22 deprecated libusb_set_debug with libusb_set_option
Posted by John Thomson 5 years, 11 months ago
libusb-1.0.22 marked libusb_set_debug deprecated
it is replaced with
libusb_set_option(libusb_context, LIBUSB_OPTION_LOG_LEVEL, libusb_log_level);

details here: https://github.com/libusb/libusb/commit/539f22e2fd916558d11ab9a66f10f461c5593168

Warning here:

  CC      hw/usb/host-libusb.o
/builds/xen/src/qemu-xen/hw/usb/host-libusb.c: In function 'usb_host_init':
/builds/xen/src/qemu-xen/hw/usb/host-libusb.c:250:5: error: 'libusb_set_debug' is deprecated: Use libusb_set_option instead [-Werror=deprecated-declarations]
     libusb_set_debug(ctx, loglevel);
     ^~~~~~~~~~~~~~~~
In file included from /builds/xen/src/qemu-xen/hw/usb/host-libusb.c:40:0:
/usr/include/libusb-1.0/libusb.h:1300:18: note: declared here
 void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
                  ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [/builds/xen/src/qemu-xen/rules.mak:66: hw/usb/host-libusb.o] Error 1
make: Leaving directory '/builds/xen/src/xen/tools/qemu-xen-build'

Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au>
---
 hw/usb/host-libusb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 1b0be071cc..dc0a8fe295 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -247,7 +247,11 @@ static int usb_host_init(void)
     if (rc != 0) {
         return -1;
     }
+#if LIBUSB_API_VERSION >= 0x01000106
+    libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, loglevel);
+#else
     libusb_set_debug(ctx, loglevel);
+#endif
 #ifdef CONFIG_WIN32
     /* FIXME: add support for Windows. */
 #else
-- 
2.16.3


Re: [Qemu-devel] [PATCH] Fix libusb-1.0.22 deprecated libusb_set_debug with libusb_set_option
Posted by Gerd Hoffmann 5 years, 11 months ago
On Thu, Apr 05, 2018 at 11:20:46PM +1000, John Thomson wrote:
> libusb-1.0.22 marked libusb_set_debug deprecated
> it is replaced with
> libusb_set_option(libusb_context, LIBUSB_OPTION_LOG_LEVEL, libusb_log_level);
> 
> details here: https://github.com/libusb/libusb/commit/539f22e2fd916558d11ab9a66f10f461c5593168
> 
> Warning here:
> 
>   CC      hw/usb/host-libusb.o
> /builds/xen/src/qemu-xen/hw/usb/host-libusb.c: In function 'usb_host_init':
> /builds/xen/src/qemu-xen/hw/usb/host-libusb.c:250:5: error: 'libusb_set_debug' is deprecated: Use libusb_set_option instead [-Werror=deprecated-declarations]
>      libusb_set_debug(ctx, loglevel);
>      ^~~~~~~~~~~~~~~~
> In file included from /builds/xen/src/qemu-xen/hw/usb/host-libusb.c:40:0:
> /usr/include/libusb-1.0/libusb.h:1300:18: note: declared here
>  void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
>                   ^~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make: *** [/builds/xen/src/qemu-xen/rules.mak:66: hw/usb/host-libusb.o] Error 1
> make: Leaving directory '/builds/xen/src/xen/tools/qemu-xen-build'

Added to usb patch queue.

thanks,
  Gerd