From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbcFNWUE (ORCPT ); Tue, 14 Jun 2016 18:20:04 -0400 Received: from relay3.sgi.com ([192.48.152.1]:49472 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750977AbcFNWUB (ORCPT ); Tue, 14 Jun 2016 18:20:01 -0400 Date: Tue, 14 Jun 2016 17:19:58 -0500 From: Joseph Thelen To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Alex Thorlton , Matt Fleming , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-efi@vger.kernel.org Subject: Re: [PATCH] x86/efi: Auto enable EFI memmap on SGI UV systems Message-ID: <20160614221958.GB172952@stormcage.americas.sgi.com> References: <1464900635-11957-1-git-send-email-jthelen@sgi.com> <1464900635-11957-2-git-send-email-jthelen@sgi.com> <20160608111223.GA5772@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160608111223.GA5772@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 08, 2016 at 01:12:23PM +0200, Ingo Molnar wrote: > > * Joseph Thelen wrote: > > > static int __init setup_add_efi_memmap(char *arg) > > { > > + static bool arg_as_bool; > > Why hidden inside local variables as static? Likely muscle memory of some kind after being forced to do a bunch of things in Java for awhile. Thanks for pointing that out. > > > + int ret = strtobool(arg, &arg_as_bool); > > + > > + /* check for a non-existent arg, to maintain backward compatibility */ > > + if (!arg) { > > + add_efi_memmap = EFI_MEMMAP_ENABLED; > > + } else { > > + if (ret) { > > + /* a bad argument was passed... */ > > + return ret; > > + } else { > > + if (arg_as_bool) > > + add_efi_memmap = EFI_MEMMAP_ENABLED; > > + else > > + add_efi_memmap = EFI_MEMMAP_DISABLED; > > + } > > + } > > + > > return 0; > > And that's a really weird code flow! > > How about something straightforward: > > int val = 0; > int ret; > > /* Check for a non-existent arg, to maintain backward compatibility: */ > if (!arg) { > add_efi_memmap = EFI_MEMMAP_ENABLED; > return 0; > } > > ret = strtobool(arg, &val); > > /* Was a bad argument passed? */ > if (ret) > return ret; > > if (val) > add_efi_memmap = EFI_MEMMAP_ENABLED; > else > add_efi_memmap = EFI_MEMMAP_DISABLED; > > return 0; > > ? > > Also note the rename to 'val'. > > Thanks, > > Ingo That certainly is much cleaner! Having only recently come from a place where "extra" returns were to be avoided at any cost, the fact that they do not appear to be quite so tabo here is nice. These changes will be made to whatever version of this comes into being after considering Matt Fleming's comments. Thanks, Joseph Thelen