Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Fishier code in handlefeatures



06.01.2015, 03:32, "Mikael Magnusson" <mikachu@xxxxxxxxx>:
> On Tue, Jan 6, 2015 at 1:24 AM, ZyX <kp-pav@xxxxxxxxx> wrote:
>>  06.01.2015, 03:21, "Mikael Magnusson" <mikachu@xxxxxxxxx>:
>>>  mod_export int
>>>  handlefeatures(Module m, Features f, int **enables)
>>>  {
>>>      if (!enables || *enables)
>>>        return setfeatureenables(m, f, *enables);
>>>      *enables = getfeatureenables(m, f);
>>>      return 0;
>>>  }
>>>
>>>  so if enables is NULL, we immediately do *enables? I'm not sure what's
>>>  intended here but obviously it somehow works.
>>  NULL is false, so if enables is NULL !enables is true and *enables is not evaluated due to short-circuiting. Nothing wrong here.
>
> Read the next line too.

Ah. You mean dereference in function arguments, good catch.

Guess this code means that `enables` is never NULL and first part of the condition should be dropped in order not to confuse people.

>
> --
> Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author