summaryrefslogtreecommitdiff
path: root/managemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'managemon.c')
-rw-r--r--managemon.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/managemon.c b/managemon.c
index 6c21ecbd..ef351b39 100644
--- a/managemon.c
+++ b/managemon.c
@@ -147,7 +147,7 @@ static void free_aa(struct active_array *aa)
static struct active_array *duplicate_aa(struct active_array *aa)
{
- struct active_array *newa = malloc(sizeof(*newa));
+ struct active_array *newa = xmalloc(sizeof(*newa));
struct mdinfo **dp1, **dp2;
*newa = *aa;
@@ -162,7 +162,7 @@ static struct active_array *duplicate_aa(struct active_array *aa)
if ((*dp1)->state_fd < 0)
continue;
- d = malloc(sizeof(*d));
+ d = xmalloc(sizeof(*d));
*d = **dp1;
*dp2 = d;
dp2 = & d->next;
@@ -391,12 +391,8 @@ static void manage_container(struct mdstat_ent *mdstat,
di->disk.minor == cd->disk.minor)
break;
if (!cd) {
- struct mdinfo *newd = malloc(sizeof(*newd));
+ struct mdinfo *newd = xmalloc(sizeof(*newd));
- if (!newd) {
- container->devcnt = -1;
- continue;
- }
*newd = *di;
add_disk_to_container(container, newd);
}
@@ -525,9 +521,7 @@ static void manage_member(struct mdstat_ent *mdstat,
for (d = newdev; d ; d = d->next) {
struct mdinfo *newd;
- newd = malloc(sizeof(*newd));
- if (!newd)
- continue;
+ newd = xmalloc(sizeof(*newd));
if (sysfs_add_disk(&newa->info, d, 0) < 0) {
free(newd);
continue;
@@ -577,9 +571,7 @@ static void manage_member(struct mdstat_ent *mdstat,
if (!newa)
break;
}
- newd = malloc(sizeof(*newd));
- if (!newd)
- continue;
+ newd = xmalloc(sizeof(*newd));
disk_init_and_add(newd, d, newa);
}
if (sysfs_get_ll(info, NULL, "array_size", &array_size) == 0
@@ -643,16 +635,10 @@ static void manage_new(struct mdstat_ent *mdstat,
GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT|
GET_DEGRADED|GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE);
- new = malloc(sizeof(*new));
- if (!new || !mdi) {
- if (mdi)
- sysfs_free(mdi);
- if (new)
- free(new);
+ if (!mdi)
return;
- }
- memset(new, 0, sizeof(*new));
+ new = xcalloc(1, sizeof(*new));
new->devnum = mdstat->devnum;
strcpy(new->info.sys_name, devnum2devname(new->devnum));
@@ -668,7 +654,7 @@ static void manage_new(struct mdstat_ent *mdstat,
new->info.component_size = mdi->component_size;
for (i = 0; i < new->info.array.raid_disks; i++) {
- struct mdinfo *newd = malloc(sizeof(*newd));
+ struct mdinfo *newd = xmalloc(sizeof(*newd));
for (di = mdi->devs; di; di = di->next)
if (i == di->disk.raid_disk)
@@ -796,7 +782,7 @@ static void handle_message(struct supertype *container, struct metadata_update *
manage(mdstat, container);
free_mdstat(mdstat);
} else if (!sigterm) {
- mu = malloc(sizeof(*mu));
+ mu = xmalloc(sizeof(*mu));
mu->len = msg->len;
mu->buf = msg->buf;
msg->buf = NULL;