zsh-workers
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: Peter Stephenson <p.stephenson@samsung.com>,
	zsh workers <zsh-workers@zsh.org>
Subject: Re: Fishier code in handlefeatures
Date: Tue, 06 Jan 2015 03:36:09 +0300	[thread overview]
Message-ID: <2001361420504569@web17g.yandex.ru> (raw)
In-Reply-To: <CAHYJk3QP+mPCGpjia6aB+UxwGa9ePVceK7v4RBu-aMC5epYLRw@mail.gmail.com>

06.01.2015, 03:32, "Mikael Magnusson" <mikachu@gmail.com>:
> On Tue, Jan 6, 2015 at 1:24 AM, ZyX <kp-pav@yandex.ru> wrote:
>>  06.01.2015, 03:21, "Mikael Magnusson" <mikachu@gmail.com>:
>>>  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


  reply	other threads:[~2015-01-06  0:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-06  0:20 Mikael Magnusson
2015-01-06  0:24 ` ZyX
2015-01-06  0:32   ` Mikael Magnusson
2015-01-06  0:36     ` ZyX [this message]
2015-01-06  7:45       ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2001361420504569@web17g.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=mikachu@gmail.com \
    --cc=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).