]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: clean up MNT_FMT_* usage in parser
authorKarel Zak <kzak@redhat.com>
Tue, 3 Apr 2012 09:32:12 +0000 (11:32 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Apr 2012 09:32:12 +0000 (11:32 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/tab_parse.c

index 28c8536afec2017897c03928ab13e91e2f010d38..6d3e21d21b549a14553db19b3d41675f2850380a 100644 (file)
@@ -295,6 +295,7 @@ static int mnt_table_parse_next(struct libmnt_table *tb, FILE *f, struct libmnt_
 {
        char buf[BUFSIZ];
        char *s;
+       int rc;
 
        assert(tb);
        assert(f);
@@ -329,23 +330,23 @@ static int mnt_table_parse_next(struct libmnt_table *tb, FILE *f, struct libmnt_
        if (tb->fmt == MNT_FMT_GUESS)
                tb->fmt = guess_table_format(s);
 
-       if (tb->fmt == MNT_FMT_FSTAB) {
-               if (mnt_parse_table_line(fs, s) != 0)
-                       goto err;
-
-       } else if (tb->fmt == MNT_FMT_MOUNTINFO) {
-               if (mnt_parse_mountinfo_line(fs, s) != 0)
-                       goto err;
-
-       } else if (tb->fmt == MNT_FMT_UTAB) {
-               if (mnt_parse_utab_line(fs, s) != 0)
-                       goto err;
+       switch (tb->fmt) {
+       case MNT_FMT_FSTAB:
+               rc = mnt_parse_table_line(fs, s);
+               break;
+       case MNT_FMT_MOUNTINFO:
+               rc = mnt_parse_mountinfo_line(fs, s);
+               break;
+       case MNT_FMT_UTAB:
+               rc = mnt_parse_utab_line(fs, s);
+               break;
+       default:
+               rc = -1;        /* unknown format */
+               break;
        }
 
-
-       /*DBG(TAB, mnt_fs_print_debug(fs, stderr));*/
-
-       return 0;
+       if (rc == 0)
+               return 0;
 err:
        DBG(TAB, mnt_debug_h(tb, "%s:%d: %s parse error", filename, *nlines,
                                tb->fmt == MNT_FMT_MOUNTINFO ? "mountinfo" :