summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-06-05 18:11:25 +0000
committerjmallett <jmallett@FreeBSD.org>2002-06-05 18:11:25 +0000
commite24090eb3a797e5f9a03d68354396bb36afd28f2 (patch)
tree47d7bd53bf4aaac82ddc54b2e48f0c474d954661 /bin
parente11700e21ef6e32612bde060eef8120b23330acf (diff)
downloadFreeBSD-src-e24090eb3a797e5f9a03d68354396bb36afd28f2.zip
FreeBSD-src-e24090eb3a797e5f9a03d68354396bb36afd28f2.tar.gz
Widen the scope of fmt.c::1.19 and consistently use errx(3) if malloc(3) [or
realloc(3)] happens to fail, everywhere in ps(1). Discussed with: bde, charnier (a while ago) fmt_argv() can no longer return NULL, so don't bother checking. Submitted by: bde
Diffstat (limited to 'bin')
-rw-r--r--bin/ps/keyword.c4
-rw-r--r--bin/ps/print.c4
-rw-r--r--bin/ps/ps.c10
3 files changed, 8 insertions, 10 deletions
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index f5724e0..8616757 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -247,10 +247,10 @@ parsefmt(const char *p)
if (cp == NULL || !(v = findvar(cp)))
continue;
if ((vent = malloc(sizeof(struct varent))) == NULL)
- err(1, NULL);
+ errx(1, "malloc failed");
vent->var = malloc(sizeof(*vent->var));
if (vent->var == NULL)
- err(1, NULL);
+ errx(1, "malloc failed");
memcpy(vent->var, v, sizeof(*vent->var));
vent->next = NULL;
if (vhead == NULL)
diff --git a/bin/ps/print.c b/bin/ps/print.c
index fefb005..f885770 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -108,11 +108,11 @@ command(KINFO *k, VARENT *ve)
}
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
- err(1, NULL);
+ errx(1, "malloc failed");
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
if (k->ki_env) {
if ((vis_env = malloc(strlen(k->ki_env) * 4 + 1)) == NULL)
- err(1, NULL);
+ errx(1, "malloc failed");
strvis(vis_env, k->ki_env, VIS_TAB | VIS_NL | VIS_NOSLASH);
} else
vis_env = NULL;
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index c6da58e..2a25c92 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -311,7 +311,7 @@ main(int argc, char *argv[])
/* XXX - should be cleaner */
if (!all && ttydev == NODEV && pid == -1 && !nuids) {
if ((uids = malloc(sizeof (*uids))) == NULL)
- err(1, "malloc");
+ errx(1, "malloc failed");
nuids = 1;
*uids = getuid();
}
@@ -343,7 +343,7 @@ main(int argc, char *argv[])
if ((kp = kvm_getprocs(kd, what, flag, &nentries)) == 0 || nentries < 0)
errx(1, "%s", kvm_geterr(kd));
if ((kinfo = malloc(nentries * sizeof(*kinfo))) == NULL)
- err(1, NULL);
+ errx(1, "malloc failed");
for (i = nentries; --i >= 0; ++kp) {
kinfo[i].ki_p = kp;
if (needuser)
@@ -424,7 +424,7 @@ getuids(const char *arg, int *nuids)
moreuids = realloc(uids, alloc * sizeof (*uids));
if (moreuids == NULL) {
free(uids);
- err(1, "realloc");
+ errx(1, "realloc failed");
}
uids = moreuids;
}
@@ -500,8 +500,6 @@ fmt(char **(*fn)(kvm_t *, const struct kinfo_proc *, int), KINFO *ki,
const char *s;
s = fmt_argv((*fn)(kd, ki->ki_p, termwidth), comm, maxlen);
- if (s == NULL)
- err(1, NULL);
return (s);
}
@@ -578,7 +576,7 @@ kludge_oldps_options(char *s)
len = strlen(s);
if ((newopts = ns = malloc(len + 2)) == NULL)
- err(1, NULL);
+ errx(1, "malloc failed");
/*
* options begin with '-'
*/
OpenPOWER on IntegriCloud