diff options
author | NeilBrown <neilb@suse.de> | 2012-07-09 09:14:16 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-07-09 09:14:16 +0200 |
commit | 503975b9d5f0696b5d2ee20ea903b859e3f60662 (patch) | |
tree | 171c9f9b9db109325fad7f81ba07671d84a085a5 /Detail.c | |
parent | Remove re_add flag in favour of new disposition. (diff) | |
download | mdadm-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 'Detail.c')
-rw-r--r-- | Detail.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -146,7 +146,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost, char *pre if (subarray) info = st->ss->container_content(st, subarray); else { - info = malloc(sizeof(*info)); + info = xmalloc(sizeof(*info)); st->ss->getinfo_super(st, info, NULL); } if (!info) @@ -226,7 +226,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost, char *pre goto out; } - disks = malloc(max_disks * sizeof(mdu_disk_info_t)); + disks = xmalloc(max_disks * sizeof(mdu_disk_info_t)); for (d=0; d<max_disks; d++) { disks[d].state = (1<<MD_DISK_REMOVED); disks[d].major = disks[d].minor = 0; @@ -251,7 +251,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost, char *pre disks[next++] = disk; } - avail = calloc(array.raid_disks, 1); + avail = xcalloc(array.raid_disks, 1); for (d= 0; d < array.raid_disks; d++) { mdu_disk_info_t disk = disks[d]; @@ -574,11 +574,11 @@ This is pretty boring if ((dv=map_dev_preferred(disk.major, disk.minor, 0, prefer))) { if (brief) { if (devices) { - devices = realloc(devices, + devices = xrealloc(devices, strlen(devices)+1+strlen(dv)+1); strcat(strcat(devices,","),dv); } else - devices = strdup(dv); + devices = xstrdup(dv); } else printf(" %s", dv); } |