]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Always initialise a struct super_type to zero
authorNeil Brown <neilb@suse.de>
Sat, 12 Jul 2008 10:27:36 +0000 (20:27 +1000)
committerNeil Brown <neilb@suse.de>
Sat, 12 Jul 2008 10:27:36 +0000 (20:27 +1000)
super-ddf.c
super-intel.c
super0.c
super1.c
util.c

index 339db9fab75914a92bbe08d80da6473256926994..0c2a0138c5b9b480ce84c9beda400cb2e7a8628a 100644 (file)
@@ -820,6 +820,7 @@ static struct supertype *match_metadata_desc_ddf(char *arg)
                return NULL;
 
        st = malloc(sizeof(*st));
+       memset(st, 0, sizeof(*st));
        st->ss = &super_ddf;
        st->max_devs = 512;
        st->minor_version = 0;
@@ -837,6 +838,7 @@ static struct supertype *match_metadata_desc_ddf_bvd(char *arg)
                return NULL;
 
        st = malloc(sizeof(*st));
+       memset(st, 0, sizeof(*st));
        st->ss = &super_ddf_bvd;
        st->max_devs = 512;
        st->minor_version = 0;
@@ -853,6 +855,7 @@ static struct supertype *match_metadata_desc_ddf_svd(char *arg)
                return NULL;
 
        st = malloc(sizeof(*st));
+       memset(st, 0, sizeof(*st));
        st->ss = &super_ddf_svd;
        st->max_devs = 512;
        st->minor_version = 0;
index 8ca491bd035e104ef52321745bc97fd5f345dca7..263e398a89181ed9643cdbf1043f2723a6ae86f6 100644 (file)
@@ -157,6 +157,7 @@ static struct supertype *match_metadata_desc_imsm(char *arg)
                return NULL;
 
        st = malloc(sizeof(*st));
+       memset(st, 0, sizeof(*st));
        st->ss = &super_imsm;
        st->max_devs = IMSM_MAX_DEVICES;
        st->minor_version = 0;
@@ -175,6 +176,7 @@ static struct supertype *match_metadata_desc_imsm_volume(char *arg)
                return NULL;
 
        st = malloc(sizeof(*st));
+       memset(st, 0, sizeof(*st));
        st->ss = &super_imsm_volume;
        st->max_devs = IMSM_MAX_DEVICES;
        st->minor_version = 0;
index b0a625bde57cd4e4a34fcc85e5d000f062105e7a..1ca35368bb4f92ca8d5b4d2b7d728bef60b11588 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -869,6 +869,7 @@ static struct supertype *match_metadata_desc0(char *arg)
        struct supertype *st = malloc(sizeof(*st));
        if (!st) return st;
 
+       memset(st, 0, sizeof(*st));
        st->ss = &super0;
        st->info = NULL;
        st->minor_version = 90;
index 211be82356d0df94913da900693dfe55aa60881d..0fe54e97c22fda05c350774d8ea23f8cca93440b 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -1073,8 +1073,8 @@ static int load_super1(struct supertype *st, int fd, char *devname)
                struct supertype tst;
                __u64 bestctime = 0;
                /* guess... choose latest ctime */
+               memset(&tst, 0, sizeof(tst));
                tst.ss = &super1;
-               tst.sb = NULL;
                for (tst.minor_version = 0; tst.minor_version <= 2 ; tst.minor_version++) {
                        switch(load_super1(&tst, fd, devname)) {
                        case 0: super = tst.sb;
@@ -1216,6 +1216,7 @@ static struct supertype *match_metadata_desc1(char *arg)
        struct supertype *st = malloc(sizeof(*st));
        if (!st) return st;
 
+       memset(st, 0, sizeof(*st));
        st->ss = &super1;
        st->max_devs = 384;
        st->sb = NULL;
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);