On Tue, Jul 3, 2012 at 12:30 AM, Raphael Kubo da Costa
<[email protected]> wrote:
> Michael Blumenkrantz <[email protected]> writes:
>> On Wed, 27 Jun 2012 23:43:23 -0300
>> Raphael Kubo da Costa <[email protected]> wrote:
>>> Cedric BAIL <[email protected]> writes:
>>> > I personally think that eina_iterator_free like any free function
>>> > should just work fine with NULL. I was against at that time, but
>>> > others won. So we do have this incoherency where some of our free
>>> > function work with NULL and some don't.
>>>
>>> So what can we do to improve the situation here (if it does need to be
>>> improved)? Speaking more generically, what criteria are used to decide
>>> that a function should be decorated with EINA_ARG_NONNULL and/or have
>>> magic checks performed?
>>
>> I am hugely in favor of having all _free() and _del() functions take NULL
>> arguments without erroring.
>
> OK, here's a proposed patch. I tried to change only _free() and _del()
> calls (so _get(), _add() etc still bark at you if you pass NULL to
> them). Existing if (!foo) return; statements have not been changed.
>
> OTOH, operations such as eina_list_remove(), eina_list_reverse() and
> eina_list_sort() only perform the magic check if the list passed to it
> is not NULL, which is inconsistent with similar calls in other
> places.
>
> I'm unsure about whether to change the following calls, so for now I
> haven't:
>  - eina_inarray_flush()
>  - eina_inarray_remove()
>  - eina_tiler_clear()
>
>  - *_foreach():
>    One could argue that passing NULL should be equivalent to an empty
>    loop. For example, right now
>        eina_iterator_foreach(NULL, ..., ...)
>    generates a magic check error message, while
>        EINA_ITERATOR_FOREACH(NULL, ...)
>    does not.

Sorry this patch is wrong for what you intend to do.
EINA_SAFETY_ON_NULL_RETURN can be completly disable at compile time.
This is an optimization as the understanding of this macro is to
generate warning when you pass NULL where you shouldn't (On low end
device, this with disabling magic check can give you a 5 to 10%
boost).
  So you really need to use a if (!exp) return ; here. Because you
don't want your code to break due to EINA_SAFETY_ON_NULL_RETURN being
disable.
-- 
Cedric BAIL

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to