Commit Graph

23 Commits

Author SHA1 Message Date
Eitan Adler
17be5f230a top(1): Use warnx and errx instead of fprintf
This also makes make "-v" exit without error, since it isn't.
2018-08-22 10:07:15 +00:00
Daichi GOTO
324976739f top(1): fixed the empty output problem in non-interactive mode (-n, -b) regressed in r336028
PR:		229842
Reported by:	Ali Abdallah <aliovx@gmail.com>
Reviewed by:	eadler, cy
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16455
2018-07-27 01:20:34 +00:00
Daichi GOTO
0a59db87e3 Changed to eliminate the upper limit of command length displayed
by "-a" and expand to match terminal width

Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16083
2018-07-06 12:07:06 +00:00
Eitan Adler
5c66dcc072 top(1): remove special handling of load > 5
When the load is "high" (an arbitrary value) top(1) previously moved the
cursor to the top-left of the screen as an acknowledgment. In practice,
on modern machines, even relatively slow ones, it looked more like a
glitch. Remove the logic.
2018-06-22 09:45:18 +00:00
Eitan Adler
c8aa5e526f top(1): move command mapping to commands.c
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.
2018-06-12 06:53:31 +00:00
Eitan Adler
c51e28f46f top(1): Fix two speeling errors I introduced 2018-06-02 22:12:57 +00:00
Eitan Adler
4fedcd4983 top(1): cleanup memory allocation and warnings
- 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]
2018-06-02 21:40:45 +00:00
Eitan Adler
2c1fdbac13 top(1): remove wrapper around putchar
This appears to have been written for portability which we no longer
need.
2018-06-02 07:44:53 +00:00
Eitan Adler
0059e7102f top(1): clean up a bit
- remove unused defines
- use standard defines for STDOUT
- don't cast for memset
- avoid using (void) cast
2018-06-02 04:20:42 +00:00
Eitan Adler
1978939544 top(1): Use uid_t for uid rather than 'int'
Remove unneeded define while here.
2018-06-02 03:54:50 +00:00
Eitan Adler
0b2f6ed144 top(1): Use standard boolean rather than homegrown alternative 2018-06-02 03:25:15 +00:00
Eitan Adler
f6234b51bf top(1): ansify, style(9). and nits
- 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
2018-06-02 00:02:15 +00:00
Eitan Adler
1b7645c629 top(1): modernize a bit; reduce warnings
- 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
88 warnings in machine.c
7 warnings in commands.c

all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"
2018-05-21 09:25:21 +00:00
Eitan Adler
00157b4c04 Revert r333969 which contained one too many changes 2018-05-21 09:20:26 +00:00
Eitan Adler
bfb79c2ccc top(1): modernize a bit; reduce warnings
- 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"
2018-05-21 09:18:01 +00:00
Eitan Adler
a5ca08ed94 top(1): fix several more warnings 2018-05-21 03:36:16 +00:00
Eitan Adler
666cf87393 top(1): clean much of WARNS=3 issues
There is still one glaring issue: new_message is not a protoype, but
can't be trivially converted since it uses K&R style var-args.
2018-05-21 00:53:42 +00:00
Eitan Adler
4901ca088d top(1): build with WARN=2 2018-05-21 00:32:48 +00:00
Eitan Adler
f11066efb1 top(1): unconditionally assume we are on FreeBSD (more unifdef)
Now that we're our own upstream, remove useless ifdefs.
2018-05-20 18:11:58 +00:00
Eitan Adler
cebbed43bb Retry revert
I had a local modification before my revert. Try reverting one more time.
2018-05-20 18:03:40 +00:00
Eitan Adler
500cd2d6a1 revert r333928
I had missed a file when testing this, and it does not build. Will try again.
2018-05-20 18:02:40 +00:00
Eitan Adler
caee48830b top(1): unconditionally assume we are running on FreeBSD
This allows us to remove a special header and more specifically just the
system headers we want.
2018-05-19 23:19:24 +00:00
Eitan Adler
3be6ef0659 top(1): Migrate top to usr.bin
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
2018-05-19 22:40:23 +00:00