]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Various compile fixes.
authorNeilBrown <neilb@suse.de>
Tue, 1 Feb 2011 04:48:03 +0000 (15:48 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 1 Feb 2011 04:48:03 +0000 (15:48 +1100)
Make "make everything" succeed.
This fixed some real bugs.

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c
Incremental.c
Monitor.c
mapfile.c
mdassemble.c
super-gpt.c
super-intel.c
super-mbr.c
util.c

index 113c29cb2ef711153bc7f9574317d463b9da1e73..317be8b7314595adef30df09f3482418818b2aaa 100644 (file)
@@ -330,11 +330,13 @@ int Assemble(struct supertype *st, char *mddev,
                                        fprintf(stderr, Name ": %s is a container, but we are looking for components\n",
                                                devname);
                                tmpdev->used = 2;
+#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
                        } if (!tst && (tst = super_by_fd(dfd, NULL)) == NULL) {
                                if (report_missmatch)
                                        fprintf(stderr, Name ": not a recognisable container: %s\n",
                                                devname);
                                tmpdev->used = 2;
+#endif
                        } else if (!tst->ss->load_container
                                   || tst->ss->load_container(tst, dfd, NULL)) {
                                if (report_missmatch)
index 52558e4059d42aa4dd5fd7fb51925055ddaabcfe..889184fe8e8ebd5bc29efd9bd96ff634bfca97e0 100644 (file)
@@ -883,7 +883,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
                struct domainlist *dl = NULL;
                struct mdinfo *sra;
                unsigned long long devsize;
-               unsigned long long component_size;
+               unsigned long long component_size = 0;
 
                if (is_subarray(mp->metadata))
                        continue;
@@ -1077,7 +1077,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
        DIR *dir;
        struct dirent *de;
        char *chosen = NULL;
-       unsigned long long chosen_size;
+       unsigned long long chosen_size = 0;
        struct supertype *chosen_st = NULL;
        int fd;
 
@@ -1118,7 +1118,10 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
                domain_free(domlist);
                domlist = NULL;
 
-               asprintf(&devname, "/dev/disk/by-path/%s", de->d_name);
+               if (asprintf(&devname, "/dev/disk/by-path/%s", de->d_name) != 1) {
+                       devname = NULL;
+                       goto next;
+               }
                fd = open(devname, O_RDONLY);
                if (fd < 0)
                        goto next;
index 452f62d8d1b13cc78ee6c7897c1f135ebf6fb30f..d3795b1713d8e07226c4f83666ce01459e7452e9 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -291,7 +291,8 @@ static int check_one_sharer(int scan)
        struct stat buf;
        fp = fopen("/var/run/mdadm/autorebuild.pid", "r");
        if (fp) {
-               fscanf(fp, "%d", &pid);
+               if (fscanf(fp, "%d", &pid) != 1)
+                       pid = -1;
                sprintf(dir, "/proc/%d", pid);
                rv = stat(dir, &buf);
                if (rv != -1) {
index 1cc61d1b82aa702437768fbdfaa2dbb0b6028452..ff1e97360dc20cf06e586567e22d58e1c982da97 100644 (file)
--- a/mapfile.c
+++ b/mapfile.c
@@ -380,7 +380,7 @@ void RebuildMap(void)
                        int dfd;
                        int ok;
                        struct supertype *st;
-                       char *subarray;
+                       char *subarray = NULL;
                        char *path;
                        struct mdinfo *info;
 
index 28f431b45d3bb4b16733161ee7c8f793a2973444..a8b78ceb45b214e5de5c21691c7ed9881380eee0 100644 (file)
@@ -105,7 +105,7 @@ int main(int argc, char *argv[]) {
                        if (mdfd >= 0)
                                close(mdfd);
                        rv |= Assemble(array_list->st, array_list->devname,
-                                      array_list, NULL, NULL,
+                                      array_list, NULL, NULL, 0,
                                       readonly, runstop, NULL, NULL, 0,
                                       verbose, force);
                }
index e70a6fac3be9e5f2e467f292375d45aa8386726b..f60a67148c92c44e7f4d4ed3dc0ea600e96f24b1 100644 (file)
@@ -205,8 +205,8 @@ static int validate_geometry(struct supertype *st, int level,
 struct superswitch gpt = {
 #ifndef MDASSEMBLE
        .examine_super = examine_gpt,
-#endif
        .validate_geometry = validate_geometry,
+#endif
        .match_metadata_desc = match_metadata_desc,
        .load_super = load_gpt,
        .store_super = store_gpt,
index 5d39d5bbb5e780561ca7f90e0b6c0c1abd17343e..84ab47b3aebd42ca222da04e5581f7feeb464a58 100644 (file)
@@ -384,6 +384,7 @@ const char *get_sys_dev_type(enum sys_dev_type type)
        return _sys_dev_type[type];
 }
 
+#ifndef MDASSEMBLE
 static struct intel_hba * alloc_intel_hba(struct sys_dev *device)
 {
        struct intel_hba *result = malloc(sizeof(*result));
@@ -408,7 +409,6 @@ static struct intel_hba * find_intel_hba(struct intel_hba *hba, struct sys_dev *
 }
 
 
-
 static int attach_hba_to_super(struct intel_super *super, struct sys_dev *device,
                               const char *devname)
 {
@@ -475,6 +475,7 @@ static struct sys_dev* find_disk_attached_hba(int fd, const char *devname)
 
        return NULL;
 }
+#endif /* MDASSEMBLE */
 
 
 static struct supertype *match_metadata_desc_imsm(char *arg)
@@ -4646,7 +4647,6 @@ static int update_subarray_imsm(struct supertype *st, char *subarray,
 
        return 0;
 }
-#endif /* MDASSEMBLE */
 
 static int is_gen_migration(struct imsm_dev *dev)
 {
@@ -4658,6 +4658,7 @@ static int is_gen_migration(struct imsm_dev *dev)
 
        return 0;
 }
+#endif /* MDASSEMBLE */
 
 static int is_rebuilding(struct imsm_dev *dev)
 {
@@ -6639,7 +6640,6 @@ static void imsm_delete(struct intel_super *super, struct dl **dlp, unsigned ind
                __free_imsm_disk(dl);
        }
 }
-#endif /* MDASSEMBLE */
 
 static char disk_by_path[] = "/dev/disk/by-path/";
 
@@ -7066,7 +7066,7 @@ static int imsm_reshape_super(struct supertype *st, long long size, int level,
 
        dprintf("imsm: reshape_super called.\n");
 
-       memset(&geo, sizeof(struct geo_params), 0);
+       memset(&geo, 0, sizeof(struct geo_params));
 
        geo.dev_name = dev;
        geo.dev_id = st->devnum;
@@ -7167,6 +7167,7 @@ static int imsm_manage_reshape(
                afd, sra, reshape, st, stripes,
                fds, offsets, dests, destfd, destoffsets);
 }
+#endif /* MDASSEMBLE */
 
 struct superswitch super_imsm = {
 #ifndef        MDASSEMBLE
@@ -7184,6 +7185,10 @@ struct superswitch super_imsm = {
        .kill_subarray = kill_subarray_imsm,
        .update_subarray = update_subarray_imsm,
        .load_container = load_container_imsm,
+       .default_geometry = default_geometry_imsm,
+       .get_disk_controller_domain = imsm_get_disk_controller_domain,
+       .reshape_super  = imsm_reshape_super,
+       .manage_reshape = imsm_manage_reshape,
 #endif
        .match_home     = match_home_imsm,
        .uuid_from_super= uuid_from_super_imsm,
@@ -7202,10 +7207,6 @@ struct superswitch super_imsm = {
        .free_super     = free_super_imsm,
        .match_metadata_desc = match_metadata_desc_imsm,
        .container_content = container_content_imsm,
-       .default_geometry = default_geometry_imsm,
-       .get_disk_controller_domain = imsm_get_disk_controller_domain,
-       .reshape_super  = imsm_reshape_super,
-       .manage_reshape = imsm_manage_reshape,
 
        .external       = 1,
        .name = "imsm",
index 0129fd695223020ebb6f7f4d2952a7cd235f7395..7d770aa2489ae88efa5f04911adc6f1fae5e0f1b 100644 (file)
@@ -199,8 +199,8 @@ static int validate_geometry(struct supertype *st, int level,
 struct superswitch mbr = {
 #ifndef MDASSEMBLE
        .examine_super = examine_mbr,
-#endif
        .validate_geometry = validate_geometry,
+#endif
        .match_metadata_desc = match_metadata_desc,
        .load_super = load_super_mbr,
        .store_super = store_mbr,
diff --git a/util.c b/util.c
index 81f936018ff4c6367a55822719ed3be0a6323a31..87c23dcfbc5eb9ca7dffb7082ddba889dbc96d3b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -160,6 +160,7 @@ int get_linux_version()
        return (a*1000000)+(b*1000)+c;
 }
 
+#ifndef MDASSEMBLE
 int mdadm_version(char *version)
 {
        int a, b, c;
@@ -185,7 +186,6 @@ int mdadm_version(char *version)
        return (a*1000000)+(b*1000)+c;
 }
 
-#ifndef MDASSEMBLE
 long long parse_size(char *size)
 {
        /* parse 'size' which should be a number optionally