summaryrefslogtreecommitdiffstats
path: root/usr.bin/last
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-05-17 05:11:07 +0000
committerjmallett <jmallett@FreeBSD.org>2002-05-17 05:11:07 +0000
commit0109c305458dc8e85d6497c140a58a9fce7df4f3 (patch)
treecf78d7652b64bccf0e61a4cef6f041a454a5bc4c /usr.bin/last
parent17aec9648900d65e6dc437b556bfd7a2789ad9b9 (diff)
downloadFreeBSD-src-0109c305458dc8e85d6497c140a58a9fce7df4f3.zip
FreeBSD-src-0109c305458dc8e85d6497c140a58a9fce7df4f3.tar.gz
Clean up malloc(3)'s argument. Remove casts which do nothing when we're
using sizeof() anyway. Use slightly more consistent (per-file) error reporting for malloc(3) returning NULL. If "malloc failed" was being printed, don't use err(3). If a NULL format is being used, use err(3). In one case errx(3) was being used with strerror(3), so just use err(3).
Diffstat (limited to 'usr.bin/last')
-rw-r--r--usr.bin/last/last.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index 5029a05..41e2492 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -290,7 +290,7 @@ doentry(bp)
/* add new one */
tt = malloc(sizeof(struct ttytab));
if (tt == NULL)
- err(1, "malloc failure");
+ errx(1, "malloc failure");
tt->logout = currentout;
strncpy(tt->tty, bp->ut_line, UT_LINESIZE);
LIST_INSERT_HEAD(&ttylist, tt, list);
@@ -418,8 +418,8 @@ addarg(type, arg)
{
ARG *cur;
- if (!(cur = (ARG *)malloc((u_int)sizeof(ARG))))
- err(1, "malloc failure");
+ if ((cur = malloc(sizeof(ARG))) == NULL)
+ errx(1, "malloc failure");
cur->next = arglist;
cur->type = type;
cur->name = arg;
@@ -468,8 +468,8 @@ ttyconv(arg)
*/
if (strlen(arg) == 2) {
/* either 6 for "ttyxx" or 8 for "console" */
- if (!(mval = malloc((u_int)8)))
- err(1, "malloc failure");
+ if ((mval = malloc(8)) == NULL)
+ errx(1, "malloc failure");
if (!strcmp(arg, "co"))
(void)strcpy(mval, "console");
else {
OpenPOWER on IntegriCloud