summaryrefslogtreecommitdiff
path: root/Incremental.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 /Incremental.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 'Incremental.c')
-rw-r--r--Incremental.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/Incremental.c b/Incremental.c
index 833eac7e..44d5c7c2 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -657,15 +657,11 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
st->ss->getinfo_super(st, &info, devmap + raid_disks * devnum);
if (!avail) {
raid_disks = info.array.raid_disks;
- avail = calloc(raid_disks, 1);
- if (!avail) {
- pr_err("out of memory.\n");
- exit(1);
- }
+ avail = xcalloc(raid_disks, 1);
*availp = avail;
- best = calloc(raid_disks, sizeof(int));
- devmap = calloc(raid_disks * numdevs, 1);
+ best = xcalloc(raid_disks, sizeof(int));
+ devmap = xcalloc(raid_disks, numdevs);
st->ss->getinfo_super(st, &info, devmap);
}