Module Name: src
Committed By: christos
Date: Wed Mar 9 20:02:33 UTC 2016
Modified Files:
src/usr.bin/infocmp: Makefile infocmp.c
Log Message:
PR/50932: David Binderman: use emalloc/erealloc/ecalloc
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/infocmp/Makefile
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/infocmp/infocmp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/infocmp/Makefile
diff -u src/usr.bin/infocmp/Makefile:1.2 src/usr.bin/infocmp/Makefile:1.3
--- src/usr.bin/infocmp/Makefile:1.2 Sun Aug 11 02:48:46 2013
+++ src/usr.bin/infocmp/Makefile Wed Mar 9 15:02:33 2016
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.2 2013/08/11 06:48:46 dholland Exp $
+# $NetBSD: Makefile,v 1.3 2016/03/09 20:02:33 christos Exp $
PROG= infocmp
CPPFLAGS+= -I${.CURDIR}/../../lib/libterminfo
-LDADD+= -lterminfo
-DPADD+= ${LIBTERMINFO}
+LDADD+= -lterminfo -lutil
+DPADD+= ${LIBTERMINFO} ${LIBUTIL}
.include <bsd.prog.mk>
Index: src/usr.bin/infocmp/infocmp.c
diff -u src/usr.bin/infocmp/infocmp.c:1.9 src/usr.bin/infocmp/infocmp.c:1.10
--- src/usr.bin/infocmp/infocmp.c:1.9 Wed Feb 24 08:31:54 2016
+++ src/usr.bin/infocmp/infocmp.c Wed Mar 9 15:02:33 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: infocmp.c,v 1.9 2016/02/24 13:31:54 roy Exp $ */
+/* $NetBSD: infocmp.c,v 1.10 2016/03/09 20:02:33 christos Exp $ */
/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: infocmp.c,v 1.9 2016/02/24 13:31:54 roy Exp $");
+__RCSID("$NetBSD: infocmp.c,v 1.10 2016/03/09 20:02:33 christos Exp $");
#include <sys/ioctl.h>
@@ -40,6 +40,7 @@ __RCSID("$NetBSD: infocmp.c,v 1.9 2016/0
#include <term_private.h>
#include <term.h>
#include <unistd.h>
+#include <util.h>
#define SW 8
@@ -180,7 +181,7 @@ print_ent(const TIENT *ents, size_t nent
l = strlen(ents[i].id) + 3;
break;
default:
- errx(1, "invalid type");
+ errx(EXIT_FAILURE, "invalid type");
}
if (col != SW) {
if (col + l > cols) {
@@ -431,9 +432,7 @@ load_term(const char *name)
{
TERMINAL *t;
- t = calloc(1, sizeof(*t));
- if (t == NULL)
- err(1, "calloc");
+ t = ecalloc(1, sizeof(*t));
if (name == NULL)
name = getenv("TERM");
if (name == NULL)
@@ -442,9 +441,9 @@ load_term(const char *name)
return t;
if (_ti_database == NULL)
- errx(1, "no terminal definition found in internal database");
+ errx(EXIT_FAILURE, "no terminal definition found in internal database");
else
- errx(1, "no terminal definition found in %s.db", _ti_database);
+ errx(EXIT_FAILURE, "no terminal definition found in %s.db", _ti_database);
}
static void
@@ -507,15 +506,13 @@ use_terms(TERMINAL *term, size_t nuse, c
TERMUSERDEF *ud, *tud;
size_t i, j, agree, absent, data;
- terms = malloc(sizeof(**terms) * nuse);
- if (terms == NULL)
- err(1, "malloc");
+ terms = ecalloc(nuse, sizeof(**terms));
for (i = 0; i < nuse; i++) {
if (strcmp(term->name, *uterms) == 0)
- errx(1, "cannot use same terminal");
+ errx(EXIT_FAILURE, "cannot use same terminal");
for (j = 0; j < i; j++)
if (strcmp(terms[j]->name, *uterms) == 0)
- errx(1, "cannot use same terminal");
+ errx(EXIT_FAILURE, "cannot use same terminal");
terms[i] = load_term(*uterms++);
}
@@ -628,10 +625,8 @@ use_terms(TERMINAL *term, size_t nuse, c
ud = find_userdef(term, terms[i]->_userdefs[j].id);
if (ud != NULL)
continue; /* We have handled this */
- term->_userdefs = realloc(term->_userdefs,
+ term->_userdefs = erealloc(term->_userdefs,
sizeof(*term->_userdefs) * (term->_nuserdefs + 1));
- if (term->_userdefs == NULL)
- err(1, "malloc");
tud = &term->_userdefs[term->_nuserdefs++];
tud->id = terms[i]->_userdefs[j].id;
tud->type = terms[i]->_userdefs[j].flag;