From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4152 invoked by alias); 6 Jan 2015 00:36:14 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34101 Received: (qmail 18508 invoked from network); 6 Jan 2015 00:36:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_FSL_HELO_BARE_IP_2 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1420504570; bh=jB4/Eu5gjjni99R9g7t7gC23Kj+YdKuKvVI5eb4KoFM=; h=From:To:Cc:In-Reply-To:References:Subject:Date; b=kLSI1J8P8k/TFtcN3q+SJ+wnInpfyklnKBnU0IxaHP2FxovD8fnnLl4NvUooJbs1N VI+6rByuAsfCaCaSqj85xg/CaulLjr2skwuYXC62mxhJ/LGY8VXXRMOiVvoeQSxnR2 KwvnToJXpbzrzfOl987seLYyhFyqnb+hJAV2bqJ0= From: ZyX To: Mikael Magnusson Cc: Peter Stephenson , zsh workers In-Reply-To: References: <1999441420503885@web17g.yandex.ru> Subject: Re: Fishier code in handlefeatures MIME-Version: 1.0 Message-Id: <2001361420504569@web17g.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Tue, 06 Jan 2015 03:36:09 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r 06.01.2015, 03:32, "Mikael Magnusson" : > On Tue, Jan 6, 2015 at 1:24 AM, ZyX wrote: >> š06.01.2015, 03:21, "Mikael Magnusson" : >>> š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