]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: Grow_addbitmap(): Add check to quiet down static code checkers
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 4 Mar 2016 21:49:38 +0000 (16:49 -0500)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 9 Mar 2016 16:35:34 +0000 (11:35 -0500)
Grow_addbitmap() is only ever called with s->bitmap_file != NULL, but
not all static code checkers catch this. This adds a check to quiet
down the false positive warnings.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Grow.c

diff --git a/Grow.c b/Grow.c
index c4af5c031c410104befe2c581172013e77acf423..cf2750aab2c8f18c96922e69b4937a86647fd4d6 100755 (executable)
--- a/Grow.c
+++ b/Grow.c
@@ -297,7 +297,14 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
                        "  between different architectures.  Consider upgrading the Linux kernel.\n");
        }
 
-       if (s->bitmap_file && strcmp(s->bitmap_file, "clustered") == 0)
+       /*
+        * We only ever get called if s->bitmap_file is != NULL, so this check
+        * is just here to quiet down static code checkers.
+        */
+       if (!s->bitmap_file)
+               return 1;
+
+       if (strcmp(s->bitmap_file, "clustered") == 0)
                major = BITMAP_MAJOR_CLUSTERED;
 
        if (ioctl(fd, GET_BITMAP_FILE, &bmf) != 0) {