Always initialise a struct super_type to zero

This commit is contained in:
Neil Brown 2008-07-12 20:27:36 +10:00
parent 904c1ef77b
commit ef60947720
5 changed files with 11 additions and 4 deletions

View 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;

View 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;

View File

@ -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;

View File

@ -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;

6
util.c
View File

@ -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);