From: Jason Colapietro <jasoncola1@gmail.com>
To: Valentina Manea <valentina.manea.m@gmail.com>,
Shuah Khan <shuah@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>
Cc: Hongren Zheng <i@zenithal.me>, Greg KH <greg@kroah.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order
Date: Wed, 12 Aug 2026 02:39:10 -0400 [thread overview]
Message-ID: <20260812063910.31293-2-jasoncola1@gmail.com> (raw)
In-Reply-To: <20260812063910.31293-1-jasoncola1@gmail.com>
usbip_list() acts on -r, -l and -d as soon as getopt_long() returns them,
so any option parsed afterwards is never seen. -p therefore only takes
effect when it precedes the mode selector: "usbip list -p -r <host>" is
parsable while "usbip list -r <host> -p" is not, and -l and -d behave the
same way. Nothing in the usage text suggests the order matters.
Record the requested mode during the option loop and run it once parsing
has finished, so -p applies wherever it appears on the command line. When
several mode selectors are given the first one still wins, as before.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jason Colapietro <jasoncola1@gmail.com>
---
tools/usb/usbip/src/usbip_list.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
index b9d60b87e..632a968a0 100644
--- a/tools/usb/usbip/src/usbip_list.c
+++ b/tools/usb/usbip/src/usbip_list.c
@@ -343,6 +343,8 @@ int usbip_list(int argc, char *argv[])
};
bool parsable = false;
+ char *remote_host = NULL;
+ int action = 0;
int opt;
int ret = -1;
@@ -360,19 +362,36 @@ int usbip_list(int argc, char *argv[])
parsable = true;
break;
case 'r':
- ret = list_exported_devices(optarg, parsable);
- goto out;
+ if (!action) {
+ action = opt;
+ remote_host = optarg;
+ }
+ break;
case 'l':
- ret = list_devices(parsable);
- goto out;
case 'd':
- ret = list_gadget_devices(parsable);
- goto out;
+ if (!action)
+ action = opt;
+ break;
default:
goto err_out;
}
}
+ switch (action) {
+ case 'r':
+ ret = list_exported_devices(remote_host, parsable);
+ break;
+ case 'l':
+ ret = list_devices(parsable);
+ break;
+ case 'd':
+ ret = list_gadget_devices(parsable);
+ break;
+ default:
+ goto err_out;
+ }
+ goto out;
+
err_out:
usbip_list_usage();
out:
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-08-12 6:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 6:39 [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Jason Colapietro
2026-08-12 6:39 ` Jason Colapietro [this message]
2026-08-12 7:24 ` [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order Greg KH
2026-08-12 7:22 ` [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Greg KH
2026-08-12 7:23 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260812063910.31293-2-jasoncola1@gmail.com \
--to=jasoncola1@gmail.com \
--cc=greg@kroah.com \
--cc=i@zenithal.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=valentina.manea.m@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox