diff options
author | Davidlohr Bueso | 2011-07-18 06:33:20 +0200 |
---|---|---|
committer | Karel Zak | 2011-07-21 17:49:05 +0200 |
commit | bfbb12d24b77bc36a1c3adb5eefb633e08a5d0de (patch) | |
tree | 800ec9c50d8e5936a52fcdbf751df80b60750611 /mount/swapon.c | |
parent | partx: get partition number with sysfs lib (diff) | |
download | kernel-qcow2-util-linux-bfbb12d24b77bc36a1c3adb5eefb633e08a5d0de.tar.gz kernel-qcow2-util-linux-bfbb12d24b77bc36a1c3adb5eefb633e08a5d0de.tar.xz kernel-qcow2-util-linux-bfbb12d24b77bc36a1c3adb5eefb633e08a5d0de.zip |
swapon: use xalloc lib
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'mount/swapon.c')
-rw-r--r-- | mount/swapon.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/mount/swapon.c b/mount/swapon.c index 49771f5d7..8dd922248 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; } |