From 7eb4ac5b72b00a726562c3361305f973ea262c22 Mon Sep 17 00:00:00 2001 From: Christian Wiese Date: Thu, 25 Apr 2013 16:45:59 +0200 Subject: [PATCH] nut: add patch to fix scan_usb to remove trailing spaces from output strings see: https://github.com/networkupstools/nut/issues/26 --- ...0100-scan_usb-remove-trailing-spaces.patch | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 monitor/nut/nut-2.6.5-0100-scan_usb-remove-trailing-spaces.patch diff --git a/monitor/nut/nut-2.6.5-0100-scan_usb-remove-trailing-spaces.patch b/monitor/nut/nut-2.6.5-0100-scan_usb-remove-trailing-spaces.patch new file mode 100644 index 000000000..dde09ca2b --- /dev/null +++ b/monitor/nut/nut-2.6.5-0100-scan_usb-remove-trailing-spaces.patch @@ -0,0 +1,62 @@ +From 0b10420084b93572b1fec091d1ca4948c6cbba62 Mon Sep 17 00:00:00 2001 +From: Christian Wiese +Date: Thu, 25 Apr 2013 15:10:00 +0200 +Subject: [PATCH] nut-scanner: fix scan_usb to remove trailing spaces from + output strings + +This patch uses rtrim() from libcommon to remove trailing spaces from +serialnumber, device_name and vendor_name. + +see: https://github.com/networkupstools/nut/issues/26 +--- + tools/nut-scanner/Makefile.am | 2 +- + tools/nut-scanner/scan_usb.c | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/tools/nut-scanner/Makefile.am b/tools/nut-scanner/Makefile.am +index d4066d2..87fb6ed 100644 +--- a/tools/nut-scanner/Makefile.am ++++ b/tools/nut-scanner/Makefile.am +@@ -17,7 +17,7 @@ libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include $(LIBLTDL + + nut_scanner_SOURCES = nut-scanner.c + nut_scanner_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include +-nut_scanner_LDADD = libnutscan.la ++nut_scanner_LDADD = libnutscan.la ../../common/libcommon.la + + if WITH_SSL + libnutscan_la_CFLAGS += $(LIBSSL_CFLAGS) +diff --git a/tools/nut-scanner/scan_usb.c b/tools/nut-scanner/scan_usb.c +index d6e1e4e..1a4bb24 100644 +--- a/tools/nut-scanner/scan_usb.c ++++ b/tools/nut-scanner/scan_usb.c +@@ -177,7 +177,7 @@ nutscan_device_t * nutscan_scan_usb() + dev->descriptor.iSerialNumber, + string, sizeof(string)); + if (ret > 0) { +- serialnumber = strdup(string); ++ serialnumber = strdup(rtrim(string, ' ')); + } + } + /* get product name */ +@@ -186,7 +186,7 @@ nutscan_device_t * nutscan_scan_usb() + dev->descriptor.iProduct, + string, sizeof(string)); + if (ret > 0) { +- device_name = strdup(string); ++ device_name = strdup(rtrim(string, ' ')); + } + } + +@@ -196,7 +196,7 @@ nutscan_device_t * nutscan_scan_usb() + dev->descriptor.iManufacturer, + string, sizeof(string)); + if (ret > 0) { +- vendor_name = strdup(string); ++ vendor_name = strdup(rtrim(string, ' ')); + } + } + +-- +1.7.10.2 +