Removing the NT_STATUS_HAVE_NO_MEMORY_AND_FREE macro

Kamen Mazdrashki kamenim at samba.org
Sat Feb 15 07:21:11 MST 2014


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
will
literary double the length of it (which will make it hard to notice if you
have
missed to copy a struct field).

Just my 2c.

Cheers,
Kamen



On Thu, Feb 13, 2014 at 6:27 AM, Garming Sam <garming at catalyst.net.nz>wrote:

> Hi,
>
> Included are some patches to remove the NT_STATUS_HAVE_NO_MEMORY_AND_FREE
> macro.
>
> I'm told that the we shouldn't be using such macros anymore and so I
> thought I might try and get rid of them. When I was going through the code
> earlier, I came across this one which is especially terrible since it
> doesn't have any mention of even a return.
>
> There's a few others that we should get rid of. I do note that
> NT_STATUS_HAVE_NO_MEMORY has something like 1000 instances. I could
> obviously remove them, but they're going to have to be checked and it's
> probably going to be a nuisance to someone.
>
> The first patch I just ran the code through a script. There were only a
> few left, so in the second patch I fixed the remaining ones manually.
>
>
> Cheers,
>
>
> Garming Sam
>


More information about the samba-technical mailing list