summaryrefslogtreecommitdiffhomepage
path: root/e2fsprogs/ext2fs/finddev.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-06-12 00:45:09 +0000
committerMike Frysinger <vapier@gentoo.org>2005-06-12 00:45:09 +0000
commitd5826903c171981d967dc6a8c430dfaaed05c53a (patch)
treee60fa099cc881ef65c0ac4115b91b0874a5d781d /e2fsprogs/ext2fs/finddev.c
parent7fde8debc450c19927b82e3434fc5d6a6dd4d35d (diff)
use xmalloc instead of malloc
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 fa2cadde4..c459c0833 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;