On 04/14/2014 09:26 AM, Andreas Schwab wrote:
> Eric Blake <ebl...@redhat.com> writes:
> 
>> It silences static code checkers and avoids undefined C behavior.
>>
>> Also, if invokers[] is allocated such that it ends on the end of a page
>> boundary (such as might be the case under certain malloc debuggers),
>> then doing the bounds check first will avoid an out-of-bounds access
>> causing a SEGFAULT.
> 
> invokers[] is guaranteed to end with a NULL element, so there cannot be
> any out-of-bounds access, and the use is completely defined.  The NULL
> check is the primary condition, with the index check only being
> secondary.

In that case, the index check is dead code, and it could be elided as a
micro-optimization.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to