From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10517 invoked by alias); 28 Feb 2016 03:31:35 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 1706 invoked by uid 89); 28 Feb 2016 03:24:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=mistakenly, hassle, Hx-languages-length:955 X-HELO: zimbra.cs.ucla.edu Subject: Re: [PATCH 3/3] posix: New Linux posix_spawn{p} implementation To: Adhemerval Zanella , libc-alpha@sourceware.org References: <1456495001-5298-1-git-send-email-adhemerval.zanella@linaro.org> <1456495001-5298-4-git-send-email-adhemerval.zanella@linaro.org> <56D0B319.3060005@cs.ucla.edu> <56D0D129.2070201@linaro.org> From: Paul Eggert Message-ID: <56D26862.9090702@cs.ucla.edu> Date: Sun, 28 Feb 2016 16:41:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56D0D129.2070201@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-02/txt/msg00856.txt.bz2 Adhemerval Zanella wrote: > I see using const on complex expression might help compiler > get logic errors (where the variable is set to a different value) In that case, you should also put "register" in your local declarations too, right? Something like this: register const int prot = PROT_READ | PROT_WRITE; That way, you are also guarded against errors where later code mistakenly attempts to take the address of 'prot'. You may think I'm joking, but I have worked with programmers who believe in this sort of thing, and I have experience with (non-GNU) code using this style. The problem with this approach is that the attributes get in the way of reading the code. Attributes like 'const' can make sense for globals, but for local variables the hassle of maintaining them typically outweighs the meager benefits of having them. That's certainly the case for this example, anyway.