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 <holzheu@linux.vnet.ibm.com>
This commit is contained in:
Michael Holzheu
2018-01-29 18:11:01 +01:00
parent 05de40cdeb
commit 89ead069f9
2 changed files with 2 additions and 19 deletions

View File

@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
#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;
}

View File

@@ -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);