From owner-freebsd-current Tue Nov 16 0:45:54 1999 Delivered-To: freebsd-current@freebsd.org Received: from enst.enst.fr (enst.enst.fr [137.194.2.16]) by hub.freebsd.org (Postfix) with ESMTP id 88B4A14EC6 for ; Tue, 16 Nov 1999 00:45:48 -0800 (PST) (envelope-from beyssac@enst.fr) Received: from bofh.enst.fr (bofh-2.enst.fr [137.194.2.37]) by enst.enst.fr (8.9.1a/8.9.1) with ESMTP id JAA11136; Tue, 16 Nov 1999 09:45:36 +0100 (MET) Received: by bofh.enst.fr (Postfix, from userid 12426) id 61BB9D226; Tue, 16 Nov 1999 09:45:36 +0100 (CET) Message-ID: <19991116094536.A44999@enst.fr> Date: Tue, 16 Nov 1999 09:45:36 +0100 From: Pierre Beyssac To: Bruce Evans Cc: Garrett Wollman , Sheldon Hearn , freebsd-current@FreeBSD.ORG Subject: Re: egcs -O breaks ping.c:in_cksum() References: <19991115194357.T28348@enst.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2i In-Reply-To: ; from Bruce Evans on Tue, Nov 16, 1999 at 03:17:43PM +1100 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, Nov 16, 1999 at 03:17:43PM +1100, Bruce Evans wrote: > On Mon, 15 Nov 1999, Pierre Beyssac wrote: > > - volatile u_short answer = 0; > > + union { > > + u_int16_t us; > > + u_int8_t uc[2]; > > + } answer; > > This has indentation bugs. Uh, which one(s) do you mean exactly? The 4-space indented union (I just followed style(9)) or the double space before uc[2] (it was just to align us and uc vertically)? > ping.c still assumes that u_short is u_int16_t everywhere else. But in_cksum() is more or less self-contained. Probably it's more consistent (even withing in_cksum which uses u_short elsewhere) to change back the union to u_short and u_char, though. > This `answer' variable has nothing to do with the final `answer' variable. > The latter should not be a union. The original code apparently reuses > `answer' to do manual register allocation for ancient compilers. Agreed. > Perhaps the above should be written as: > > sum += ntohs(*(u_char *)w << 8); > > to avoid the undefined union access (answer.us). Uh... I'm not sure I don't prefer the union, actually :-) -- Pierre Beyssac pb@enst.fr To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message