diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-26 20:56:55 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-26 20:56:55 +0000 |
commit | c03e8721128fa7803d40dd07084f7650e88c7355 (patch) | |
tree | c13760bac677e9d4220477c0ac29ed9c2a52c1a4 | |
parent | abee3d0e0dc7c7e4b733b0145c56bf8159a37a69 (diff) | |
download | busybox-w32-c03e8721128fa7803d40dd07084f7650e88c7355.tar.gz busybox-w32-c03e8721128fa7803d40dd07084f7650e88c7355.tar.bz2 busybox-w32-c03e8721128fa7803d40dd07084f7650e88c7355.zip |
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
-rw-r--r-- | e2fsprogs/fsck.c | 4 | ||||
-rw-r--r-- | modutils/modprobe.c | 5 | ||||
-rw-r--r-- | networking/inetd.c | 6 | ||||
-rw-r--r-- | networking/udhcp/files.c | 10 | ||||
-rw-r--r-- | util-linux/mount.c | 2 |
5 files changed, 8 insertions, 19 deletions
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c index f80de8178..8dd9785ee 100644 --- a/e2fsprogs/fsck.c +++ b/e2fsprogs/fsck.c | |||
@@ -349,9 +349,7 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs) | |||
349 | 349 | ||
350 | *ret_fs = 0; | 350 | *ret_fs = 0; |
351 | strip_line(line); | 351 | strip_line(line); |
352 | cp = strchr(line, '#'); | 352 | *strchrnul(line, '#') = '\0'; /* Ignore everything after comment */ |
353 | if (cp) | ||
354 | *cp = '\0'; /* Ignore everything after the comment char */ | ||
355 | cp = line; | 353 | cp = line; |
356 | 354 | ||
357 | device = parse_word(&cp); | 355 | device = parse_word(&cp); |
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index bc2dbd128..f6681a8d8 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -242,11 +242,8 @@ static void include_conf(struct dep_t **first, struct dep_t **current, char *buf | |||
242 | 242 | ||
243 | while (reads(fd, buffer, buflen)) { | 243 | while (reads(fd, buffer, buflen)) { |
244 | int l; | 244 | int l; |
245 | char *p; | ||
246 | 245 | ||
247 | p = strchr(buffer, '#'); | 246 | *strchrnul(buffer, '#') = '\0'; |
248 | if (p) | ||
249 | *p = '\0'; | ||
250 | 247 | ||
251 | l = strlen(buffer); | 248 | l = strlen(buffer); |
252 | 249 | ||
diff --git a/networking/inetd.c b/networking/inetd.c index 5d3774639..a9c9397f5 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -554,13 +554,9 @@ static void setup(servtab_t *sep) | |||
554 | 554 | ||
555 | static char *nextline(void) | 555 | static char *nextline(void) |
556 | { | 556 | { |
557 | char *cp; | ||
558 | |||
559 | if (fgets(line, LINE_SIZE, fconfig) == NULL) | 557 | if (fgets(line, LINE_SIZE, fconfig) == NULL) |
560 | return NULL; | 558 | return NULL; |
561 | cp = strchr(line, '\n'); | 559 | *strchrnul(line, '\n') = '\0'; |
562 | if (cp) | ||
563 | *cp = '\0'; | ||
564 | return line; | 560 | return line; |
565 | } | 561 | } |
566 | 562 | ||
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 63c90647d..491b8871e 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -332,14 +332,12 @@ int read_config(const char *file) | |||
332 | 332 | ||
333 | while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) { | 333 | while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) { |
334 | char debug_orig[READ_CONFIG_BUF_SIZE]; | 334 | char debug_orig[READ_CONFIG_BUF_SIZE]; |
335 | char *p; | ||
336 | 335 | ||
337 | lm++; | 336 | lm++; |
338 | p = strchr(buffer, '\n'); | 337 | *strchrnul(buffer, '\n') = '\0'; |
339 | if (p) *p = '\0'; | 338 | if (ENABLE_FEATURE_UDHCP_DEBUG) |
340 | if (ENABLE_FEATURE_UDHCP_DEBUG) strcpy(debug_orig, buffer); | 339 | strcpy(debug_orig, buffer); |
341 | p = strchr(buffer, '#'); | 340 | *strchrnul(buffer, '#') = '\0'; |
342 | if (p) *p = '\0'; | ||
343 | 341 | ||
344 | token = strtok(buffer, " \t"); | 342 | token = strtok(buffer, " \t"); |
345 | if (!token) continue; | 343 | if (!token) continue; |
diff --git a/util-linux/mount.c b/util-linux/mount.c index 1ecdd9529..abf5cd03f 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -1448,7 +1448,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1448 | // Might this be a virtual filesystem? | 1448 | // Might this be a virtual filesystem? |
1449 | 1449 | ||
1450 | if (ENABLE_FEATURE_MOUNT_HELPERS | 1450 | if (ENABLE_FEATURE_MOUNT_HELPERS |
1451 | && (strchr(mp->mnt_fsname,'#')) | 1451 | && (strchr(mp->mnt_fsname, '#')) |
1452 | ) { | 1452 | ) { |
1453 | char *s, *p, *args[35]; | 1453 | char *s, *p, *args[35]; |
1454 | int n = 0; | 1454 | int n = 0; |