Skip to content

Commit

Permalink
sysutils/nut: Remove unnecessary validation for bus_num
Browse files Browse the repository at this point in the history
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:	networkupstools/nut#2198
  • Loading branch information
delphij authored and cschuber committed Nov 24, 2023
1 parent f183414 commit 8d2996f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 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}/

Expand Down
18 changes: 18 additions & 0 deletions 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);

0 comments on commit 8d2996f

Please sign in to comment.