Skip to contentSkip to conversation

swapon: use xalloc lib

PATCH Applied Davidlohr Bueso 2 participants 2 messages Jul 19, 2011 – Jul 21, 2011 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swapon: use xalloc lib

From: Davidlohr Bueso <[email protected]>
Date: Mon, 18 Jul 2011 00:33:20 -0400

---
 mount/swapon.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)
mount/swapon.c +5 -10
index 49771f5..6dfe4b1 100644
@@ -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;
 }
 
Signature · 1 line
1.7.4.1
maintainer Applied
#1 lore raw
Quoted 2 lines · Davidlohr Bueso
 mount/swapon.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com