From b8bbd73bb5bd0b1f5f2c6a3441486d69a45cc79c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 1 Oct 2010 13:13:10 -0400 Subject: libmtd: make malloc failures fatal This converts libmtd to the common xalloc helpers and in doing so, makes memory allocation failures fatal rather than returning an error to the caller. I think this is acceptable behavior. Signed-off-by: Mike Frysinger Signed-off-by: Artem Bityutskiy --- lib/libmtd_legacy.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lib/libmtd_legacy.c') diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c index 3d129c1..7488275 100644 --- a/lib/libmtd_legacy.c +++ b/lib/libmtd_legacy.c @@ -75,12 +75,7 @@ static int proc_parse_start(struct proc_parse_info *pi) if (fd == -1) return -1; - pi->buf = malloc(PROC_MTD_MAX_LEN); - if (!pi->buf) { - sys_errmsg("cannot allocate %d bytes of memory", - PROC_MTD_MAX_LEN); - goto out_close; - } + pi->buf = xmalloc(PROC_MTD_MAX_LEN); ret = read(fd, pi->buf, PROC_MTD_MAX_LEN); if (ret == -1) { @@ -103,7 +98,6 @@ static int proc_parse_start(struct proc_parse_info *pi) out_free: free(pi->buf); -out_close: close(fd); return -1; } -- cgit v1.2.3