Finding unnecessary (K&R compat) casts
Florian Krohm
florian@edamail.fishkill.ibm.com
Thu Jul 17 17:48:00 GMT 2003
> I wanted to generate a complete list of such functions to know where
> to look for zapping spurious casts. So far I have these for return
> values:
>
> (m|c|re|xm|xc|xre)alloc
> xmemdup
> alloca
> htab_fin(d|d_slot|d_with_hash|d_slot_with_hash)
> ggc_[a-z_]*alloc[a-z_]*
>
Seems like a pretty good start. I've tried this
find . -name '*.c' -exec egrep -H '\([[:alnum:]_]+ \*\)[ ]*[[:alnum:]_]+[
]*\(' {} \;
and found read_seek and strchr to be the highlights.
> for argument casts I have these functions:
>
> mem[a-z]+
>
free
I've also seen some suprious casts of function return values to void.
Are you getting rid of those as well?
Florian
More information about the Gcc
mailing list