The current header formatting is a giant format string that changes
global state during the format process.
Make the following changes:
- use sbuf to build up the header rather than use the above
pseudo-dynamic one
- Change name length to 10
- Reduce size of RES and SIZE by making humanize more aggressive
- Restore a version number line to the copyright. This may be required
by the copyright (and may not be; its unclear)
This is also a pre-req to implementing TOPCOLOR from newer versions of
top(1)
Discussed with: allanjude, rpolka, danfe, rgrimes
Differential Revision: https://reviews.freebsd.org/D15801
This eliminates the difficult to follow mapping of a string list. It
moves numbers from "#define" into (more) debuggable enums. More
generally, it follows the trend of moving more data into a more central
mechanism.
The help output is a little worse: " " is not rendered well, and there
are duplicate entries, but that will be fixed in a followup.
- By popular demand, implement a different switch ("T") for toggling
between thread id and process id.
- Add an assert that the size of command chars is as expected.
- Also clean up some messiness I found when implementing this.
- Further document the new flag.
Requested by: flo, ronald-lists@klop.ws, bapt
PR: 139389 (for the record)
X-MFC-With: r334474
- Change headers to more closely match what we use
- use more standard functions instead of bzero, bcmp, bcopy
- Add myself to authors.
Tested with: base clang (amd64), gcc 9 (amd64), base clang (i386), base
gcc (mips)
- use bool instead of int [0]
- use calloc correctly [0]
(this also caught an incorrect sizeof argument) [1]
- use size_t over int [2]
- correct style
Reported by: pfg [0], scan-build [1], gcc [2]
Allow to show only a single process specified by PID. This could
be done either by running top like 'top -p PID' or using the 'p' command
inside top.
Reviewed by: eadler
Approved by: eadler
Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D15501
- Prefer using ansi prototypes rather than C prototypes
- Keep type on separate line from name of function
- Try to keep things const where possible. This will help get to WARNS=6
- switch to "bool" where it makes sense
This leaves at WARNS=6:
35 warnings in top.c
88 warnings in machine.c
all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"
- Replace caddr_t with "void *". This reduces
the number of warnings at WARNS=6
- use "static" where possible
- sprinkle const where possible
This leaves at WARNS=6:
35 warnings in top.c
72 warnings in machine.c
5 warnings in commands.c
all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"
This is all warnings at level six (6) that are not
char-subscripts, incompatible-pointer-types,
sign-compare, switch, int-conversion,
missing-variable-declarations, cast-qual, cast-align
Some warnings that are fixed by this commit are:
shadow, strict-prototypes, missing-prototypes, pointer-arith,
unused-parameter, unused-const-variable, and several others
We've been maintaining top(1) for a long time, and the upstream
hasn't existed/been used in similarly as long. Make it clear that we own
top(1)
Tested with 'make universe'. Everything passed except MIPS which failed
for unrelated reasons. Install also tested for amd64.
Reviewed by: sbruno
No objections: imp, mmacy
Differential Revision: https://reviews.freebsd.org/D15387