From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22147 invoked by alias); 6 Jan 2015 11:09:35 -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: 34135 Received: (qmail 20868 invoked from network); 6 Jan 2015 11:09:34 -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 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=enRKBxH9rmT14ElOu2gnffHMkj4fp3gCRmObU/YhNQg=; b=Y9V2EzcaJELceN9/+5Qvj5knK1dBYP2G8pdgPkPWN0oQqR54yBeLRhalYCX76VJbIE LYbMV5+eng6gGQhsIjdX969bs8Bk5HPFCHULQVQ3dEQsD6FnyUR1jsfCMdRMK7Z3AqHx F8Qvd6BrepuuivAJ4VzQrj1xB22vl+7J2ikfR4pCTl9MG1LWnMNUrRgZXCKGY3jUBTd/ t8AbIr7k+0bueOOlgGui0jFIhXsx5jZP46ntwJ6Dfl3y+EZe5e/WDoE8PwZkrm0oX9GF JKw3FDtTN7rez/d117yiNtPRcgAUL7la/7yz5hielxf4F50ZEmKIbhab7xgiO6MdEtDi AmFA== MIME-Version: 1.0 X-Received: by 10.50.45.4 with SMTP id i4mr15344116igm.42.1420542573671; Tue, 06 Jan 2015 03:09:33 -0800 (PST) In-Reply-To: <2802681.bPY3VCd1lN@kdudka.brq.redhat.com> References: <1420521949-30483-1-git-send-email-mikachu@gmail.com> <1420521949-30483-7-git-send-email-mikachu@gmail.com> <150105235302.ZM10839@torch.brasslantern.com> <2802681.bPY3VCd1lN@kdudka.brq.redhat.com> Date: Tue, 6 Jan 2015 12:09:33 +0100 Message-ID: Subject: Re: PATCH 06/17: compctl: Remove pointless check From: Mikael Magnusson To: Kamil Dudka Cc: Bart Schaefer , zsh workers Content-Type: text/plain; charset=UTF-8 On Tue, Jan 6, 2015 at 10:43 AM, Kamil Dudka wrote: > On Monday 05 January 2015 23:53:02 Bart Schaefer wrote: >> On Jan 6, 6:25am, Mikael Magnusson wrote: >> } Subject: PATCH 06/17: compctl: Remove pointless check >> } >> } cc has already been derefed a bunch of times leading up to here. Found >> } by Coverity (Issue 1255841). >> } - if (cc && cc->xor) { >> } + if (cc->xor) { >> >> I'm curious, why bother to "fix" this (and a couple of similar others in >> later patches in this series)? It's not *wrong*, and the change is not >> a significant optimization. > > True, modern compilers would optimize out such checks anyway in some cases. > Nevertheless, I believe that putting it explicit makes the code easier to > understand for a human reader. If you look at the bigger context, it's something like if (cc->foo) { ... } if (cc->bar) { ... } if (cc->baz) { ... } repeated maybe 17 times, and then suddenly if (cc && cc->xor) { ... } and it sort of makes you wonder if something suddenly could have changed cc, but indeed there is not. -- Mikael Magnusson