Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Nov 1996 17:58:51 -0600
From:      Alex Nash <nash@mcs.com>
To:        Joe Greco <jgreco@brasil.moneng.mei.com>
Cc:        Narvi <narvi@haldjas.folklore.ee>, freebsd-hackers@freebsd.org
Subject:   Re: Netstat broken or two many bytes?
Message-ID:  <329CD5BB.2F1CF0FB@mcs.com>
References:  <199611271500.JAA19115@brasil.moneng.mei.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Joe Greco wrote:

> "UTSL!"
> 
> The printf()'s in netstat/if.c +204 are signed:
>                 printf("%8d %5d ",
>                     ifnet.if_ipackets, ifnet.if_ierrors);
>                 if (bflag)
>                         printf("%10d ", ifnet.if_ibytes);
>                 printf("%8d %5d ",
>                     ifnet.if_opackets, ifnet.if_oerrors);
>                 if (bflag)
>                         printf("%10d ", ifnet.if_obytes);
>                 printf("%5d", ifnet.if_collisions);
> 
> This is contrary to the definition of ifnet, sys/net/if.h +111, where the
> variables are declared u_long:
>                 u_long  ifi_ipackets;   /* packets received on interface */
>                 u_long  ifi_ierrors;    /* input errors on interface */
>                 u_long  ifi_opackets;   /* packets sent on interface */
>                 u_long  ifi_oerrors;    /* output errors on interface */
>                 u_long  ifi_collisions; /* collisions on csma interfaces */
>                 u_long  ifi_ibytes;     /* total number of octets received */
>                 u_long  ifi_obytes;     /* total number of octets sent */

I fixed the format specifiers in -current a while ago, but didn't 
bring it into -stable:

revision 1.12
date: 1996/06/02 23:19:01;  author: alex;  state: Exp;  lines: +7 -8
Code cleanup: remove unused variables, use correct *printf format
specifiers (some unsigned values were printed as signed, some longs
were printed as ints), and place parentheses around assignments in
if statements.
-----

Of course our longs and ints are the same size, so the signed/unsigned
change only buys you a 2x increase :(  Going to a bigger data type is
undoubtedly the way to go, but I'm touching that with a ten foot pole.

In case anyone is interested in fixing their local versions, if.c 
wasn't the only netstat module afflicted with this problem.

Alex



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?329CD5BB.2F1CF0FB>