Otherwise small quantities look nonsensical. For instance, when
swapping in a single page we would print "4096 In".
Fix code indentation while here.
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
The original intention was 4 columns but with a usable a result. In
practice this was not the case. Increase the number of columns to 5
until humanize_number learns alternative ways of presenting the number.
Requested by: many
Ref D15801
Encoding-specific processing introduced in r335836 is not recommended.
And doing getenv("LANG") and assuming an encoding based on it is a
very bad practice to internationalize software.
Submitted by: hrs
Differential Revision: https://reviews.freebsd.org/D16203
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
- remove __pure annotations I added earlier for some functions. One
writes to the the arguments as "out" pointers. The
other reads from an array, which while const within the function might
be mutated externally.
- total_change is modified to be at 1, if previously 0, so no if check
is needed.
I had changed this from a for loop to a memset during an earlier
cleanup. This change was incorrect so revert it.
While here, clean up
Reported by: flo
- avoid the need to call a function to get size of known array. I'll
likely re-arrange some of the indirect in a later to avoid the magic
constants.
- use correct type
- add const
- replace caddr_t with void*. This corrects an alignment warning.
- remove duplicated include from immediately prior commit
Under base clang we're now down to:
- 3 warning in top.c, 1 warning in mahcine.c, 4 warning in display.c,
- 1 warning in utils.c
Tested with base clang, gcc7, gcc9, base gcc (mips)
- Add const where helpful
- add missing 'static' for file-local functions
- use nitems where possible
- convert manual abort() to assert
- use strndup instead of homegrown version
Tested with clang, gcc7, and gcc9
In fixing issues with uid > INT_MAX, I broke the uid without username
case. The latter is more important so return the old state.
Discussed with: allanjude
- 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]
- Prefer calloc over malloc. This is more predicable and we're not in a
performance sensitive context. [1]
- Remove bogus comment (obsolete from prior commit). [2]
- Remove void casts and type casts of NULL
- Remove redundant declaration of 'quit'
- Add additional const
Reported by: kib [1], vangyzen [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 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