On Tue, 2012-11-20 at 10:18 +0100, Petr Spacek wrote:
> Hello,
> 
>      Use memory allocation macros more extensively.
> 
>      Some scattered occurences of isc_mem_* functions was replaced by macros.
>      Destroy_ldap_instance() now accepts NULL LDAP instance.
> 
>      String functions from str.c are still calling isc_mem_directly.
> 
> This patch contain small subset of changes which affect new_ldap_instance() 
> and destroy_ldap_instance() calls. Remaining changes do not require changes 
> in 
> new_*/destroy_* logic and will follow in separate patch.

Hi Petr,
I am not sure what are ISC conventions, but in general Macros that
change program flow are quite dangerous *unless* you prominently make
clear that that's what they are doing.

So if you return or goto in a macro I suggest you make RETURN and GOTO
part of the name, otherwise inspection of the code will easily make
someone not notice that.

This can easily lead to memory leaks where you do not notice a
return/goto macro and the condition happen, as well as more serious
issues, like not seeing a return/goto after you obtained a lock or a
mutex and so on.

In general I would really avoid 'return' in a macro and at most do gotos
to some explicit label you can pass as argument of the macro.

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to