public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* First kernel patch (optimization)
@ 2015-09-15 19:53 Eric Curtin
  2015-09-15 20:11 ` Felipe Balbi
                   ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: Eric Curtin @ 2015-09-15 19:53 UTC (permalink / raw)
  To: valentina.manea.m, shuah.kh; +Cc: linux-usb, linux-kernel

My first kernel patch, hope I did everything correctly! Instead of calling strlen on every iteration of the for loop, just call it once instead and store in a variable.

Signed-off-by: Eric Curtin <ericcurtin17@gmail.com>

diff --git a/tools/usb/usbip/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c
index 05c6d15..9db9d21 100644
--- a/tools/usb/usbip/src/usbip_detach.c
+++ b/tools/usb/usbip/src/usbip_detach.c
@@ -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;


^ permalink raw reply related	[flat|nested] 43+ messages in thread
* First kernel patch (optimization)
@ 2015-09-15 19:52 Eric Curtin
  2015-09-15 21:57 ` Alexander Duyck
  0 siblings, 1 reply; 43+ messages in thread
From: Eric Curtin @ 2015-09-15 19:52 UTC (permalink / raw)
  To: ericcurtin17; +Cc: linux-kernel

My first kernel patch, hope I did everything correctly! Instead of calling strlen on every iteration of the for loop, just call it once instead and store in a variable.

Signed-off-by: Eric Curtin <ericcurtin17@gmail.com>

diff --git a/tools/usb/usbip/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c
index 05c6d15..9db9d21 100644
--- a/tools/usb/usbip/src/usbip_detach.c
+++ b/tools/usb/usbip/src/usbip_detach.c
@@ -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;


^ permalink raw reply related	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2015-09-29 14:47 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-15 19:53 First kernel patch (optimization) Eric Curtin
2015-09-15 20:11 ` Felipe Balbi
2015-09-16  0:09 ` Steve Calfee
2015-09-16 11:45   ` Austin S Hemmelgarn
2015-09-16 12:56     ` David Laight
2015-09-17  1:49       ` Jaime Arrocha
2015-09-17  8:45         ` David Laight
2015-09-16 13:24     ` Greg KH
2015-09-16 16:03       ` Eric Curtin
2015-09-16 16:40         ` Theodore Ts'o
2015-09-16 17:24           ` Raymond Jennings
2015-09-16 17:26           ` Josh Boyer
2015-09-18  3:12             ` Theodore Ts'o
2015-09-18  7:42               ` Greg KH
2015-09-18  9:31                 ` Raymond Jennings
2015-09-18 19:08                   ` Austin S Hemmelgarn
2015-09-19  2:26                 ` Theodore Ts'o
2015-09-19  4:22                   ` Sudip Mukherjee
2015-09-19  5:18                   ` Greg KH
2015-09-19 12:20                     ` Theodore Ts'o
2015-09-19 12:52                     ` Alexander Holler
2015-09-19 14:14                       ` Alexander Holler
2015-09-19 14:22                       ` Theodore Ts'o
2015-09-19 17:47                         ` Alexander Holler
2015-09-20  2:21                           ` Theodore Ts'o
2015-09-20 10:41                             ` Alexander Holler
2015-09-21 15:47                               ` Austin S Hemmelgarn
2015-09-21 17:20                                 ` Alexander Holler
2015-09-21 18:41                                 ` Alexander Holler
2015-09-23  8:59                               ` Alexander Holler
2015-09-28  6:54                     ` Thiago Farina
2015-09-28 14:20                       ` Greg KH
2015-09-16 20:02         ` Greg KH
2015-09-16 20:21           ` Eric Curtin
2015-09-16 22:38             ` Greg KH
2015-09-22 17:38 ` Linus Torvalds
2015-09-22 18:18   ` Eric Curtin
2015-09-25 22:06     ` Dmitry Torokhov
2015-09-26 13:28       ` Eric Curtin
2015-09-29 13:51         ` Austin S Hemmelgarn
2015-09-29 14:47           ` Eric Curtin
  -- strict thread matches above, loose matches on Subject: below --
2015-09-15 19:52 Eric Curtin
2015-09-15 21:57 ` Alexander Duyck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox