From d98f7442215204743af54f6450d5947de3b0188b Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sun, 25 Jun 2023 20:19:16 +0800 Subject: [PATCH] Fix lsusb -h returns an error --- 0002-lsusb-h-returns-an-error.patch | 29 ++++++++++++++++++++++++++ 0003-lsusb-h-fixups.patch | 32 +++++++++++++++++++++++++++++ usbutils.spec | 7 ++++++- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 0002-lsusb-h-returns-an-error.patch create mode 100644 0003-lsusb-h-fixups.patch diff --git a/0002-lsusb-h-returns-an-error.patch b/0002-lsusb-h-returns-an-error.patch new file mode 100644 index 0000000..ac5eb5f --- /dev/null +++ b/0002-lsusb-h-returns-an-error.patch @@ -0,0 +1,29 @@ +From 882a852d06321968a420fda46aef0c52b8220eae Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Sun, 25 Jun 2023 09:04:23 +0200 +Subject: [PATCH 1/2] lsusb -h returns an error + +Fix up the issue where 'lsusb -h' will return an error to the shell, it +succeeded, so return 0 instead. + +Signed-off-by: Greg Kroah-Hartman +--- + lsusb.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lsusb.c b/lsusb.c +index 90825c5..1d4c5fd 100644 +--- a/lsusb.c ++++ b/lsusb.c +@@ -3797,7 +3797,7 @@ int main(int argc, char *argv[]) + " -h, --help\n" + " Show usage and help\n" + ); +- return EXIT_FAILURE; ++ return 0; + } + + +-- +2.23.0 + diff --git a/0003-lsusb-h-fixups.patch b/0003-lsusb-h-fixups.patch new file mode 100644 index 0000000..0722396 --- /dev/null +++ b/0003-lsusb-h-fixups.patch @@ -0,0 +1,32 @@ +From 09af21c154cf7b239f39644d1245d2191abf2c76 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Sun, 25 Jun 2023 09:47:50 +0200 +Subject: [PATCH 2/2] lsusb -h fixups + +Previous change to make `lsusb -h` not return an error forgot to account +that the help is also printed when an invalid option is used. + +Signed-off-by: Greg Kroah-Hartman +--- + lsusb.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/lsusb.c b/lsusb.c +index 3cb61b7..7fa1555 100644 +--- a/lsusb.c ++++ b/lsusb.c +@@ -3799,7 +3799,10 @@ int main(int argc, char *argv[]) + " -h, --help\n" + " Show usage and help\n" + ); +- return 0; ++ if (help && !err) ++ return 0; ++ else ++ return EXIT_FAILURE; + } + + +-- +2.23.0 + diff --git a/usbutils.spec b/usbutils.spec index e2ab4a3..5774ddd 100644 --- a/usbutils.spec +++ b/usbutils.spec @@ -1,6 +1,6 @@ Name: usbutils Version: 014 -Release: 2 +Release: 3 Summary: Linux utilities for USB device License: GPLv2+ URL: http://www.linux-usb.org/ @@ -10,6 +10,8 @@ Source1: GPL-2.0.txt Source2: GPL-3.0.txt Patch1: 0001-Fix-an-runtime-error-reported-by-undefind-sanitizer.patch +Patch2: 0002-lsusb-h-returns-an-error.patch +patch3: 0003-lsusb-h-fixups.patch BuildRequires: libusbx-devel systemd-devel gcc autoconf automake libtool Requires: hwdata @@ -46,6 +48,9 @@ install -D -m 644 %{SOURCE2} %{buildroot}%{_defaultlicensedir}/%{name}/GPL-3.0.t %{_mandir}/*/* %changelog +* Sun Jun 25 2023 zhanghongtao - 014-3 +- Fix 'lsusb -h' returns an error + * Tue Nov 1 2022 lihaoxiang - 014-2 - fix an runtime error reported by undefined sanitizer -- Gitee