Commit Graph

13766 Commits

Author SHA1 Message Date
Kyle Evans
031f92f512 bsdgrep(1): Remove redundant initialization; unconditionally assigned later 2018-06-15 03:31:30 +00:00
Eitan Adler
ef8dcce3c2 top(1): remove myself from top.1
I wrote some, but not enough for the man page.
2018-06-14 12:14:51 +00:00
Allan Jude
21e289d49b Fix top(1) support for displaying ZFS Compressed ARC statistics
Broken in r334514

sysctlbyname("vfs.zfs.compressed_arc_enabled", ...) would return ENOMEM
while trying to read the sysctl (a boolean_t) into a bool, which is too small.

Reviewed by:	jhb (on irc)
Sponsored by:	Klara Systems
2018-06-14 00:10:16 +00:00
Eitan Adler
f764243341 top(1): remove unneeded logic
- 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.
2018-06-13 11:12:52 +00:00
Eitan Adler
1de6384221 top(1): style(9)
- split return type from function name
- Sprinkle a __pure where possible.
2018-06-13 08:52:22 +00:00
Eitan Adler
d18626664a top(1): add myself to authors
At this point I've mucked enough with top(1) that all bugs should be
blamed on me rather than William LeFebvre.
2018-06-13 08:52:19 +00:00
Eitan Adler
c655e639c2 top(1): shift from atoi to non-deprecated function 2018-06-13 08:52:14 +00:00
Eitan Adler
704daa9b87 top(1): replace homegrown itoa with sprintf
Much of this should be inlined to the callsite, but leave it here for
now to make it easier to make it easier bisect later.
2018-06-13 08:52:12 +00:00
Eitan Adler
8e4b205ea5 top(1): format_time, format_k, etc.
- Use humanize_number for format_k and format_k2
- Fix some style nits in format_time
2018-06-13 08:52:09 +00:00
Eitan Adler
e7cb1c0776 top(1): format help more nicely
For entries that are duplicates present them nicely rather than showing
two identical help entries. For ' ' present it as SPC
2018-06-13 08:52:06 +00:00
Eitan Adler
baab2cf821 vmstat(1): various nits
Continue my parade on introspection tools by fixing:
- failed to check for null after reallocf
- avoid the comma operator
- mark usage as dead
- correct size of len
2018-06-13 08:52:04 +00:00
Eitan Adler
59c50d8277 top(1): several small bugfixes and nits
- initialize all maybe uninitialized vars with bogus values. This shuts
up the compiler, and causes crashes if it changes later.
- mark noreturn as noreturn
- removed unused macro
- handle x_procstate as runtime rather than pre-processor
- avoid using void functions in condtionals

Tested with clang, gcc 7, gcc 9
2018-06-13 00:45:38 +00:00
Baptiste Daroussin
43d7b1c097 Fix memory leak
CID:		1393352
2018-06-12 16:42:11 +00:00
Baptiste Daroussin
5a43dca273 Correctly test return value of pipe(2)
CID:		1393351
2018-06-12 16:40:22 +00:00
Eitan Adler
0ff79d817c top(1): remove trailing whitespace 2018-06-12 07:31:59 +00:00
Eitan Adler
ccf22059e0 top(1): style and related
- style(9)
- remove now-defunct comments
- remove getuid check for low delay
- expand range of format_k
2018-06-12 07:14:12 +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
Piotr Pawel Stefaniak
bb92a28b2f indent(1): rename -nsac/-sac ("space after cast") to -ncs/-cs
Also update tests and the manpage.

GNU indent had the option earlier as -cs, let's not diverge unnecessarily.
2018-06-11 05:35:57 +00:00
Eitan Adler
fb7b896cd8 top(1): handle 0 in "digits" functions 2018-06-11 05:05:20 +00:00
Piotr Pawel Stefaniak
7e53aaedd3 indent(1): group global option variables into an options structure
It's clearer now when a variable represents a toggable command line option.

