summaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/dmesg.c2
-rw-r--r--util-linux/fsck_minix.c35
-rw-r--r--util-linux/mkfs_minix.c10
-rw-r--r--util-linux/mkswap.c6
-rw-r--r--util-linux/umount.c3
5 files changed, 15 insertions, 41 deletions
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index bbed822..2bbf43a 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -95,7 +95,7 @@ int dmesg_main(int argc, char **argv)
if (bufsize < 4096)
bufsize = 4096;
- buf = (char *) malloc(bufsize);
+ buf = (char *) xmalloc(bufsize);
n = klogctl(cmd, buf, bufsize);
if (n < 0) {
goto klogctl_error;
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index cfa973e..47e81ce 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -603,23 +603,13 @@ static void read_superblock(void)
static void read_tables(void)
{
- inode_map = malloc(IMAPS * BLOCK_SIZE);
- if (!inode_map)
- die("Unable to allocate buffer for inode map");
- zone_map = malloc(ZMAPS * BLOCK_SIZE);
- if (!inode_map)
- die("Unable to allocate buffer for zone map");
+ inode_map = xmalloc(IMAPS * BLOCK_SIZE);
+ zone_map = xmalloc(ZMAPS * BLOCK_SIZE);
memset(inode_map, 0, sizeof(inode_map));
memset(zone_map, 0, sizeof(zone_map));
- inode_buffer = malloc(INODE_BUFFER_SIZE);
- if (!inode_buffer)
- die("Unable to allocate buffer for inodes");
- inode_count = malloc(INODES + 1);
- if (!inode_count)
- die("Unable to allocate buffer for inode count");
- zone_count = malloc(ZONES);
- if (!zone_count)
- die("Unable to allocate buffer for zone count");
+ inode_buffer = xmalloc(INODE_BUFFER_SIZE);
+ inode_count = xmalloc(INODES + 1);
+ zone_count = xmalloc(ZONES);
if (IMAPS * BLOCK_SIZE != read(IN, inode_map, IMAPS * BLOCK_SIZE))
die("Unable to read inode map");
if (ZMAPS * BLOCK_SIZE != read(IN, zone_map, ZMAPS * BLOCK_SIZE))
@@ -1247,18 +1237,9 @@ static void alloc_name_list(void)
{
int i;
- name_list = malloc(sizeof(char *) * MAX_DEPTH);
- if (!name_list) {
- fprintf(stderr,"fsck_minix: name_list: %s\n", strerror(errno));
- exit(1);
- }
- for (i = 0; i < MAX_DEPTH; i++) {
- name_list[i] = malloc(sizeof(char) * PATH_MAX + 1);
- if (!name_list[i]) {
- fprintf(stderr,"fsck_minix: name_list: %s\n", strerror(errno));
- exit(1);
- }
- }
+ name_list = xmalloc(sizeof(char *) * MAX_DEPTH);
+ for (i = 0; i < MAX_DEPTH; i++)
+ name_list[i] = xmalloc(sizeof(char) * PATH_MAX + 1);
}
/* execute this atexit() to deallocate name_list[] */
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 4435cb6..1ee3d4c 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -530,19 +530,15 @@ static void setup_tables(void)
die("unable to allocate buffers for maps");
}
FIRSTZONE = NORM_FIRSTZONE;
- inode_map = malloc(IMAPS * BLOCK_SIZE);
- zone_map = malloc(ZMAPS * BLOCK_SIZE);
- if (!inode_map || !zone_map)
- die("unable to allocate buffers for maps");
+ inode_map = xmalloc(IMAPS * BLOCK_SIZE);
+ zone_map = xmalloc(ZMAPS * BLOCK_SIZE);
memset(inode_map, 0xff, IMAPS * BLOCK_SIZE);
memset(zone_map, 0xff, ZMAPS * BLOCK_SIZE);
for (i = FIRSTZONE; i < ZONES; i++)
unmark_zone(i);
for (i = MINIX_ROOT_INO; i <= INODES; i++)
unmark_inode(i);
- inode_buffer = malloc(INODE_BUFFER_SIZE);
- if (!inode_buffer)
- die("unable to allocate buffer for inodes");
+ inode_buffer = xmalloc(INODE_BUFFER_SIZE);
memset(inode_buffer, 0, INODE_BUFFER_SIZE);
printf("%ld inodes\n", INODES);
printf("%ld blocks\n", ZONES);
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index 130d241..17866a7 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -116,7 +116,7 @@ static void init_signature_page()
if (pagesize != PAGE_SIZE)
fprintf(stderr, "Assuming pages of size %d\n", pagesize);
#endif
- signature_page = (int *) malloc(pagesize);
+ signature_page = (int *) xmalloc(pagesize);
memset(signature_page, 0, pagesize);
p = (struct swap_header_v1 *) signature_page;
}
@@ -230,9 +230,7 @@ void check_blocks(void)
int do_seek = 1;
char *buffer;
- buffer = malloc(pagesize);
- if (!buffer)
- die("Out of memory");
+ buffer = xmalloc(pagesize);
current_page = 0;
while (current_page < PAGES) {
if (!check) {
diff --git a/util-linux/umount.c b/util-linux/umount.c
index b0f393c..6661db8 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -89,8 +89,7 @@ void mtab_read(void)
return;
}
while ((e = getmntent(fp))) {
- entry = malloc(sizeof(struct _mtab_entry_t));
-
+ entry = xmalloc(sizeof(struct _mtab_entry_t));
entry->device = strdup(e->mnt_fsname);
entry->mountpt = strdup(e->mnt_dir);
entry->next = mtab_cache;