From: Davidlohr Bueso Date: Mon, 18 Jul 2011 04:33:20 +0000 (-0400) Subject: swapon: use xalloc lib X-Git-Tag: v2.20-rc1~52 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bfbb12d24b77bc36a1c3adb5eefb633e08a5d0de;p=thirdparty%2Futil-linux.git swapon: use xalloc lib Signed-off-by: Davidlohr Bueso --- diff --git a/mount/swapon.c b/mount/swapon.c index 49771f5d76..8dd9222486 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -24,6 +24,7 @@ #include "swapheader.h" #include "mangle.h" #include "canonicalize.h" +#include "xalloc.h" #include "c.h" #define PATH_MKSWAP "/sbin/mkswap" @@ -341,9 +342,7 @@ swap_get_header(int fd, int *sig, unsigned int *pagesize) *pagesize = 0; *sig = 0; - buf = malloc(MAX_PAGESIZE); - if (!buf) - return NULL; + buf = xmalloc(MAX_PAGESIZE); datasz = read(fd, buf, MAX_PAGESIZE); if (datasz == (ssize_t) -1) @@ -658,16 +657,12 @@ static const char **ulist = NULL; static int ulct = 0; static void addl(const char *label) { - llist = (const char **) realloc(llist, (++llct) * sizeof(char *)); - if (!llist) - exit(EXIT_FAILURE); + llist = (const char **) xrealloc(llist, (++llct) * sizeof(char *)); llist[llct-1] = label; } static void addu(const char *uuid) { - ulist = (const char **) realloc(ulist, (++ulct) * sizeof(char *)); - if (!ulist) - exit(EXIT_FAILURE); + ulist = (const char **) xrealloc(ulist, (++ulct) * sizeof(char *)); ulist[ulct-1] = uuid; }