Compiler warnings

Andreas Ericsson ae at op5.se
Thu Oct 18 18:58:11 CEST 2007


Ethan Galstad wrote:
> Andreas Ericsson wrote:
>> Ahoy.
>>
>> I was digging around trying to fix a bunch of compiler-warnings, and
>> noticed that pretty much every invocation of my_free() resulted in
>> about a million warnings, such as this:
>>
>> 	../xdata/xrddefault.c:190: warning: dereferencing type-punned
>> 	pointer will break strict-aliasing rules
>>
>>
>> Considering that not a single invocation of my_free() evaluates the
>> return code of the function, a macro such as
>>
>> 	#define my_free(ptr) { if(ptr) { free(ptr); ptr = NULL; } }
>>
>> would do the trick, and also provide a slight performance improvement.
>>
>> Since a patch would be fairly huge, and I've kinda filled my quota
>> for huge patches for today, the following sed-script will take care
>> of the call-sites (requires sed 4.0.9 or later):
>>
>> 	sed -i 's/my_free[^&]*&\([^)]*\).*/my_free(\1);/' */*.c
>>
> 
> Definitely a good idea.  I've committed this to CVS after some manual 
> massaging post-sed.
> 

Thanks.

> Don't know why, but I get a SIGABRT if I don't comment out two my_free() 
> statements in xdata/xodtemplate.c in the 
> xodtemplate_get_inherited_string() function.
> 

I'll look into it.

> For the time being I've removed them.  This will cause a small, but 
> one-time memory leak upon startup until the problem is fixed.
> 

Also upon sighup and reloads, I take it?

I'll feel better if it gets properly fixed. Did you have some specific
test-case or backtrace for it, or should I just throw some anarchy at it
and see what pops up?

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/




More information about the Developers mailing list