Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Jun 2018 21:43:25 -0700 (PDT)
From:      "Rodney W. Grimes" <freebsd@pdx.rh.CN85.dnsmgr.net>
To:        Eitan Adler <eadler@freebsd.org>
Cc:        "Rodney W. Grimes" <rgrimes@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r334518 - head/usr.bin/top
Message-ID:  <201806020443.w524hPwO084996@pdx.rh.CN85.dnsmgr.net>
In-Reply-To: <CAF6rxgnxkpsb%2Br_WDH-3LYG9Bf5psvLXYW_u%2BQMg1DiBnTROPQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[ Charset UTF-8 unsupported, converting... ]
> On 1 June 2018 at 21:32, Rodney W. Grimes
> <freebsd@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@freebsd.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806020443.w524hPwO084996>