Subject: Re: lib/36668: bogus complaints about sys/endian.h code when running lint -aa
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Matthias Kretschmer <mccratch@gmx.de>
List: netbsd-bugs
Date: 07/20/2007 20:50:02
The following reply was made to PR lib/36668; it has been noted by GNATS.

From: Matthias Kretschmer <mccratch@gmx.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: lib/36668: bogus complaints about sys/endian.h code when running lint -aa
Date: Fri, 20 Jul 2007 22:50:31 +0200

 On Fri, Jul 20, 2007 at 03:55:02PM +0000, David Laight wrote:
 > From: David Laight <david@l8s.co.uk>
 >  > -       p[1] = u & 0xff;
 >  > +       p[1] = (uint8_t)(u & 0xff);
 >  
 >  There is a big problem with adding such casts, they can very easily
 >  hide other (bigger) problems with the source.
 >  Especially if applied to every place an implicit integer narrowing
 >  conversion happens.
 
 The meaning of the code doesn't change and I don't see where there are
 any problems with this code as it just does the right thing.  It's
 nothing more than that lint is unable to tell that "u & 0xff" will
 really be just 8-bits long.  Similiar for other parts of the code in
 endian.h.
 
 --
 Matthias Kretschmer