From 8d2996f519277001777d07bd61c9cdab77a5c334 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Fri, 24 Nov 2023 07:52:06 -0800 Subject: [PATCH] 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 PR: 275293 Upstream commit: 4aeb199eb Upstream Pull Request: https://github.com/networkupstools/nut/pull/2198/ --- sysutils/nut/Makefile | 2 +- sysutils/nut/files/patch-drivers_libusb1.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 sysutils/nut/files/patch-drivers_libusb1.c diff --git a/sysutils/nut/Makefile b/sysutils/nut/Makefile index a22dd514509bb..d179892a49e15 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 0000000000000..8e778ecf87075 --- /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);