NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/43541: Unaligned access in pf_normalize_tcpopt()



The following reply was made to PR kern/43541; it has been noted by GNATS.

From: David Laight <david%l8s.co.uk@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/43541: Unaligned access in pf_normalize_tcpopt()
Date: Wed, 30 Jun 2010 00:21:05 +0100

 On Tue, Jun 29, 2010 at 08:15:05PM +0000, David Holland wrote:
 > The following reply was made to PR kern/43541; it has been noted by GNATS.
 > 
 > From: David Holland <dholland-bugs%netbsd.org@localhost>
 > To: gnats-bugs%NetBSD.org@localhost
 > Cc: 
 > Subject: Re: kern/43541: Unaligned access in pf_normalize_tcpopt()
 > Date: Tue, 29 Jun 2010 20:12:11 +0000
 > 
 >  On Mon, Jun 28, 2010 at 04:35:00PM +0000, 
 > gandersen%cradlepoint.com@localhost wrote:
 >   > +                                optp[2] = (u_char)(r->max_mss >> 8) & 
 > 0xff;
 >   > +                                optp[3] = (u_char)(r->max_mss) & 0xff;
 >  
 >  Do those casts serve any purpose?
 
 Do the '& 0xff' serve any purpose ?
 
 The compiler may well generate code that 'and's the value with 0xff twice
 before storing the low 8 bits away!
 
 OTOH reversing the two lines may well save a temporary register.
 Hmmm... actually you want to cache r->max_rss in a local, the compiler
 is most likely required to re-read r->max_rss between the two statements.
 
        David
 
 -- 
 David Laight: david%l8s.co.uk@localhost
 


Home | Main Index | Thread Index | Old Index