提交 0c618145 编写于 作者: E Eric Curtin 提交者: Greg Kroah-Hartman

tools: usbip: detach: avoid calling strlen() at each iteration

Instead of calling strlen on every iteration of the for loop, just call it
once and cache the result in a temporary local variable which will be used
in the for loop instead.
Signed-off-by: NEric Curtin <ericcurtin17@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 1f93e4a9
......@@ -47,7 +47,9 @@ static int detach_port(char *port)
uint8_t portnum;
char path[PATH_MAX+1];
for (unsigned int i = 0; i < strlen(port); i++)
unsigned int port_len = strlen(port);
for (unsigned int i = 0; i < port_len; i++)
if (!isdigit(port[i])) {
err("invalid port %s", port);
return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册