From c9f4963ca6c455713ae57ac272b20d7342b86a65 Mon Sep 17 00:00:00 2001 From: wangqia Date: Thu, 11 May 2023 13:50:36 +0800 Subject: [PATCH 1/2] fix help parameter return value failed --- ...x-help-parameter-return-value-failed.patch | 55 +++++++++++++++++++ usbutils.spec | 6 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 0001-fix-help-parameter-return-value-failed.patch diff --git a/0001-fix-help-parameter-return-value-failed.patch b/0001-fix-help-parameter-return-value-failed.patch new file mode 100644 index 0000000..cf73cc5 --- /dev/null +++ b/0001-fix-help-parameter-return-value-failed.patch @@ -0,0 +1,55 @@ +From 02b215c32a935da32677511cba4b2d3646ae8249 Mon Sep 17 00:00:00 2001 +From: wangqia +Date: Thu, 11 May 2023 11:46:13 +0800 +Subject: [PATCH] fix help error + +--- + lsusb.c | 25 +++++++++++++++++++++++-- + 1 file changed, 23 insertions(+), 2 deletions(-) + +diff --git a/lsusb.c b/lsusb.c +index 80503e4..db71e3b 100644 +--- a/lsusb.c ++++ b/lsusb.c +@@ -3821,7 +3821,7 @@ int main(int argc, char *argv[]) + break; + } + } +- if (err || argc > optind || help) { ++ if (err || argc > optind) { + fprintf(stderr, "Usage: lsusb [options]...\n" + "List USB devices\n" + " -v, --verbose\n" +@@ -3843,7 +3843,28 @@ int main(int argc, char *argv[]) + ); + return EXIT_FAILURE; + } +- ++ if (help) { ++ fprintf(stderr, "Usage: lsusb [options]...\n" ++ "List USB devices\n" ++ " -v, --verbose\n" ++ " Increase verbosity (show descriptors)\n" ++ " -s [[bus]:][devnum]\n" ++ " Show only devices with specified device and/or\n" ++ " bus numbers (in decimal)\n" ++ " -d vendor:[product]\n" ++ " Show only devices with the specified vendor and\n" ++ " product ID numbers (in hexadecimal)\n" ++ " -D device\n" ++ " Selects which device lsusb will examine\n" ++ " -t, --tree\n" ++ " Dump the physical USB device hierarchy as a tree\n" ++ " -V, --version\n" ++ " Show version of program\n" ++ " -h, --help\n" ++ " Show usage and help\n" ++ ); ++ return EXIT_SUCCESS; ++ } + + /* by default, print names as well as numbers */ + if (names_init() < 0) +-- +2.27.0 + diff --git a/usbutils.spec b/usbutils.spec index c49e2a7..575d855 100644 --- a/usbutils.spec +++ b/usbutils.spec @@ -1,6 +1,6 @@ Name: usbutils Version: 012 -Release: 5 +Release: 6 Summary: Linux utilities for USB device License: GPLv2+ URL: http://www.linux-usb.org/ @@ -11,6 +11,7 @@ Source2: GPL-3.0.txt BuildRequires: libusbx-devel systemd-devel gcc libtool Patch1: 0001-usbmisc-initialize-string-buffer-before-reading-from.patch +Patch2: 0001-fix-help-parameter-return-value-failed.patch Requires: hwdata @@ -47,6 +48,9 @@ install -D -m 644 %{SOURCE2} %{buildroot}%{_defaultlicensedir}/%{name}/GPL-3.0.t %{_mandir}/*/* %changelog +* Thu May 11 2023 wangqia - 012-6 +- fix help parameter return value failed + * Tue Sep 28 2021 Wenchao Hao - 012-5 - Nothing but to sync master and LTS branch -- Gitee From 3140429535c4a52f5f02f1161421e486a4ce3ea3 Mon Sep 17 00:00:00 2001 From: ut004527 Date: Thu, 26 Oct 2023 11:07:22 +0800 Subject: [PATCH 2/2] Fix 'lsusb -h' returns an error --- ...x-help-parameter-return-value-failed.patch | 55 ------------------- 0002-lsusb-h-returns-an-error.patch | 28 ++++++++++ 0003-lsusb-h-fixups.patch | 31 +++++++++++ usbutils.spec | 7 ++- 4 files changed, 63 insertions(+), 58 deletions(-) delete mode 100644 0001-fix-help-parameter-return-value-failed.patch create mode 100644 0002-lsusb-h-returns-an-error.patch create mode 100644 0003-lsusb-h-fixups.patch diff --git a/0001-fix-help-parameter-return-value-failed.patch b/0001-fix-help-parameter-return-value-failed.patch deleted file mode 100644 index cf73cc5..0000000 --- a/0001-fix-help-parameter-return-value-failed.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 02b215c32a935da32677511cba4b2d3646ae8249 Mon Sep 17 00:00:00 2001 -From: wangqia -Date: Thu, 11 May 2023 11:46:13 +0800 -Subject: [PATCH] fix help error - ---- - lsusb.c | 25 +++++++++++++++++++++++-- - 1 file changed, 23 insertions(+), 2 deletions(-) - -diff --git a/lsusb.c b/lsusb.c -index 80503e4..db71e3b 100644 ---- a/lsusb.c -+++ b/lsusb.c -@@ -3821,7 +3821,7 @@ int main(int argc, char *argv[]) - break; - } - } -- if (err || argc > optind || help) { -+ if (err || argc > optind) { - fprintf(stderr, "Usage: lsusb [options]...\n" - "List USB devices\n" - " -v, --verbose\n" -@@ -3843,7 +3843,28 @@ int main(int argc, char *argv[]) - ); - return EXIT_FAILURE; - } -- -+ if (help) { -+ fprintf(stderr, "Usage: lsusb [options]...\n" -+ "List USB devices\n" -+ " -v, --verbose\n" -+ " Increase verbosity (show descriptors)\n" -+ " -s [[bus]:][devnum]\n" -+ " Show only devices with specified device and/or\n" -+ " bus numbers (in decimal)\n" -+ " -d vendor:[product]\n" -+ " Show only devices with the specified vendor and\n" -+ " product ID numbers (in hexadecimal)\n" -+ " -D device\n" -+ " Selects which device lsusb will examine\n" -+ " -t, --tree\n" -+ " Dump the physical USB device hierarchy as a tree\n" -+ " -V, --version\n" -+ " Show version of program\n" -+ " -h, --help\n" -+ " Show usage and help\n" -+ ); -+ return EXIT_SUCCESS; -+ } - - /* by default, print names as well as numbers */ - if (names_init() < 0) --- -2.27.0 - diff --git a/0002-lsusb-h-returns-an-error.patch b/0002-lsusb-h-returns-an-error.patch new file mode 100644 index 0000000..e80f19e --- /dev/null +++ b/0002-lsusb-h-returns-an-error.patch @@ -0,0 +1,28 @@ +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..78299ad --- /dev/null +++ b/0003-lsusb-h-fixups.patch @@ -0,0 +1,31 @@ +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 575d855..235b29b 100644 --- a/usbutils.spec +++ b/usbutils.spec @@ -11,7 +11,8 @@ Source2: GPL-3.0.txt BuildRequires: libusbx-devel systemd-devel gcc libtool Patch1: 0001-usbmisc-initialize-string-buffer-before-reading-from.patch -Patch2: 0001-fix-help-parameter-return-value-failed.patch +Patch2: 0002-lsusb-h-returns-an-error.patch +patch3: 0003-lsusb-h-fixups.patch Requires: hwdata @@ -48,8 +49,8 @@ install -D -m 644 %{SOURCE2} %{buildroot}%{_defaultlicensedir}/%{name}/GPL-3.0.t %{_mandir}/*/* %changelog -* Thu May 11 2023 wangqia - 012-6 -- fix help parameter return value failed +* Thu Oct 26 2023 wangqia - 012-6 +- Fix 'lsusb -h' returns an error * Tue Sep 28 2021 Wenchao Hao - 012-5 - Nothing but to sync master and LTS branch -- Gitee