From owner-freebsd-hackers Wed Nov 27 16:09:02 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id QAA24179 for hackers-outgoing; Wed, 27 Nov 1996 16:09:02 -0800 (PST) Received: from zen.nash.org (nash.pr.mcs.net [204.95.47.72]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id QAA24167 for ; Wed, 27 Nov 1996 16:08:58 -0800 (PST) Received: from zen.nash.org (localhost [127.0.0.1]) by zen.nash.org (8.8.3/8.6.12) with SMTP id RAA12567; Wed, 27 Nov 1996 17:58:52 -0600 (CST) Message-ID: <329CD5BB.2F1CF0FB@mcs.com> Date: Wed, 27 Nov 1996 17:58:51 -0600 From: Alex Nash X-Mailer: Mozilla 3.01Gold (X11; I; FreeBSD 2.1.5-STABLE i386) MIME-Version: 1.0 To: Joe Greco CC: Narvi , freebsd-hackers@freebsd.org Subject: Re: Netstat broken or two many bytes? References: <199611271500.JAA19115@brasil.moneng.mei.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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