svn commit: trunk/busybox: e2fsprogs modutils networking networking etc...

vda at busybox.net vda at busybox.net
Wed Dec 26 20:56:56 UTC 2007


Author: vda
Date: 2007-12-26 12:56:55 -0800 (Wed, 26 Dec 2007)
New Revision: 20689

Log:
save a bit of code with *strchrnul = '\0' trick

function                                             old     new   delta
nextline                                              59      55      -4
include_conf                                         902     898      -4
read_config                                          414     406      -8
fsck_main                                           1880    1869     -11



Modified:
   trunk/busybox/e2fsprogs/fsck.c
   trunk/busybox/modutils/modprobe.c
   trunk/busybox/networking/inetd.c
   trunk/busybox/networking/udhcp/files.c
   trunk/busybox/util-linux/mount.c


Changeset:
Modified: trunk/busybox/e2fsprogs/fsck.c
===================================================================
--- trunk/busybox/e2fsprogs/fsck.c	2007-12-26 20:44:45 UTC (rev 20688)
+++ trunk/busybox/e2fsprogs/fsck.c	2007-12-26 20:56:55 UTC (rev 20689)
@@ -349,9 +349,7 @@
 
 	*ret_fs = 0;
 	strip_line(line);
-	cp = strchr(line, '#');
-	if (cp)
-		*cp = '\0'; /* Ignore everything after the comment char */
+	*strchrnul(line, '#') = '\0'; /* Ignore everything after comment */
 	cp = line;
 
 	device = parse_word(&cp);

Modified: trunk/busybox/modutils/modprobe.c
===================================================================
--- trunk/busybox/modutils/modprobe.c	2007-12-26 20:44:45 UTC (rev 20688)
+++ trunk/busybox/modutils/modprobe.c	2007-12-26 20:56:55 UTC (rev 20689)
@@ -242,11 +242,8 @@
 
 	while (reads(fd, buffer, buflen)) {
 		int l;
-		char *p;
 
-		p = strchr(buffer, '#');
-		if (p)
-			*p = '\0';
+		*strchrnul(buffer, '#') = '\0';
 
 		l = strlen(buffer);
 

Modified: trunk/busybox/networking/inetd.c
===================================================================
--- trunk/busybox/networking/inetd.c	2007-12-26 20:44:45 UTC (rev 20688)
+++ trunk/busybox/networking/inetd.c	2007-12-26 20:56:55 UTC (rev 20689)
@@ -554,13 +554,9 @@
 
 static char *nextline(void)
 {
-	char *cp;
-
 	if (fgets(line, LINE_SIZE, fconfig) == NULL)
 		return NULL;
-	cp = strchr(line, '\n');
-	if (cp)
-		*cp = '\0';
+	*strchrnul(line, '\n') = '\0';
 	return line;
 }
 

Modified: trunk/busybox/networking/udhcp/files.c
===================================================================
--- trunk/busybox/networking/udhcp/files.c	2007-12-26 20:44:45 UTC (rev 20688)
+++ trunk/busybox/networking/udhcp/files.c	2007-12-26 20:56:55 UTC (rev 20689)
@@ -332,14 +332,12 @@
 
 	while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) {
 		char debug_orig[READ_CONFIG_BUF_SIZE];
-		char *p;
 
 		lm++;
-		p = strchr(buffer, '\n');
-		if (p) *p = '\0';
-		if (ENABLE_FEATURE_UDHCP_DEBUG) strcpy(debug_orig, buffer);
-		p = strchr(buffer, '#');
-		if (p) *p = '\0';
+		*strchrnul(buffer, '\n') = '\0';
+		if (ENABLE_FEATURE_UDHCP_DEBUG)
+			strcpy(debug_orig, buffer);
+		*strchrnul(buffer, '#') = '\0';
 
 		token = strtok(buffer, " \t");
 		if (!token) continue;

Modified: trunk/busybox/util-linux/mount.c
===================================================================
--- trunk/busybox/util-linux/mount.c	2007-12-26 20:44:45 UTC (rev 20688)
+++ trunk/busybox/util-linux/mount.c	2007-12-26 20:56:55 UTC (rev 20689)
@@ -1448,7 +1448,7 @@
 	// Might this be a virtual filesystem?
 
 	if (ENABLE_FEATURE_MOUNT_HELPERS
-	 && (strchr(mp->mnt_fsname,'#'))
+	 && (strchr(mp->mnt_fsname, '#'))
 	) {
 		char *s, *p, *args[35];
 		int n = 0;




More information about the busybox-cvs mailing list