Removing the NT_STATUS_HAVE_NO_MEMORY_AND_FREE macro
jra at samba.org
Sat Feb 15 10:47:58 MST 2014
On Sat, Feb 15, 2014 at 03:21:11PM +0100, Kamen Mazdrashki wrote:
> Hi list,
> Perhaps I am missing something, but why we need this change to remove
> NT_STATUS_HAVE_NO_MEMORY_AND_FREE? I understand there is
> coding rule not to return from a macro, but in this case, this macro makes
> the code easier to read.
> Take for instance: libgpo/gpo_util.c:gpo_copy() function.
> It is supposed to be just a simple copy-object implementation and using
> NT_STATUS_HAVE_NO_MEMORY_AND_FREE it look straightforward
> imho. But, now it is going to be bloated with 'if's all the way and this
> literary double the length of it (which will make it hard to notice if you
> missed to copy a struct field).
> Just my 2c.
Well doing returns inside macros is generally bad
programming practice, especially when you may need
to do cleanups that get added later. Changes in
control flow really need to be explicit, not implicit
So it might make the code a little uglier, but it's
then easier to maintain in the long run.
My 2c (and why I +1'ed it :-).
More information about the samba-technical