summaryrefslogtreecommitdiffstats
path: root/bitmap.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 /bitmap.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 'bitmap.c')
-rw-r--r--bitmap.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/bitmap.c b/bitmap.c
index 351f08a0..4144977b 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -138,18 +138,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
}
n = read(fd, buf, 8192);
- info = malloc(sizeof(*info));
- if (info == NULL) {
-#if __GNUC__ < 3
- pr_err("failed to allocate %d bytes\n",
- (int)sizeof(*info));
-#else
- pr_err("failed to allocate %zd bytes\n",
- sizeof(*info));
-#endif
- free(buf);
- return NULL;
- }
+ info = xmalloc(sizeof(*info));
if (n < sizeof(info->sb)) {
pr_err("failed to read superblock of bitmap "