Many options were stored in the parser's state structure, so fix also that.
2018-06-10 16:44:18 +00:00
Eitan Adler
a01160996b top(1): use modern interfaces for nice and related
- attempt and fail, rather than check for permission.
- use macro rather than explicit "-20"
2018-06-10 09:15:13 +00:00
Eitan Adler
1a8f56dd3a top(1): add command aliases; correct dumb support 2018-06-10 09:04:56 +00:00
Eitan Adler
561b0720cf top(1): use sys_signame instead of hard coding signals
This enables the removal of the signal.h awk script. Shamelessly stolen
from kill(1).
2018-06-10 09:00:01 +00:00
Eitan Adler
b26cf3d06c top(1): bring some structure to commands
Right now this is only used for help text but it'll eventually be used
to build up long options array, dispatch commands, etc.
2018-06-10 08:59:57 +00:00
Eitan Adler
4eef480b46 top(1): use correct word when displaying threads
PR:		182204
Reported by:	"Brodey Dover" <doverosx@gmail.com>
2018-06-10 06:33:49 +00:00
Eitan Adler
b4aadfd27e top(1): filter fewer warnings; clean up
- remove WARNS?=6. It is default
- we no longer have cast-qual problems
- remove unused macros
- remove unneeded casts
- add include guard for loadavg.h
2018-06-10 06:21:51 +00:00
Eitan Adler
da446b10ed top(1): permit sending signal with any case 2018-06-10 06:21:45 +00:00
Michael Dexter
c1192502cb Add myself to calendar.freebsd
Approved by:	bcr (mentor)
2018-06-10 05:48:03 +00:00
Eitan Adler
468910cd7a top(1): permit sub-second delay times
This removes the getuid check for delay==0. It didn't prevent users from
writing similar programs in the general case. In theory, if top(1) is
among one of the few restricted programs you're allowed to run, it may
have helped a little, but there are better ways of handling that case.
2018-06-10 00:02:56 +00:00
Eitan Adler
6e0632db3d top(1): correctly reset per-cpu counters
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
2018-06-09 23:24:08 +00:00
Eitan Adler
ef436ca6a6 top(1): handle specific pids better
When told to watch a specific pid, don't filter idle, system, or self
processes. The summary at the top will still flip correctly though.
2018-06-09 23:08:02 +00:00
Eitan Adler
d73bfd43b2 top(1): implement additional missing long options 2018-06-09 22:30:10 +00:00
Eitan Adler
9d6cce02a7 top(1): initial pass to freebsdize the man page
The previous man page used many conventions not typical in FreeBSD.
Since we've forked top completely, convert the man page too.
2018-06-09 21:40:33 +00:00
Eitan Adler
c388909b8d top(1): Implement long options
This also documents some reserved or differing options from top's
original upstream.
2018-06-09 21:40:24 +00:00
Baptiste Daroussin
e620f7fb56 diff: Import fixes from OpenBSD
original commit log by miller@OpenBSD  r1.46:
Fix exit value when diffing directories with missing files and the -N
or -P options are not used.  From Ibrahim Khalifa
2018-06-09 21:09:24 +00:00
Guangyuan Yang
2b77102934 Add myself to the calendar
Requested by:	mckusick
Reviewed by:	emaste
2018-06-09 21:05:25 +00:00
Baptiste Daroussin
6fa5bf0832 Isolate the pr(1) related code in its own source files
This keeps diffreg.c closer to what it is supposed to do:
diffing regular files.

It also allows my code to get a proper license
2018-06-09 20:24:17 +00:00
Eitan Adler
dd0bdd6b45 top(1): allow starting with -T flag 2018-06-09 20:06:06 +00:00
Kyle Evans
be13c0f967 bsdgrep(1): Some more int -> bool conversions and name changes
Again motivated by upcoming work to rewrite a bunch of this- single-letter
variable names and slightly misleading variable names ("lastmatches" to
indicate that the last matched) are not helpful.
2018-06-09 18:11:46 +00:00
Eitan Adler
7fe961ff48 ncal: correct history section
originally reported Todd C. Miller[0]
Additional data see [1][2].

While here, pet igor.

Closes #152 (github pr)
Sbmitted by:	Raf Czlonka

[0]
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/cal/cal.1?rev=1.28&content-type=text/x-cvsweb-markup
[1] https://www.bell-labs.com/usr/dmr/www/1stEdman.html
[2] https://www.bell-labs.com/usr/dmr/www/man61.pdf
2018-06-09 04:40:17 +00:00
Eitan Adler
e3225dcf12 top(1): correct header, align it.
THR is always 6 digits or longer. Now that the PID/THR change is
separated, use correct headers.

PR:		228823
Reported by:	Trond.Endrestol@ximalas.info
2018-06-09 02:47:02 +00:00
Eitan Adler
4e08f2f53c top(1): actually make change for tid vs pid 2018-06-09 02:18:15 +00:00
Eitan Adler
fc36f5a7cb top(1): use a different command to toggle tid vs pid
- 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
2018-06-09 02:14:33 +00:00
Kyle Evans
d1a920b48f bsdgrep(1): Evict character sequence that moved in
Reported by:	trasz
2018-06-08 12:58:55 +00:00
Eitan Adler
4fb80c7008 top(1): remove some unneeded indirection 2018-06-08 02:03:51 +00:00
Eitan Adler
d408c8f742 top(1): fix several style & const related issues
- use parens for return
- put function names on newline
- sprinkle const where possible
2018-06-08 01:55:47 +00:00
Kyle Evans
bd60b9b499 bsdgrep(1): Slooowly peel away the chunky onion
(or peel off the band-aid, whatever floats your boat)

This addresses two separate issues:

1.) Nothing within bsdgrep actually knew whether it cared about line numbers
  or not.

2.) The file layer knew nothing about the context in which it was being
  called.

#1 is only important when we're *not* processing line-by-line. #2 is
debatably a good idea; the parsing context is only handy because that's
where we store current offset information and, as of this commit, whether or
not it needs to be line-aware.
2018-06-08 01:25:07 +00:00
Kyle Evans
66f780aee0 bsdgrep(1): Don't initialize fts_flags twice
Admittedly, this is a clang-scan complaint... but it wasn't wrong. fts_flags
is initialized by all cases in the switch(), which should be fairly obvious.
Annotate this anyways.
2018-06-07 18:38:48 +00:00
Kyle Evans
40f0e0b100 bsdgrep(1): whoops, garbage collect the now write-only variable 2018-06-07 18:36:12 +00:00
Kyle Evans
cbfff13fa2 bsdgrep(1): Do some less dirty things with return types
Neither procfile nor grep_tree return anything meaningful to their callers.
None of the callers actually care about how many lines were matched in all
of the files they processed; it's all about "did anything match?"

This is generally just a light refactoring to remind me of what actually
matters as I'm rewriting these bits to care less about 'stuff'.
2018-06-07 18:27:58 +00:00