This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Finding unnecessary (K&R compat) casts
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: florian at edamail dot fishkill dot ibm dot com
- Cc: gcc at gnu dot org
- Date: Thu, 17 Jul 2003 15:23:02 -0400 (EDT)
- Subject: Re: Finding unnecessary (K&R compat) casts
- References: <200307171308.59227.florian@edamail.fishkill.ibm.com>
> From: Florian Krohm <florian@edamail.fishkill.ibm.com>
>
> > 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.
read_seek in mips-tdump.c looks like a candidate, but the one in
mips-tfile.c returns a page_t* (?), so the casts might be necessary
there.
Some of the casts used on str* functions are to go between char* and
uchar*. There's a handful of unnecessary strchr casts on the return
value, I'll zap those.
> > for argument casts I have these functions:
> >
> > mem[a-z]+
> >
>
> free
I think those are necessary to cast aways const-ness.
> I've also seen some suprious casts of function return values to void.
> Are you getting rid of those as well?
> Florian
I'll get them if I see them, but I'm not looking specifically for
those.
Thanks,
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu