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


Groups > linux.kernel > #1679657

Re: [PATCH] staging: sm750fb: skip unnecessary comparisons

From Greg KH <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] staging: sm750fb: skip unnecessary comparisons
Date 2017-07-03 08:20 +0200
Message-ID <tZ2Se-5BT-5@gated-at.bofh.it> (permalink)
References <tYYlz-2iZ-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jul 03, 2017 at 09:26:47AM +0800, Lynn Lei wrote:
> introduced early checks to skip unnecessary comparisons when flags set.

Why?

> 
> Signed-off-by: Lynn Lei <lynnl.wit@gmail.com>
> ---
>  drivers/staging/sm750fb/sm750.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index 386d4adcd91d..9e57a2d32465 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -1171,11 +1171,16 @@ static int __init lynxfb_setup(char *options)
>  	 */
>  	while ((opt = strsep(&options, ":")) != NULL) {
>  		/* options that mean for any lynx chips are configured here */
> -		if (!strncmp(opt, "noaccel", strlen("noaccel"))) {
> +
> +		/*
> +		 * NOTE: the length of options is hard-coded
> +		 * if any of those options changed  please update its length
> +		 */

That's not good, why require this?  What is wrong with the original code
here?  It doesn't have that type of restriction, right?

> +		if (!g_noaccel && !strncmp(opt, "noaccel", 7)) {
>  			g_noaccel = 1;
> -		} else if (!strncmp(opt, "nomtrr", strlen("nomtrr"))) {
> +		} else if (!g_nomtrr && !strncmp(opt, "nomtrr", 6)) {

I don't see the benefit of this change at all, what am I missing?

thanks,

greg k-h

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] staging: sm750fb: skip unnecessary comparisons Lynn Lei <lynnl.wit@gmail.com> - 2017-07-03 03:30 +0200
  Re: [PATCH] staging: sm750fb: skip unnecessary comparisons Greg KH <gregkh@linuxfoundation.org> - 2017-07-03 08:20 +0200

csiph-web