warnings in collate.c

Jeff Johnston jjohnstn@redhat.com
Wed Nov 19 21:51:00 GMT 2008

Howland Craig D (Craig) wrote:
> The problem with reallocf() is that there is not a prototype for it
> that I found.  What's the appropriate header for a prototype for
> reallocf()?  (It would seem to be stdlib.h, but it would need some
> kind of ifdef to only have it when posix (et.al.) was in use.  Jeff:
> do you know how to conditionally include it appropriately?)
> As for the second problem ("free(s);" to "free((void *)s);"), gcc 3.4.4
> says
> collate.c:183: warning: passing arg 1 of `free' discards qualifiers from
> pointer target type
> If it weren't for the very odd way that the beginning of the function
> is coded that allows the problem to be avoided, this would be best
> addressed with the cast to eliminate the warning.  But given that
> the strdup() and free() are completely unnecessary, I have attached a
> different patch that removes the problem.
> I left out the cast for reallocf() since it should be fixed with a
> prototype.  (There are two other files that also refer to reallocf().)
> A different approach would be to always include reallocf(), instead of
> only having it under posix and sys/linux, as then the condition on the
> prototype would not be needed.
Thanks Craig.  Your patch has been committed.  In addition, I have moved 
reallocf to stdlib,
added a _reallocf_r function, put the prototypes in stdlib.h, and added 
documentation to malloc.c

-- Jeff J.
> Craig
> -----Original Message-----
> From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
> On Behalf Of Ralf Corsepius
> Sent: Tuesday, November 18, 2008 11:43 PM
> To: Joel Sherrill
> Cc: newlib@sources.redhat.com
> Subject: Re: warnings in collate.c
> On Tue, 2008-11-18 at 17:11 -0600, Joel Sherrill wrote:
>> Hi,
>> Attached is a patch which removes warnings in
>> collate.c.  This just silences the warnings.
> I am opposed to this patch. 
> Better live with warnings until they can be properly fixed and do not
> try to play things down by hiding them away.
> Ralf

More information about the Newlib mailing list