summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fdisk/sfdisk.c6
-rw-r--r--misc-utils/findmnt.c8
-rw-r--r--sys-utils/swapon.c6
-rwxr-xr-xtools/checkxalloc.sh2
4 files changed, 6 insertions, 16 deletions
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index f549c6413..a090772a8 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -305,10 +305,8 @@ restore_sectors(char *dev) {
error(_("partition restore file has wrong size - not restoring\n"));
goto err;
}
- if (!(ss0 = (char *)malloc(statbuf.st_size))) {
- error(_("out of memory?\n"));
- goto err;
- }
+
+ ss0 = xmalloc(statbuf.st_size);
ss = ss0;
fdin = open(restore_sector_file, O_RDONLY);
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 2df79a4cb..f80038144 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -497,13 +497,7 @@ static int parser_errcb(struct libmnt_table *tb __attribute__ ((__unused__)),
static char **append_tabfile(char **files, int *nfiles, char *filename)
{
- void *tmp = realloc(files, sizeof(char *) * (*nfiles + 1));
-
- if (!tmp) {
- free(files);
- return NULL;
- }
- files = tmp;
+ files = xrealloc(files, sizeof(char *) * (*nfiles + 1));
files[(*nfiles)++] = filename;
return files;
}
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index f17fad65b..02e4a26d1 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -197,9 +197,7 @@ read_proc_swaps(void) {
*p = '\0';
}
- q = realloc(swapFiles, (numSwaps+1) * sizeof(*swapFiles));
- if (q == NULL)
- break;
+ q = xrealloc(swapFiles, (numSwaps+1) * sizeof(*swapFiles));
swapFiles = q;
if ((p = unmangle(line, NULL)) == NULL)
@@ -640,7 +638,7 @@ swapon_all(void) {
if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
continue;
- opts = strdup(fstab->mnt_opts);
+ opts = xstrdup(fstab->mnt_opts);
for (opt = strtok(opts, ","); opt != NULL;
opt = strtok(NULL, ",")) {
diff --git a/tools/checkxalloc.sh b/tools/checkxalloc.sh
index c507777db..3c342545f 100755
--- a/tools/checkxalloc.sh
+++ b/tools/checkxalloc.sh
@@ -10,7 +10,7 @@ cd "$(git rev-parse --show-toplevel)" || {
}
git grep -zl '#include "xalloc.h"' |
- xargs -0 grep -nwE '[^x](([cm]|re)alloc|strdup|asprintf)\('
+ xargs -0 grep -nE '\b(([cm]|re)alloc|strdup|asprintf)[[:space:]]*\([^)]'
result=$?