]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
Always initialise a struct super_type to zero
[thirdparty/mdadm.git] / super-ddf.c
index 0d2a45617ca52c8ce494645c3d297d56fceae632..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;
@@ -2147,9 +2150,9 @@ int validate_geometry_ddf(struct supertype *st,
                                                         dev, freesize);
                }
                close(cfd);
-       }
-       fprintf(stderr, Name ": Cannot use %s: Already in use\n",
-               dev);
+       } else /* device may belong to a different container */
+               return 0;
+
        return 1;
 }
 
@@ -3045,8 +3048,8 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
         * Create a metadata_update record to update the
         * phys_refnum and lba_offset values
         */
-       mu = malloc(sizeof(*mu) + ddf->conf_rec_len * 512);
-       mu->buf = (char*)(mu+1);
+       mu = malloc(sizeof(*mu));
+       mu->buf = malloc(ddf->conf_rec_len * 512);
        mu->space = malloc(sizeof(struct vcl));
        mu->len = ddf->conf_rec_len;
        mu->next = *updates;