summaryrefslogtreecommitdiffstats
path: root/mdmon.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-07-09 09:14:16 +0200
committerNeilBrown <neilb@suse.de>2012-07-09 09:14:16 +0200
commit503975b9d5f0696b5d2ee20ea903b859e3f60662 (patch)
tree171c9f9b9db109325fad7f81ba07671d84a085a5 /mdmon.c
parentRemove re_add flag in favour of new disposition. (diff)
downloadmdadm-503975b9d5f0696b5d2ee20ea903b859e3f60662.tar.xz
mdadm-503975b9d5f0696b5d2ee20ea903b859e3f60662.zip
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 'mdmon.c')
-rw-r--r--mdmon.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mdmon.c b/mdmon.c
index dee02a9c..294cd72c 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -434,7 +434,7 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover)
} else
pfd[0] = pfd[1] = -1;
- container = calloc(1, sizeof(*container));
+ container = xcalloc(1, sizeof(*container));
container->devnum = devnum;
container->devname = devname;
container->arrays = NULL;
@@ -473,7 +473,7 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover)
container->devs = NULL;
for (di = mdi->devs; di; di = di->next) {
- struct mdinfo *cd = malloc(sizeof(*cd));
+ struct mdinfo *cd = xmalloc(sizeof(*cd));
*cd = *di;
cd->next = container->devs;
container->devs = cd;