Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Feb 2012 21:47:51 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232007 - head/lib/libc/gen
Message-ID:  <201202222147.q1MLlpji070412@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Wed Feb 22 21:47:50 2012
New Revision: 232007
URL: http://svn.freebsd.org/changeset/base/232007

Log:
  libc: Eliminate some relative relocations in fmtmsg().

Modified:
  head/lib/libc/gen/fmtmsg.c

Modified: head/lib/libc/gen/fmtmsg.c
==============================================================================
--- head/lib/libc/gen/fmtmsg.c	Wed Feb 22 21:46:15 2012	(r232006)
+++ head/lib/libc/gen/fmtmsg.c	Wed Feb 22 21:47:50 2012	(r232007)
@@ -45,10 +45,6 @@ static const char
 		*sevinfo(int);
 static int	 validmsgverb(const char *);
 
-static const char *validlist[] = {
-	"label", "severity", "text", "action", "tag", NULL
-};
-
 int
 fmtmsg(long class, const char *label, int sev, const char *text,
     const char *action, const char *tag)
@@ -205,14 +201,18 @@ sevinfo(int sev)
 static int
 validmsgverb(const char *msgverb)
 {
+	const char *validlist = "label\0severity\0text\0action\0tag\0";
 	char *msgcomp;
-	int i, equality;
+	size_t len1, len2;
+	const char *p;
+	int equality;
 
 	equality = 0;
 	while ((msgcomp = nextcomp(msgverb)) != NULL) {
 		equality--;
-		for (i = 0; validlist[i] != NULL; i++) {
-			if (strcmp(msgcomp, validlist[i]) == 0)
+		len1 = strlen(msgcomp);
+		for (p = validlist; (len2 = strlen(p)) != 0; p += len2 + 1) {
+			if (len1 == len2 && memcmp(msgcomp, p, len1) == 0)
 				equality++;
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202222147.q1MLlpji070412>