From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2935 invoked by alias); 6 Jan 2015 07:45:25 -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: 34122 Received: (qmail 23571 invoked from network); 6 Jan 2015 07:45:24 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=B94OC1pJ c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=YNv0rlydsVwA:10 a=73-QTGEoIGVYsLVb6PYA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150105234539.ZM10605@torch.brasslantern.com> Date: Mon, 05 Jan 2015 23:45:39 -0800 In-reply-to: Comments: In reply to Mikael Magnusson "Fishier code in handlefeatures" (Jan 6, 1:20am) References: <1999441420503885@web17g.yandex.ru> <2001361420504569@web17g.yandex.ru> In-reply-to: <2001361420504569@web17g.yandex.ru> Comments: In reply to ZyX "Re: Fishier code in handlefeatures" (Jan 6, 3:36am) X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh workers Subject: Re: Fishier code in handlefeatures MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 6, 1:20am, Mikael Magnusson wrote: } } if (!enables || *enables) } return setfeatureenables(m, f, *enables); } } so if enables is NULL, we immediately do *enables? I'm not sure what's } intended here but obviously it somehow works. On Jan 6, 3:36am, ZyX wrote: } } Guess this code means that `enables` is never NULL and first part of } the condition should be dropped in order not to confuse people. setfeatureenables() accepts a NULL third argument and is called that way in a number of places; so I suspect that even though none of the current module implementations calls handlefeatures() with a NULL third argument, it was probably intended to permit that case. None of this is described in zsh-development-guide, though. diff --git a/Src/module.c b/Src/module.c index 9e8b3cc..bcc0ba8 100644 --- a/Src/module.c +++ b/Src/module.c @@ -3367,7 +3367,7 @@ mod_export int handlefeatures(Module m, Features f, int **enables) { if (!enables || *enables) - return setfeatureenables(m, f, *enables); + return setfeatureenables(m, f, enables ? *enables : NULL); *enables = getfeatureenables(m, f); return 0; } -- Barton E. Schaefer