summaryrefslogtreecommitdiff
path: root/Create.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 /Create.c
parentc8e1a230b73c44aff5beeeb74d32e36219bed12d (diff)
downloadmdadm-503975b9d5f0696b5d2ee20ea903b859e3f60662.tar.gz
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 'Create.c')
-rw-r--r--Create.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/Create.c b/Create.c
index f150954..af09495 100644
--- a/Create.c
+++ b/Create.c
@@ -803,11 +803,7 @@ int Create(struct supertype *st, char *mddev,
}
}
- infos = malloc(sizeof(*infos) * total_slots);
- if (!infos) {
- pr_err("Unable to allocate memory\n");
- goto abort;
- }
+ infos = xmalloc(sizeof(*infos) * total_slots);
for (pass=1; pass <=2 ; pass++) {
struct mddev_dev *moved_disk = NULL; /* the disk that was moved out of the insert point */
@@ -931,7 +927,7 @@ int Create(struct supertype *st, char *mddev,
/* update parent container uuid */
if (me) {
- char *path = strdup(me->path);
+ char *path = xstrdup(me->path);
st->ss->getinfo_super(st, &info_new, NULL);
map_update(&map, st->container_dev,