]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapon: use xalloc lib
authorDavidlohr Bueso <dave@gnu.org>
Mon, 18 Jul 2011 04:33:20 +0000 (00:33 -0400)
committerKarel Zak <kzak@redhat.com>
Thu, 21 Jul 2011 15:49:05 +0000 (17:49 +0200)
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
mount/swapon.c

index 49771f5d7638ea30eee29413b82e4b176e5b5879..8dd9222486128810670902c1cbe054d82895180e 100644 (file)
@@ -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;
 }