aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2023-11-24 15:52:06 +0000
committerCy Schubert <cy@FreeBSD.org>2023-11-24 16:03:39 +0000
commit8d2996f519277001777d07bd61c9cdab77a5c334 (patch)
treedae6fc631db4e4f1f1292176fed64f0fe2ae35f8
parentf183414b25ed07d90461aa3064c39ca0162ad301 (diff)
sysutils/nut: Remove unnecessary validation for bus_num
The libusb_get_bus_number() function serves as a simple accessor for the bus number of the opaque device struct. Unlike libusb_get_port_number(), it does not have the ability to convey errors back to the caller, and a bus number of 0 is a valid value. Therefore, any validation around bus_num is redundant. This commit removes the unnecessary validation code related to bus_num. Signed-off-by: Xin LI <delphij@FreeBSD.org> PR: 275293 Upstream commit: 4aeb199eb Upstream Pull Request: https://github.com/networkupstools/nut/pull/2198/
-rw-r--r--sysutils/nut/Makefile2
-rw-r--r--sysutils/nut/files/patch-drivers_libusb1.c18
2 files changed, 19 insertions, 1 deletions
diff --git a/sysutils/nut/Makefile b/sysutils/nut/Makefile
index a22dd514509b..d179892a49e1 100644
--- a/sysutils/nut/Makefile
+++ b/sysutils/nut/Makefile
@@ -1,6 +1,6 @@
PORTNAME= nut
PORTVERSION= 2.8.1
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= sysutils
MASTER_SITES= http://www.networkupstools.org/source/${PORTVERSION:R}/
diff --git a/sysutils/nut/files/patch-drivers_libusb1.c b/sysutils/nut/files/patch-drivers_libusb1.c
new file mode 100644
index 000000000000..8e778ecf8707
--- /dev/null
+++ b/sysutils/nut/files/patch-drivers_libusb1.c
@@ -0,0 +1,18 @@
+--- drivers/libusb1.c.orig 2023-11-24 07:19:04.377537000 -0800
++++ drivers/libusb1.c 2023-11-24 07:20:06.065188000 -0800
+@@ -263,14 +263,7 @@
+ libusb_free_device_list(devlist, 1);
+ fatal_with_errno(EXIT_FAILURE, "Out of memory");
+ }
+- if (bus_num > 0) {
+- sprintf(curDevice->Bus, "%03d", bus_num);
+- } else {
+- upsdebugx(1, "%s: invalid libusb bus number %i",
+- __func__, bus_num);
+- free(curDevice->Bus);
+- curDevice->Bus = NULL;
+- }
++ sprintf(curDevice->Bus, "%03d", bus_num);
+
+ device_addr = libusb_get_device_address(device);
+ curDevice->Device = (char *)malloc(4);