]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
getinfo_super now clears the 'info' structure before filling it in.
authorNeilBrown <neilb@suse.de>
Wed, 8 Jun 2011 05:54:13 +0000 (15:54 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 8 Jun 2011 05:54:13 +0000 (15:54 +1000)
Some code currently clears 'info' before calling getinfo_super,
some code doesn't.

To be consistent, change it so no caller ever clears 'info',
but ever getinfo_super function must clear it.

Note that ->raid_disk may be meaningful if that 'map' is passed
non-NULL.  In that case it is copied out before the structure
is zeroed.

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c
Create.c
Incremental.c
mdadm.h
super-ddf.c
super-intel.c
super0.c
super1.c

index 8b05829d3a132ed72dd7ddc63ae5772276b5fe81..250a6e0ee15ff83a78f26c1d9c0072602471b637 100644 (file)
@@ -418,7 +418,6 @@ int Assemble(struct supertype *st, char *mddev,
                                        int uuid[4];
 
                                        content = &info;
-                                       memset(content, 0, sizeof(*content));
                                        tst->ss->getinfo_super(tst, content, NULL);
 
                                        if (!parse_uuid(ident->container, uuid) ||
@@ -484,7 +483,6 @@ int Assemble(struct supertype *st, char *mddev,
                } else {
 
                        content = &info;
-                       memset(content, 0, sizeof(*content));
                        tst->ss->getinfo_super(tst, content, NULL);
 
                        if (!ident_matches(ident, content, tst,
index 1aeff77b7668ba1eb7cacfcf3ffa90bccbf43ccb..7b4d0feceabe7e9c193d430b0aafb054910e86f6 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -658,8 +658,8 @@ int Create(struct supertype *st, char *mddev,
                goto abort;
 
        total_slots = info.array.nr_disks;
-       sysfs_init(&info, mdfd, 0);
        st->ss->getinfo_super(st, &info, NULL);
+       sysfs_init(&info, mdfd, 0);
 
        if (did_default && verbose >= 0) {
                if (is_subarray(info.text_version)) {
index 14184da0291441cd3c3fc6ba8c5a1d904727bfa0..f576cbae35b1d8669b9bad2eb3937105caac9134 100644 (file)
@@ -202,7 +202,6 @@ int Incremental(char *devname, int verbose, int runstop,
        }
        close (dfd); dfd = -1;
 
-       memset(&info, 0, sizeof(info));
        st->ss->getinfo_super(st, &info, NULL);
 
        /* 3/ Check if there is a match in mdadm.conf */
@@ -396,7 +395,6 @@ int Incremental(char *devname, int verbose, int runstop,
                                goto out;
                        }
                        close(dfd2);
-                       memset(&info2, 0, sizeof(info2));
                        st2->ss->getinfo_super(st2, &info2, NULL);
                        st2->ss->free_super(st2);
                        if (info.array.level != info2.array.level ||
@@ -1435,7 +1433,6 @@ static int Incremental_container(struct supertype *st, char *devname,
        int suuid[4];
        int sfd;
 
-       memset(&info, 0, sizeof(info));
        st->ss->getinfo_super(st, &info, NULL);
 
        if ((runstop > 0 && info.container_enough >= 0) ||
diff --git a/mdadm.h b/mdadm.h
index 9437d04ea2a07f84f0f19ad9ee04b434a15d3298..8bde0de5771ccb7586f4bcb9e1be53ebbe8bd1e2 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -616,6 +616,7 @@ extern struct superswitch {
         * (raid_disk must already be set and correct) and it is filled
         * with 1 for slots that are thought to be active and 0 for slots which
         * appear to be failed/missing.
+        * *info is zeroed out before data is added.
         */
        void (*getinfo_super)(struct supertype *st, struct mdinfo *info, char *map);
        struct mdinfo *(*getinfo_super_disks)(struct supertype *st);
index 8f88b70837f765a46166cfdde3839711fc8cc600..21a917e4fc965f09a4155f983cd652d88092aa66 100644 (file)
@@ -1341,6 +1341,7 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
                getinfo_super_ddf_bvd(st, info, map);
                return;
        }
+       memset(info, 0, sizeof(*info));
 
        info->array.raid_disks    = __be16_to_cpu(ddf->phys->used_pdes);
        info->array.level         = LEVEL_CONTAINER;
@@ -1406,6 +1407,7 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
        struct dl *dl;
        int map_disks = info->array.raid_disks;
 
+       memset(info, 0, sizeof(*info));
        /* FIXME this returns BVD info - what if we want SVD ?? */
 
        info->array.raid_disks    = __be16_to_cpu(vc->conf.prim_elmnt_count);
index e401eb0153aecaba934c8c3abdd1fc0c2033ee10..b1461c64ebf5f17e4454116f290f918f240660bb 100644 (file)
@@ -1764,6 +1764,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
        unsigned int component_size_alligment;
        int map_disks = info->array.raid_disks;
 
+       memset(info, 0, sizeof(*info));
        if (prev_map)
                map_to_analyse = prev_map;
 
@@ -1972,6 +1973,7 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *
                getinfo_super_imsm_volume(st, info, map);
                return;
        }
+       memset(info, 0, sizeof(*info));
 
        /* Set raid_disks to zero so that Assemble will always pull in valid
         * spares
index 2c27e1e196c951b6ed0d23cf5bdce05a65b12304..440981bab9971320373af515f9882701ea60f8a1 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -346,6 +346,7 @@ static void getinfo_super0(struct supertype *st, struct mdinfo *info, char *map)
        int i;
        int map_disks = info->array.raid_disks;
 
+       memset(info, 0, sizeof(*info));
        info->array.major_version = sb->major_version;
        info->array.minor_version = sb->minor_version;
        info->array.patch_version = sb->patch_version;
index 9ba1ded4e00d152d28d413af20eeeb3c002559e3..81648232ede07fda76344b1a9f13d88733787b00 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -566,6 +566,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
        unsigned int role;
        unsigned int map_disks = info->array.raid_disks;
 
+       memset(info, 0, sizeof(*info));
        info->array.major_version = 1;
        info->array.minor_version = st->minor_version;
        info->array.patch_version = 0;