From owner-svn-src-head@freebsd.org Sat Jun 2 04:43:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33D92EFDDC7; Sat, 2 Jun 2018 04:43:28 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 826B36B923; Sat, 2 Jun 2018 04:43:27 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w524hPWh084997; Fri, 1 Jun 2018 21:43:25 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w524hPwO084996; Fri, 1 Jun 2018 21:43:25 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201806020443.w524hPwO084996@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r334518 - head/usr.bin/top In-Reply-To: To: Eitan Adler Date: Fri, 1 Jun 2018 21:43:25 -0700 (PDT) CC: "Rodney W. Grimes" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jun 2018 04:43:28 -0000 [ Charset UTF-8 unsupported, converting... ] > On 1 June 2018 at 21:32, Rodney W. Grimes > 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