From d5826903c171981d967dc6a8c430dfaaed05c53a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 12 Jun 2005 00:45:09 +0000 Subject: use xmalloc instead of malloc --- e2fsprogs/ext2fs/finddev.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'e2fsprogs/ext2fs/finddev.c') 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; -- cgit v1.2.3