Source-Changes-D archive

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

Re: CVS commit: src/lib/libc



On Tue, Mar 13, 2012 at 10:27:08PM +0100, Joerg Sonnenberger wrote:
> On Tue, Mar 13, 2012 at 05:13:51PM -0400, Christos Zoulas wrote:
> > Log Message:
> > PR/45989: Martin Husemann: lint invocation does include -w only on i386
> > 
> > - turn lint -w for all the platforms after fixing the lint warnings.
> > - add _DIAGASSERTS() for casts that would assign values to types that
> >   would not fit.
> > - change types, add casts
> > - change into ansii prototypes
> > - turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
> >   builds)
> 
> Thanks for ignoring my comments. It's especially useful that you
> haven't really addressed any of the points. Checking casts from size_t
> to uint32_t is useless on a good number of our architectures. Other
> places have proper checks already in place, so this just adds bloat.
> 
> Joerg

I also suspect it seriously reduces readability.
I'm very much against any casts between integral types,
I've been caught out too many times (at least once!) because casts
can also do pointer conversions.

The same goes for casts to change the integral type on function calls.
Since we require ANSI C prototypes to be in place they are worthless,
for K&R C they were needed to get the correct values passed.
But that is no longer true.

I'd also vote for any code that looks at the return value
of printf() being flagged - rather than require a (void) cast of
the result. (You need to use ferror() probably after fflush() to
detect errors, especially just before calling fclose(), anything
else is mostly pointless.)

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index