[PATCH] swapon: use xalloc lib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Davidlohr Bueso <dave@xxxxxxx>
Date: Mon, 18 Jul 2011 00:33:20 -0400

Signed-off-by: Davidlohr Bueso <dave@xxxxxxx>
---
 mount/swapon.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/mount/swapon.c b/mount/swapon.c
index 49771f5..6dfe4b1 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,10 +342,8 @@ 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)
 		goto err;
@@ -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;
 }
 
-- 
1.7.4.1



--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux