From: Davidlohr Bueso <dave@gnu.org>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: [PATCH] swapon: use xalloc lib
Date: Tue, 19 Jul 2011 19:17:55 -0400 [thread overview]
Message-ID: <1311117475.3215.5.camel@offbook> (raw)
From: Davidlohr Bueso <dave@gnu.org>
Date: Mon, 18 Jul 2011 00:33:20 -0400
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
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
next reply other threads:[~2011-07-19 23:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-19 23:17 Davidlohr Bueso [this message]
2011-07-21 16:54 ` [PATCH] swapon: use xalloc lib Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1311117475.3215.5.camel@offbook \
--to=dave@gnu.org \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox