From: Vadym Hrynchyshyn <vadimgrn@gmail.com>
To: valentina.manea.m@gmail.com, shuah@kernel.org, i@zenithal.me,
linux-usb@vger.kernel.org
Cc: Vadym Hrynchyshyn <vadimgrn@gmail.com>
Subject: [PATCH v2 3/3] usbipd: use usbip_to_int to simplify usbip_setup_port_number implementation
Date: Fri, 23 May 2025 12:07:25 +0300 [thread overview]
Message-ID: <20250523090802.17987-4-vadimgrn@gmail.com> (raw)
In-Reply-To: <20250523090802.17987-1-vadimgrn@gmail.com>
usbip_to_int function is used for handling arguments of options
--tcp-keepidle,--tcp-keepcnt,--tcp-keepintvl. It is now called
from usbip_setup_port_number to handle tcp port number.
This simplifies its implementation.
Signed-off-by: Vadym Hrynchyshyn <vadimgrn@gmail.com>
---
tools/usb/usbip/src/usbip_network.c | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/tools/usb/usbip/src/usbip_network.c b/tools/usb/usbip/src/usbip_network.c
index 15787044a7c9..26559a11e648 100644
--- a/tools/usb/usbip/src/usbip_network.c
+++ b/tools/usb/usbip/src/usbip_network.c
@@ -26,28 +26,13 @@ char *usbip_port_string = "3240";
void usbip_setup_port_number(char *arg)
{
dbg("parsing port arg '%s'", arg);
- char *end;
- unsigned long int port = strtoul(arg, &end, 10);
-
- if (end == arg) {
- err("port: could not parse '%s' as a decimal integer", arg);
- return;
- }
+ int port = usbip_to_int("port", arg, UINT16_MAX);
- if (*end != '\0') {
- err("port: garbage at end of '%s'", arg);
- return;
+ if (port > 0) {
+ usbip_port = port;
+ usbip_port_string = arg;
+ info("using port %d (\"%s\")", usbip_port, usbip_port_string);
}
-
- if (port > UINT16_MAX) {
- err("port: %s too high (max=%d)",
- arg, UINT16_MAX);
- return;
- }
-
- usbip_port = port;
- usbip_port_string = arg;
- info("using port %d (\"%s\")", usbip_port, usbip_port_string);
}
int usbip_to_int(const char *name, const char *val, int maxval)
--
2.43.0
next prev parent reply other threads:[~2025-05-23 9:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 9:07 [PATCH v2 0/3] usbipd: enable tcp keepalive and set its options for accepted connection Vadym Hrynchyshyn
2025-05-23 9:07 ` [PATCH v2 1/3] usbipd: enable SO_KEEPALIVE socket option " Vadym Hrynchyshyn
2025-05-23 9:07 ` [PATCH v2 2/3] usbipd: add long options to set TCP_KEEPIDLE/TCP_KEEPCNT/TCP_KEEPINTVL socket options Vadym Hrynchyshyn
2025-05-23 9:07 ` Vadym Hrynchyshyn [this message]
2025-05-23 9:17 ` [PATCH v2 0/3] usbipd: enable tcp keepalive and set its options for accepted connection 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=20250523090802.17987-4-vadimgrn@gmail.com \
--to=vadimgrn@gmail.com \
--cc=i@zenithal.me \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.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