Subject: Re: bin/19381: netstat shows negative percentage
To: None <netbsd-bugs@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 12/14/2002 10:59:44
> >Synopsis:       netstat shows negative percentage
> --- mbuf.c      2002/03/09 23:26:51     1.17
> +++ mbuf.c      2002/12/14 09:56:39
> @@ -157,7 +157,7 @@
>             (mclpool.pr_npages << mclpa.pa_pageshift);
>         totused = (mbpool.pr_nget - mbpool.pr_nput) * mbpool.pr_size +
>             (mclpool.pr_nget - mclpool.pr_nput) * mclpool.pr_size;
> -       totpct = (totmem == 0)? 0 : ((totused * 100)/totmem);
> +       totpct = (totmem == 0)? 0 : (int)(((double)totused * 100)/totmem);
>         printf("%u Kbytes allocated to network (%d%% in use)\n",
>             totmem / 1024, totpct);
>         printf("%lu requests for memory denied\n", mbstat.m_drops);

or:
+       totpct = (totmem < 100) ? 0 : totused/(totmem/100));
to avoid nasty FP arithmetic.

	David

-- 
David Laight: david@l8s.co.uk