Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/rpcgen Use errx when malloc fails, and also don't ca...
details: https://anonhg.NetBSD.org/src/rev/d3ad8356b1aa
branches: trunk
changeset: 338091:d3ad8356b1aa
user: dholland <dholland%NetBSD.org@localhost>
date: Sat May 09 23:16:51 2015 +0000
description:
Use errx when malloc fails, and also don't cast the return value of
malloc/realloc.
diffstat:
usr.bin/rpcgen/rpc_cout.c | 13 ++++++-------
usr.bin/rpcgen/rpc_util.c | 10 ++++------
2 files changed, 10 insertions(+), 13 deletions(-)
diffs (80 lines):
diff -r 69fe8876d499 -r d3ad8356b1aa usr.bin/rpcgen/rpc_cout.c
--- a/usr.bin/rpcgen/rpc_cout.c Sat May 09 23:14:22 2015 +0000
+++ b/usr.bin/rpcgen/rpc_cout.c Sat May 09 23:16:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_cout.c,v 1.35 2015/05/09 23:14:22 dholland Exp $ */
+/* $NetBSD: rpc_cout.c,v 1.36 2015/05/09 23:16:51 dholland Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_cout.c,v 1.35 2015/05/09 23:14:22 dholland Exp $");
+__RCSID("$NetBSD: rpc_cout.c,v 1.36 2015/05/09 23:16:51 dholland Exp $");
#endif
#endif
@@ -476,7 +476,7 @@
else {
char *nsizestr;
- nsizestr = (char *) realloc(sizestr, strlen(sizestr) + strlen(ptemp) + 1);
+ nsizestr = realloc(sizestr, strlen(sizestr) + strlen(ptemp) + 1);
if (nsizestr == NULL) {
errx(EXIT_FAILURE, "Out of memory");
@@ -711,11 +711,10 @@
char *ptr, *hptr;
- ptr = (char *) malloc(strlen(str) + 1);
+ ptr = malloc(strlen(str) + 1);
if (ptr == NULL) {
- f_print(stderr, "malloc failed\n");
- exit(1);
- };
+ errx(EXIT_FAILURE, "Out of memory");
+ }
hptr = ptr;
while (*str != '\0')
diff -r 69fe8876d499 -r d3ad8356b1aa usr.bin/rpcgen/rpc_util.c
--- a/usr.bin/rpcgen/rpc_util.c Sat May 09 23:14:22 2015 +0000
+++ b/usr.bin/rpcgen/rpc_util.c Sat May 09 23:16:51 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rpc_util.c,v 1.15 2015/05/09 23:12:57 dholland Exp $ */
+/* $NetBSD: rpc_util.c,v 1.16 2015/05/09 23:16:51 dholland Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI";
#else
-__RCSID("$NetBSD: rpc_util.c,v 1.15 2015/05/09 23:12:57 dholland Exp $");
+__RCSID("$NetBSD: rpc_util.c,v 1.16 2015/05/09 23:16:51 dholland Exp $");
#endif
#endif
@@ -432,8 +432,7 @@
len = strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3;
name = malloc(len);
if (!name) {
- fprintf(stderr, "failed in malloc");
- exit(1);
+ errx(EXIT_FAILURE, "Out of memory");
}
snprintf(name, len, "%s_%s_%s", locase(pname), vname, ARGEXT);
return (name);
@@ -448,8 +447,7 @@
bas_type *ptr;
if ((ptr = malloc(sizeof(bas_type))) == NULL) {
- fprintf(stderr, "failed in malloc");
- exit(1);
+ errx(EXIT_FAILURE, "Out of memory");
}
ptr->name = type;
ptr->length = len;
Home |
Main Index |
Thread Index |
Old Index