Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1422405 > unrolled thread

Re: [PATCH] x86/efi: Auto enable EFI memmap on SGI UV systems

Started byJoseph Thelen <jthelen@sgi.com>
First post2016-06-15 00:30 +0200
Last post2016-06-15 00:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] x86/efi: Auto enable EFI memmap on SGI UV systems Joseph Thelen <jthelen@sgi.com> - 2016-06-15 00:30 +0200

#1422405 — Re: [PATCH] x86/efi: Auto enable EFI memmap on SGI UV systems

FromJoseph Thelen <jthelen@sgi.com>
Date2016-06-15 00:30 +0200
SubjectRe: [PATCH] x86/efi: Auto enable EFI memmap on SGI UV systems
Message-ID<rK50m-2si-23@gated-at.bofh.it>
On Wed, Jun 08, 2016 at 01:12:23PM +0200, Ingo Molnar wrote:
> 
> * Joseph Thelen <jthelen@sgi.com> 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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web