diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-06-05 18:11:25 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-06-05 18:11:25 +0000 |
commit | e24090eb3a797e5f9a03d68354396bb36afd28f2 (patch) | |
tree | 47d7bd53bf4aaac82ddc54b2e48f0c474d954661 /bin/ps/ps.c | |
parent | e11700e21ef6e32612bde060eef8120b23330acf (diff) | |
download | FreeBSD-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/ps/ps.c')
-rw-r--r-- | bin/ps/ps.c | 10 |
1 files changed, 4 insertions, 6 deletions
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 '-' */ |