summaryrefslogtreecommitdiff
path: root/e2fsprogs/ext2fs/finddev.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/ext2fs/finddev.c')
-rw-r--r--e2fsprogs/ext2fs/finddev.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/e2fsprogs/ext2fs/finddev.c b/e2fsprogs/ext2fs/finddev.c
index fa2cadd..c459c08 100644
--- a/e2fsprogs/ext2fs/finddev.c
+++ b/e2fsprogs/ext2fs/finddev.c
@@ -46,14 +46,8 @@ static void add_to_dirlist(const char *name, struct dir_list **list)
{
struct dir_list *dp;
- dp = malloc(sizeof(struct dir_list));
- if (!dp)
- return;
- dp->name = malloc(strlen(name)+1);
- if (!dp->name) {
- free(dp);
- return;
- }
+ dp = xmalloc(sizeof(struct dir_list));
+ dp->name = xmalloc(strlen(name)+1);
strcpy(dp->name, name);
dp->next = *list;
*list = dp;
@@ -100,11 +94,7 @@ static int scan_dir(char *dir_name, dev_t device, struct dir_list **list,
if (S_ISDIR(st.st_mode))
add_to_dirlist(path, list);
if (S_ISBLK(st.st_mode) && st.st_rdev == device) {
- cp = malloc(strlen(path)+1);
- if (!cp) {
- closedir(dir);
- return ENOMEM;
- }
+ cp = xmalloc(strlen(path)+1);
strcpy(cp, path);
*ret_path = cp;
goto success;