svn commit: r334518 - head/usr.bin/top

Rodney W. Grimes freebsd at pdx.rh.CN85.dnsmgr.net
Sat Jun 2 04:43:28 UTC 2018


[ Charset UTF-8 unsupported, converting... ]
> On 1 June 2018 at 21:32, Rodney W. Grimes
> <freebsd at pdx.rh.cn85.dnsmgr.net> wrote:
> >> Author: eadler
> >> Date: Sat Jun  2 04:08:52 2018
> >> New Revision: 334518
> >> URL: https://svnweb.freebsd.org/changeset/base/334518
> >>
> >> Log:
> >>   top(1): help scan-build along a bit
> >>
> >>   Teach scan-build that some arrays are larger than zero, and thus not to
> >>   warn.
> >>
> >> Modified:
> >>   head/usr.bin/top/display.c
> >>   head/usr.bin/top/machine.c
> >>
> >> Modified: head/usr.bin/top/display.c
> >>       swap_names = statics->swap_names;
> >>       num_swap = string_count(swap_names);
> >> +     assert(num_swap > 0);
> >
> > Isn't it valid to run without swap and then num_swap = 0?
> 
> I explicitly tested this case. num_swap comes from swap_names which
> comes from swapnames which is defined as
> 
> static char *swapnames[] = {
>         "K Total, ", "K Used, ", "K Free, ", "% Inuse, ", "K In, ", "K Out",
>         NULL
> };
> 
> 
> In short: its poor naming :)

Yep, I went and dug down this path myself and was about to reply
to ignore my assumption about what swap_names is and num_swap was
counting.


-- 
Rod Grimes                                                 rgrimes at freebsd.org


More information about the svn-src-all mailing list