From 372686bde7b4c0abaf01123d8dda1dc6ab9a92e2 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Thu, 12 Oct 2006 22:42:33 +0000 Subject: cut, mount: small improvements --- util-linux/mount.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'util-linux/mount.c') diff --git a/util-linux/mount.c b/util-linux/mount.c index 531fb4520..5448f1f21 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -172,8 +172,12 @@ static int parse_mount_options(char *options, char **unrecognized) static llist_t *get_block_backed_filesystems(void) { - char *fs, *buf, - *filesystems[] = {"/etc/filesystems", "/proc/filesystems", 0}; + static const char *const filesystems[] = { + "/etc/filesystems", + "/proc/filesystems", + 0 + }; + char *fs, *buf; llist_t *list = 0; int i; FILE *f; @@ -182,16 +186,15 @@ static llist_t *get_block_backed_filesystems(void) f = fopen(filesystems[i], "r"); if (!f) continue; - for (fs = buf = 0; (fs = buf = bb_get_chomped_line_from_file(f)); - free(buf)) - { - if (!strncmp(buf,"nodev",5) && isspace(buf[5])) continue; - + while ((buf = bb_get_chomped_line_from_file(f)) != 0) { + if (!strncmp(buf, "nodev", 5) && isspace(buf[5])) + continue; + fs = buf; while (isspace(*fs)) fs++; - if (*fs=='#' || *fs=='*') continue; - if (!*fs) continue; + if (*fs=='#' || *fs=='*' || !*fs) continue; - llist_add_to_end(&list,xstrdup(fs)); + llist_add_to_end(&list, xstrdup(fs)); + free(buf); } if (ENABLE_FEATURE_CLEAN_UP) fclose(f); } -- cgit v1.2.3