Skip to contentSkip to conversation

is just a wrong function name of libusb_get_port_number? request for a review of the bug fix

PATCH bauerchen(陈蒙蒙) 2 participants 5 messages Apr 2, 2020 – Apr 3, 2020

lore
Share & tools
lore
#0 lore raw

From 6bfb3087866606ed36a21e7bd05f0674e6a97158 Mon Sep 17 00:00:00 2001
From: Bauerchen <[email protected]>
Date: Thu, 2 Apr 2020 19:19:00 +0800
Subject: [PATCH] Fix:fix the wrong function name of libusb_get_port_number

[desc]:
libusb_get_port_numbers is called in function usb_host_get_port, and qemu crashed with:
symbol lookup error: undefined symbol: libusb_get_port_numbers I check /lib64/libusb-1.0.so.0 and output is libusb_get_port_number, I change it to libusb_get_port_number, crash problem is gone; so is it just a function name bug?

---
 hw/usb/host-libusb.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/host-libusb.c +0 -0
index 2ac7a93..713db8d 100644
@@ -285,7 +285,7 @@ static int usb_host_get_port(libusb_device *dev, char *port, size_t len)

     int rc, i;

 #if LIBUSB_API_VERSION >= 0x01000102
-    rc = libusb_get_port_numbers(dev, path, 7);
+    rc = libusb_get_port_number(dev, path, 7); #else
     rc = libusb_get_port_path(ctx, dev, path, 7); #endif
--
1.8.3.1

-------------
bauerchen

#1 lore raw
Quoted 24 lines · bauerchen(陈蒙蒙)

From 6bfb3087866606ed36a21e7bd05f0674e6a97158 Mon Sep 17 00:00:00 2001
From: Bauerchen <[email protected]>
Date: Thu, 2 Apr 2020 19:19:00 +0800
Subject: [PATCH] Fix:fix the wrong function name of libusb_get_port_number

[desc]:
libusb_get_port_numbers is called in function usb_host_get_port, and qemu crashed with:
symbol lookup error: undefined symbol: libusb_get_port_numbers I check /lib64/libusb-1.0.so.0 and output is libusb_get_port_number, I change it to libusb_get_port_number, crash problem is gone; so is it just a function name bug?

---
 hw/usb/host-libusb.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/host-libusb.c +0 -0
index 2ac7a93..713db8d 100644
@@ -285,7 +285,7 @@ static int usb_host_get_port(libusb_device *dev, char *port, size_t len)
      int rc, i;
Quoted 4 lines


 #if LIBUSB_API_VERSION >= 0x01000102
-    rc = libusb_get_port_numbers(dev, path, 7);
+    rc = libusb_get_port_number(dev, path, 7);

Surely not that simple. libusb_get_port_number isn't a drop-in replacement for libusb_get_port_numbers. Also it was probably added later to libusb, so some LIBUSB_API_VERSION #ifdef will be needed so the one or the other will be used depending on the library version.

cheers,
Gerd

#2 lore raw

Re: Re: is just a wrong function name of libusb_get_port_number? request for a review of the bug fix(Internet mail)

thanks, but my libusbx version is libusbx-1.0.15-4.el7.x86_64 ,
I can find libusb_get_port_numbers function in libusb-1.0.so.0 but find libusb_get_port_number

[root@t]# strings /lib64/libusb-1.0.so.0 |grep libusb_get_port_number
libusb_get_port_number
[root@t]#

is my libusbx package problem?

________________________________
Bauer

From: kraxel<mailto:[email protected]>
Date: 2020-04-03 14:50
To: bauerchen(陈蒙蒙)<mailto:[email protected]>
CC: qemu-devel<mailto:[email protected]>; hdegoede<mailto:[email protected]>
Subject: Re: is just a wrong function name of libusb_get_port_number? request for a review of the bug fix(Internet mail)

Quoted 23 lines · bauerchen(陈蒙蒙)

From 6bfb3087866606ed36a21e7bd05f0674e6a97158 Mon Sep 17 00:00:00 2001
From: Bauerchen <[email protected]>
Date: Thu, 2 Apr 2020 19:19:00 +0800
Subject: [PATCH] Fix:fix the wrong function name of libusb_get_port_number

