]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: cleanup assert() usage
authorKarel Zak <kzak@redhat.com>
Tue, 4 Aug 2015 11:21:42 +0000 (13:21 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 4 Aug 2015 11:21:42 +0000 (13:21 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c
libmount/src/context_loopdev.c
libmount/src/context_mount.c
libmount/src/context_umount.c
libmount/src/monitor.c
libmount/src/tab.c

index ec04191fccb20f56f36b382ebe4ef0d525a9da46..5ab0b794e467cd812dbaae8c9469611e5fdad74a 100644 (file)
@@ -259,7 +259,6 @@ const char *mnt_context_get_writable_tabpath(struct libmnt_context *cxt)
 
 static int set_flag(struct libmnt_context *cxt, int flag, int enable)
 {
-       assert(cxt);
        if (!cxt)
                return -EINVAL;
        if (enable) {
@@ -1391,7 +1390,6 @@ int mnt_context_get_mflags(struct libmnt_context *cxt, unsigned long *flags)
  */
 int mnt_context_set_user_mflags(struct libmnt_context *cxt, unsigned long flags)
 {
-       assert(cxt);
        if (!cxt)
                return -EINVAL;
        cxt->user_mountflags = flags;
@@ -1464,9 +1462,6 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
        assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       if (!cxt || !cxt->fs)
-               return -EINVAL;
-
        DBG(CXT, ul_debugobj(cxt, "preparing source path"));
 
        src = mnt_fs_get_source(cxt->fs);
@@ -1582,9 +1577,6 @@ int mnt_context_prepare_target(struct libmnt_context *cxt)
        assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       if (!cxt || !cxt->fs)
-               return -EINVAL;
-
        DBG(CXT, ul_debugobj(cxt, "preparing target path"));
 
        tgt = mnt_fs_get_target(cxt->fs);
@@ -1667,9 +1659,6 @@ int mnt_context_guess_fstype(struct libmnt_context *cxt)
 
        DBG(CXT, ul_debugobj(cxt, "preparing fstype"));
 
-       if (!cxt || !cxt->fs)
-               return -EINVAL;
-
        if ((cxt->mountflags & (MS_BIND | MS_MOVE))
            || mnt_context_propagation_only(cxt))
                goto none;
@@ -1921,9 +1910,6 @@ static int apply_table(struct libmnt_context *cxt, struct libmnt_table *tb,
        assert(cxt);
        assert(cxt->fs);
 
-       if (!cxt->fs)
-               return -EINVAL;
-
        src = mnt_fs_get_source(cxt->fs);
        tgt = mnt_fs_get_target(cxt->fs);
 
index 68b8dabc949fe3eacbc12dbaedd52af5f3d9b608..787114228c650cafa04603be0c654f4ccaf423fc 100644 (file)
@@ -147,9 +147,6 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
        assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       if (!cxt)
-               return -EINVAL;
-
        backing_file = mnt_fs_get_srcpath(cxt->fs);
        if (!backing_file)
                return -EINVAL;
@@ -317,9 +314,6 @@ int mnt_context_delete_loopdev(struct libmnt_context *cxt)
        assert(cxt);
        assert(cxt->fs);
 
-       if (!cxt)
-               return -EINVAL;
-
        src = mnt_fs_get_srcpath(cxt->fs);
        if (!src)
                return -EINVAL;
@@ -343,9 +337,6 @@ int mnt_context_clear_loopdev(struct libmnt_context *cxt)
 {
        assert(cxt);
 
-       if (!cxt)
-               return -EINVAL;
-
        if (mnt_context_get_status(cxt) == 0 &&
            (cxt->flags & MNT_FL_LOOPDEV_READY)) {
                /*
index 210f0f16901f1157788b59b499b4f5ca79282258..63cba216b3122519add648be7db491827aae4480 100644 (file)
@@ -159,11 +159,8 @@ static int fix_optstr(struct libmnt_context *cxt)
        };
 #endif
        assert(cxt);
-       assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       if (!cxt)
-               return -EINVAL;
        if (!cxt->fs || (cxt->flags & MNT_FL_MOUNTOPTS_FIXED))
                return 0;
 
@@ -390,11 +387,8 @@ static int evaluate_permissions(struct libmnt_context *cxt)
        unsigned long u_flags = 0;
 
        assert(cxt);
-       assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       if (!cxt)
-               return -EINVAL;
        if (!cxt->fs)
                return 0;
 
@@ -816,7 +810,6 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
        assert(cxt);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-
        /*
         * Use the pattern as list of the filesystems
         */
@@ -861,11 +854,6 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt)
 {
        int rc = -EINVAL;
 
-       assert(cxt);
-       assert(cxt->fs);
-       assert(cxt->helper_exec_status == 1);
-       assert(cxt->syscall_status == 1);
-
        if (!cxt || !cxt->fs || mnt_fs_is_swaparea(cxt->fs))
                return -EINVAL;
        if (!mnt_fs_get_source(cxt->fs) && !mnt_fs_get_target(cxt->fs))
@@ -873,6 +861,9 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt)
        if (cxt->flags & MNT_FL_PREPARED)
                return 0;
 
+       assert(cxt->helper_exec_status == 1);
+       assert(cxt->syscall_status == 1);
+
        cxt->action = MNT_ACT_MOUNT;
 
        DBG(CXT, ul_debugobj(cxt, "mount: preparing"));
index 134c92b6e6ece4502a41c881722dda2a6e71df86..c4e9ebbee767c24a98cc5a9ce18e45cbcebebc7f 100644 (file)
@@ -368,9 +368,6 @@ static int evaluate_permissions(struct libmnt_context *cxt)
        assert(cxt->fs);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
-       if (!cxt || !cxt->fs)
-               return -EINVAL;
-
        if (!mnt_context_is_restricted(cxt))
                 return 0;              /* superuser mount */
 
@@ -749,11 +746,6 @@ int mnt_context_prepare_umount(struct libmnt_context *cxt)
 {
        int rc;
 
-       assert(cxt);
-       assert(cxt->fs);
-       assert(cxt->helper_exec_status == 1);
-       assert(cxt->syscall_status == 1);
-
        if (!cxt || !cxt->fs || mnt_fs_is_swaparea(cxt->fs))
                return -EINVAL;
        if (!mnt_context_get_source(cxt) && !mnt_context_get_target(cxt))
@@ -761,6 +753,9 @@ int mnt_context_prepare_umount(struct libmnt_context *cxt)
        if (cxt->flags & MNT_FL_PREPARED)
                return 0;
 
+       assert(cxt->helper_exec_status == 1);
+       assert(cxt->syscall_status == 1);
+
        free(cxt->helper);      /* be paranoid */
        cxt->helper = NULL;
        cxt->action = MNT_ACT_UMOUNT;
index c33e7d3c611807b4fb8cbc995bbbbf11c84ad0a2..18142da5c8f92ca8878a96207a976b6cbb908dda 100644 (file)
@@ -168,9 +168,6 @@ static int monitor_next_entry(struct libmnt_monitor *mn,
        assert(itr);
        assert(me);
 
-       if (!mn || !itr || !me)
-               return -EINVAL;
-
        *me = NULL;
 
        if (!itr->head)
@@ -277,9 +274,6 @@ static int userspace_monitor_get_fd(struct libmnt_monitor *mn,
 {
        int rc;
 
-       assert(mn);
-       assert(me);
-
        if (!me || me->enable == 0)     /* not-initialized or disabled */
                return -EINVAL;
        if (me->fd >= 0)
@@ -457,9 +451,6 @@ static int kernel_monitor_get_fd(struct libmnt_monitor *mn,
 {
        int rc;
 
-       assert(mn);
-       assert(me);
-
        if (!me || me->enable == 0)     /* not-initialized or disabled */
                return -EINVAL;
        if (me->fd >= 0)
index 09896ccb619d8f4e80ac3c06e2b5612926cb1018..d616547c895daa5bb21cebc2a8322bb142196046 100644 (file)
@@ -1148,8 +1148,6 @@ struct libmnt_fs *mnt_table_find_devno(struct libmnt_table *tb,
        struct libmnt_fs *fs = NULL;
        struct libmnt_iter itr;
 
-       assert(tb);
-
        if (!tb)
                return NULL;
        if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)