]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
Always initialise a struct super_type to zero
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index 365e66b81e06c3b5779684c7e2e7af28d5cadde4..08c6bb0b0e977acbb8c2bba724a96f456b1e58cd 100644 (file)
--- a/util.c
+++ b/util.c
@@ -841,6 +841,7 @@ struct supertype *dup_super(struct supertype *orig)
        st = malloc(sizeof(*st));
        if (!st)
                return st;
+       memset(st, 0, sizeof(*st));
        st->ss = orig->ss;
        st->max_devs = orig->max_devs;
        st->minor_version = orig->minor_version;
@@ -861,11 +862,10 @@ struct supertype *guess_super(int fd)
        int i;
 
        st = malloc(sizeof(*st));
-       memset(st, 0, sizeof(*st));
        for (i=0 ; superlist[i]; i++) {
                int rv;
                ss = superlist[i];
-               st->ss = NULL;
+               memset(st, 0, sizeof(*st));
                rv = ss->load_super(st, fd, NULL);
                if (rv == 0) {
                        struct mdinfo info;
@@ -880,7 +880,7 @@ struct supertype *guess_super(int fd)
        }
        if (bestsuper != -1) {
                int rv;
-               st->ss = NULL;
+               memset(st, 0, sizeof(*st));
                rv = superlist[bestsuper]->load_super(st, fd, NULL);
                if (rv == 0) {
                        superlist[bestsuper]->free_super(st);