Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Nov 1999 09:45:36 +0100
From:      Pierre Beyssac <beyssac@enst.fr>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>, Sheldon Hearn <sheldonh@uunet.co.za>, freebsd-current@FreeBSD.ORG
Subject:   Re: egcs -O breaks ping.c:in_cksum()
Message-ID:  <19991116094536.A44999@enst.fr>
In-Reply-To: <Pine.BSF.4.10.9911161448210.780-100000@alphplex.bde.org>; from Bruce Evans on Tue, Nov 16, 1999 at 03:17:43PM %2B1100
References:  <19991115194357.T28348@enst.fr> <Pine.BSF.4.10.9911161448210.780-100000@alphplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991116094536.A44999>