Various compile fixes.

Make "make everything" succeed.
This fixed some real bugs.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-02-01 15:48:03 +11:00
parent 87eb4fabe3
commit 71204a5029
9 changed files with 24 additions and 17 deletions

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

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

View File

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

View File

@ -380,7 +380,7 @@ void RebuildMap(void)
int dfd;
int ok;
struct supertype *st;
char *subarray;
char *subarray = NULL;
char *path;
struct mdinfo *info;

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

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

View 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",

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

2
util.c
View File

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