From 89ead069f9019557b60a5a3472074277c043af1e Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Mon, 29 Jan 2018 18:11:01 +0100 Subject: [PATCH] util_list: Use util_malloc() for util_list_new() Since now util_list_new() internally fails for out-of-memory situations, we can also remove some NULL pointer checks. Signed-off-by: Michael Holzheu --- libutil/util_list.c | 5 ++--- libzds/libzds.c | 16 ---------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/libutil/util_list.c b/libutil/util_list.c index d90585de..1361a1a9 100644 --- a/libutil/util_list.c +++ b/libutil/util_list.c @@ -13,6 +13,7 @@ #include #include +#include "lib/util_libc.h" #include "lib/util_list.h" /* @@ -45,10 +46,8 @@ void util_list_init_offset(struct util_list *list, unsigned long offset) */ struct util_list *util_list_new_offset(unsigned long offset) { - struct util_list *list = malloc(sizeof(*list)); + struct util_list *list = util_malloc(sizeof(*list)); - if (!list) - return NULL; util_list_init_offset(list, offset); return list; } diff --git a/libzds/libzds.c b/libzds/libzds.c index e2041793..2430962e 100644 --- a/libzds/libzds.c +++ b/libzds/libzds.c @@ -405,17 +405,7 @@ int lzds_zdsroot_alloc(struct zdsroot **root) memset(tmproot, 0, sizeof(*tmproot)); tmproot->dasdlist = util_list_new(struct dasd, list); - if (!tmproot->dasdlist) { - free(tmproot); - return ENOMEM; - } - tmproot->datasetlist = util_list_new(struct dataset, list); - if (!tmproot->dasdlist) { - util_list_free(tmproot->dasdlist); - free(tmproot); - return ENOMEM; - } *root = tmproot; @@ -804,10 +794,6 @@ static int errorlog_alloc(struct errorlog **log) return ENOMEM; memset(tmplog, 0, sizeof(*tmplog)); tmplog->entries = util_list_new(struct errormsg, list); - if (!tmplog->entries) { - free(tmplog); - return ENOMEM; - } *log = tmplog; return 0; } @@ -2185,8 +2171,6 @@ static int dataset_member_analysis(struct dataset *ds) dataset_free_memberlist(ds); ds->memberlist = util_list_new(struct pdsmember, list); - if (!ds->memberlist) - return ENOMEM; /* track buffer must be page aligned for O_DIRECT */ trackdata = memalign(4096, RAWTRACKSIZE);