[desc]:
libusb_get_port_numbers is called in function usb_host_get_port, and qemu crashed with:
symbol lookup error: undefined symbol: libusb_get_port_numbers I check /lib64/libusb-1.0.so.0 and output is libusb_get_port_number, I change it to libusb_get_port_number, crash problem is gone; so is it just a function name bug?

---
 hw/usb/host-libusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/host-libusb.c +0 -0
index 2ac7a93..713db8d 100644

hw/usb/host-libusb.c static int usb_host_get_port(libusb_device *dev, char *port, size_t len) · line 288

Quoted 5 lines
hw/usb/host-libusb.c +1 -1
@@ -285,7 +285,7 @@ static int usb_host_get_port(libusb_device *dev, char *port, size_t len)
     int rc, i;
 
 #if LIBUSB_API_VERSION >= 0x01000102
-    rc = libusb_get_port_numbers(dev, path, 7);
+    rc = libusb_get_port_number(dev, path, 7);

Surely not that simple. libusb_get_port_number isn't a drop-in replacement for libusb_get_port_numbers. Also it was probably added later to libusb, so some LIBUSB_API_VERSION #ifdef will be needed so the one or the other will be used depending on the library version.

cheers,
Gerd

#3 lore raw

Re: is just a wrong function name of libusb_get_port_number? request for a review of the bug fix(Internet mail)

Quoted 6 lines · bauerchen(陈蒙蒙)

thanks, but my libusbx version is libusbx-1.0.15-4.el7.x86_64 ,
I can find libusb_get_port_numbers function in libusb-1.0.so.0 but find libusb_get_port_number

[root@t]# strings /lib64/libusb-1.0.so.0 |grep libusb_get_port_number
libusb_get_port_number
[root@t]#

kraxel@sirius ~# grep libusb_get_port_number /usr/include/libusb-1.0/libusb.h
uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len); LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)

So libusb_get_port_numbers replaces libusb_get_port_number, seems you have an old version which hasn't yet libusb_get_port_numbers.

On old version qemu should fallback to libusb_get_port_path, but maybe the version #ifdef is wrong so this doesn't work properly for some versions ...

According to my /usr/include/libusb-1.0/libusb.h libusb >= 1.0.16 declares LIBUSB_API_VERSION >= 0x01000102, so that looks ok. Hmm, not sure what is going on here. In any case the libusb_get_port_path fallback code path should work.

cheers,
Gerd

#4 lore raw

Re: Re: is just a wrong function name of libusb_get_port_number? request for a review of the bug fix(Internet mail)

OK,thanks, I will try .

________________________________
Bauer

From: kraxel<mailto:[email protected]>
Date: 2020-04-03 16:19
To: bauerchen(陈蒙蒙)<mailto:[email protected]>
CC: qemu-devel<mailto:[email protected]>; hdegoede<mailto:[email protected]>
Subject: Re: is just a wrong function name of libusb_get_port_number? request for a review of the bug fix(Internet mail)

Quoted 6 lines · bauerchen(陈蒙蒙)

thanks, but my libusbx version is libusbx-1.0.15-4.el7.x86_64 ,
I can find libusb_get_port_numbers function in libusb-1.0.so.0 but find libusb_get_port_number

[root@t]# strings /lib64/libusb-1.0.so.0 |grep libusb_get_port_number
libusb_get_port_number
[root@t]#

kraxel@sirius ~# grep libusb_get_port_number /usr/include/libusb-1.0/libusb.h
uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len); LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)

So libusb_get_port_numbers replaces libusb_get_port_number, seems you have an old version which hasn't yet libusb_get_port_numbers.

On old version qemu should fallback to libusb_get_port_path, but maybe the version #ifdef is wrong so this doesn't work properly for some versions ...

According to my /usr/include/libusb-1.0/libusb.h libusb >= 1.0.16 declares LIBUSB_API_VERSION >= 0x01000102, so that looks ok. Hmm, not sure what is going on here. In any case the libusb_get_port_path fallback code path should work.

cheers,
Gerd