summaryrefslogtreecommitdiff
path: root/super0.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-07-09 17:14:16 +1000
committerNeilBrown <neilb@suse.de>2012-07-09 17:14:16 +1000
commit503975b9d5f0696b5d2ee20ea903b859e3f60662 (patch)
tree171c9f9b9db109325fad7f81ba07671d84a085a5 /super0.c
parentc8e1a230b73c44aff5beeeb74d32e36219bed12d (diff)
Remove scattered checks for malloc success.
malloc should never fail, and if it does it is unlikely that anything else useful can be done. Best approach is to abort and let some super-daemon restart. So define xmalloc, xcalloc, xrealloc, xstrdup which don't fail but just print a message and exit. Then use those removing all the tests for failure. Also replace all "malloc;memset" sequences with 'xcalloc'. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super0.c')
-rw-r--r--super0.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/super0.c b/super0.c
index c8cbb9d9..55e71e8c 100644
--- a/super0.c
+++ b/super0.c
@@ -418,7 +418,7 @@ static struct mdinfo *container_content0(struct supertype *st, char *subarray)
if (subarray)
return NULL;
- info = malloc(sizeof(*info));
+ info = xmalloc(sizeof(*info));
getinfo_super0(st, info, NULL);
return info;
}
@@ -710,7 +710,7 @@ static int add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo,
dip = (struct devinfo **)&st->info;
while (*dip)
dip = &(*dip)->next;
- di = malloc(sizeof(struct devinfo));
+ di = xmalloc(sizeof(struct devinfo));
di->fd = fd;
di->devname = devname;
di->disk = *dinfo;
@@ -942,9 +942,7 @@ static int load_super0(struct supertype *st, int fd, char *devname)
static struct supertype *match_metadata_desc0(char *arg)
{
- struct supertype *st = calloc(1, sizeof(*st));
- if (!st)
- return st;
+ struct supertype *st = xcalloc(1, sizeof(*st));
st->container_dev = NoMdDev;
st->ss = &super0;