lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <922f652ded6488f697f4b92e47064b41685a41d8.1258559170.git.andre.goddard@gmail.com>
Date:	Thu,  3 Dec 2009 12:52:41 -0200
From:	André Goddard Rosa <andre.goddard@...il.com>
To:	"Andrew Morton" <akpm@...ux-foundation.org>,
	"linux list" <linux-kernel@...r.kernel.org>
Cc:	André Goddard Rosa <andre.goddard@...il.com>
Subject: [PATCH][resend] parser: remove unnecessary strlen()

No functional change. Cache strlen() result to avoid recalculating it up
to 3 times on the worst case.

Reduces code size a little by 32 bytes:
   text    data     bss     dec     hex filename
   1385       0       0    1385     569 lib/parser.o-BEFORE
   1353       0       0    1353     549 lib/parser.o-AFTER

Signed-off-by: André Goddard Rosa <andre.goddard@...il.com>
---
 lib/parser.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/parser.c b/lib/parser.c
index b00d020..fb34977 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -56,13 +56,16 @@ static int match_one(char *s, const char *p, substring_t args[])
 
 		args[argc].from = s;
 		switch (*p++) {
-		case 's':
-			if (strlen(s) == 0)
+		case 's': {
+			size_t str_len = strlen(s);
+
+			if (str_len == 0)
 				return 0;
-			else if (len == -1 || len > strlen(s))
-				len = strlen(s);
+			if (len == -1 || len > str_len)
+				len = str_len;
 			args[argc].to = s + len;
 			break;
+		}
 		case 'd':
 			simple_strtol(s, &args[argc].to, 0);
 			goto num;
-- 
1.6.5.3.148.g785c5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