svn commit: r227873 - head/usr.bin/procstat
mdf at FreeBSD.org
mdf at FreeBSD.org
Wed Nov 23 19:10:49 UTC 2011
On Tue, Nov 22, 2011 at 11:34 PM, Mikolaj Golub <trociny at freebsd.org> wrote:
> Author: trociny
> Date: Wed Nov 23 07:34:09 2011
> New Revision: 227873
> URL: http://svn.freebsd.org/changeset/base/227873
>
> Log:
> Fix build, hopefully.
>
> Reviewed by: kib
>
> Modified:
> head/usr.bin/procstat/procstat_auxv.c
>
> Modified: head/usr.bin/procstat/procstat_auxv.c
> ==============================================================================
> --- head/usr.bin/procstat/procstat_auxv.c Wed Nov 23 07:12:26 2011 (r227872)
> +++ head/usr.bin/procstat/procstat_auxv.c Wed Nov 23 07:34:09 2011 (r227873)
> @@ -42,14 +42,13 @@
>
> #include "procstat.h"
>
> -static char auxv[sizeof(Elf_Auxinfo) * 256];
> +static Elf_Auxinfo auxv[256];
>
> void
> procstat_auxv(struct kinfo_proc *kipp)
> {
> - Elf_Auxinfo *aux;
> - int i, error, name[4];
> - size_t len;
> + int error, name[4];
> + size_t len, i;
>
> if (!hflag)
> printf("%5s %-16s %-53s\n", "PID", "COMM", "AUXV");
> @@ -58,7 +57,7 @@ procstat_auxv(struct kinfo_proc *kipp)
> name[1] = KERN_PROC;
> name[2] = KERN_PROC_AUXV;
> name[3] = kipp->ki_pid;
> - len = sizeof(auxv);
> + len = sizeof(auxv) * sizeof(*auxv);
> error = sysctl(name, 4, auxv, &len, NULL, 0);
> if (error < 0 && errno != ESRCH) {
> warn("sysctl: kern.proc.auxv: %d: %d", kipp->ki_pid, errno);
> @@ -72,106 +71,116 @@ procstat_auxv(struct kinfo_proc *kipp)
> printf(" -\n");
> return;
> }
> - for (aux = (Elf_Auxinfo *)auxv, i = 0; i < 256; i++, aux++) {
> - switch(aux->a_type) {
> + for (i = 0; i < len; i++) {
> + switch(auxv[i].a_type) {
> case AT_NULL:
> - printf(" (%d)\n", i + 1);
> + printf(" (%zu)\n", i + 1);
> return;
> case AT_IGNORE:
> printf(" AT_IGNORE=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
I didn't see this before, but this gives very misleading output. The
0x prefix implies the output will be hex, but it's printed as decimal,
here and below.
I don't know if there's a style preference for 0x%lx versus %#lx,
though, or a preference for a different type for the print (uintmax_t,
for example). There is probably a preference for using u_long rather
than unsigned long, since it's shorter.
Thanks,
matthew
> break;
> case AT_EXECFD:
> printf(" AT_EXECFD=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_PHDR:
> printf(" AT_PHDR=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_PHENT:
> printf(" AT_PHENT=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_PHNUM:
> printf(" AT_PHNUM=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_PAGESZ:
> printf(" AT_PAGESZ=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_BASE:
> printf(" AT_BASE=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_FLAGS:
> printf(" AT_FLAGS=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_ENTRY:
> printf(" AT_ENTRY=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> +#ifdef AT_NOTELF
> case AT_NOTELF:
> printf(" AT_NOTELF=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> +#endif
> +#ifdef AT_UID
> case AT_UID:
> printf(" AT_UID=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> +#endif
> +#ifdef AT_EUID
> case AT_EUID:
> printf(" AT_EUID=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> +#endif
> +#ifdef AT_GID
> case AT_GID:
> printf(" AT_GID=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> +#endif
> +#ifdef AT_EGID
> case AT_EGID:
> printf(" AT_EGID=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> +#endif
> case AT_EXECPATH:
> printf(" AT_EXECPATH=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_CANARY:
> printf(" AT_CANARY=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_CANARYLEN:
> printf(" AT_CANARYLEN=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_OSRELDATE:
> printf(" AT_OSRELDATE=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_NCPUS:
> printf(" AT_NCPUS=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_PAGESIZES:
> printf(" AT_PAGESIZES=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_PAGESIZESLEN:
> printf(" AT_PAGESIZESLEN=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_STACKPROT:
> printf(" AT_STACKPROT=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> case AT_COUNT:
> printf(" AT_COUNT=0x%lu",
> - (unsigned long)aux->a_un.a_val);
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> default:
> - printf(" %ld=0x%lu", (long)aux->a_type,
> - (unsigned long)aux->a_un.a_val);
> + printf(" %ld=0x%lu", (long)auxv[i].a_type,
> + (unsigned long)auxv[i].a_un.a_val);
> break;
> }
> }
>
More information about the svn-src-all
mailing list