All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8712: Remove redundant braces in if statements
@ 2023-07-21  2:05 Sergey Rozhnov
  2023-07-21  4:11 ` Greg Kroah-Hartman
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sergey Rozhnov @ 2023-07-21  2:05 UTC (permalink / raw)
  To: Larry Finger, Florian Schilhabel, Greg Kroah-Hartman,
	linux-staging, linux-kernel

Extract masked value to improve readability, apply fix suggested by checkpatch.
---
 drivers/staging/rtl8712/ieee80211.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c
index 7d8f1a29d18a..fe53453ab9a7 100644
--- a/drivers/staging/rtl8712/ieee80211.c
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -63,8 +63,9 @@ uint r8712_is_cckrates_included(u8 *rate)
 	u32 i = 0;
 
 	while (rate[i] != 0) {
-		if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
-		    (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
+		u8 val = rate[i] & 0x7f;
+
+		if (val == 2 || val == 4 || val == 11 || val == 22)
 			return true;
 		i++;
 	}
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: rtl8712: Remove redundant braces in if statements
  2023-07-21  2:05 [PATCH] staging: rtl8712: Remove redundant braces in if statements Sergey Rozhnov
@ 2023-07-21  4:11 ` Greg Kroah-Hartman
  2023-07-21  4:57 ` Larry Finger
  2023-07-21  6:01 ` Dan Carpenter
  2 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-07-21  4:11 UTC (permalink / raw)
  To: Sergey Rozhnov
  Cc: Larry Finger, Florian Schilhabel, linux-staging, linux-kernel

On Fri, Jul 21, 2023 at 06:05:57AM +0400, Sergey Rozhnov wrote:
> Extract masked value to improve readability, apply fix suggested by checkpatch.
> ---
>  drivers/staging/rtl8712/ieee80211.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c
> index 7d8f1a29d18a..fe53453ab9a7 100644
> --- a/drivers/staging/rtl8712/ieee80211.c
> +++ b/drivers/staging/rtl8712/ieee80211.c
> @@ -63,8 +63,9 @@ uint r8712_is_cckrates_included(u8 *rate)
>  	u32 i = 0;
>  
>  	while (rate[i] != 0) {
> -		if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
> -		    (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
> +		u8 val = rate[i] & 0x7f;
> +
> +		if (val == 2 || val == 4 || val == 11 || val == 22)
>  			return true;
>  		i++;
>  	}
> -- 
> 2.40.1
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch does not have a Signed-off-by: line.  Please read the
  kernel file, Documentation/process/submitting-patches.rst and resend
  it after adding that line.  Note, the line needs to be in the body of
  the email, before the patch, not at the bottom of the patch or in the
  email signature.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/process/submitting-patches.rst for what is needed in
  order to properly describe the change.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: rtl8712: Remove redundant braces in if statements
  2023-07-21  2:05 [PATCH] staging: rtl8712: Remove redundant braces in if statements Sergey Rozhnov
  2023-07-21  4:11 ` Greg Kroah-Hartman
@ 2023-07-21  4:57 ` Larry Finger
  2023-07-21  6:01 ` Dan Carpenter
  2 siblings, 0 replies; 5+ messages in thread
From: Larry Finger @ 2023-07-21  4:57 UTC (permalink / raw)
  To: Sergey Rozhnov, Florian Schilhabel, Greg Kroah-Hartman,
	linux-staging, linux-kernel

On 7/20/23 21:05, Sergey Rozhnov wrote:
> Extract masked value to improve readability, apply fix suggested by checkpatch.
> ---
>   drivers/staging/rtl8712/ieee80211.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c
> index 7d8f1a29d18a..fe53453ab9a7 100644
> --- a/drivers/staging/rtl8712/ieee80211.c
> +++ b/drivers/staging/rtl8712/ieee80211.c
> @@ -63,8 +63,9 @@ uint r8712_is_cckrates_included(u8 *rate)
>   	u32 i = 0;
>   
>   	while (rate[i] != 0) {
> -		if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
> -		    (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
> +		u8 val = rate[i] & 0x7f;
> +
> +		if (val == 2 || val == 4 || val == 11 || val == 22)
>   			return true;
>   		i++;
>   	}

The value of such a patch is marginal. The compiler will optimize it and only 
calculate the value of rate[i] & 0x7f once, and keep it in a register, which is 
likely what happens with your change as val will never be used again. Checkpatch 
is only suggestive and can be ignored.

You have no signed-off-by tag. As such, this patch could never be applied as it 
has no one vouching that they are the author. Please read and follow the 
instructions for submitting patches.

Larry


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: rtl8712: Remove redundant braces in if statements
  2023-07-21  2:05 [PATCH] staging: rtl8712: Remove redundant braces in if statements Sergey Rozhnov
  2023-07-21  4:11 ` Greg Kroah-Hartman
  2023-07-21  4:57 ` Larry Finger
@ 2023-07-21  6:01 ` Dan Carpenter
  2023-07-21  6:34   ` Joe Perches
  2 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-07-21  6:01 UTC (permalink / raw)
  To: Sergey Rozhnov
  Cc: Larry Finger, Florian Schilhabel, Greg Kroah-Hartman,
	linux-staging, linux-kernel

On Fri, Jul 21, 2023 at 06:05:57AM +0400, Sergey Rozhnov wrote:
> Extract masked value to improve readability, apply fix suggested by checkpatch.
> ---

I like the new format, but you need to run checkpatch on your patches.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] staging: rtl8712: Remove redundant braces in if statements
  2023-07-21  6:01 ` Dan Carpenter
@ 2023-07-21  6:34   ` Joe Perches
  0 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2023-07-21  6:34 UTC (permalink / raw)
  To: Dan Carpenter, Sergey Rozhnov
  Cc: Larry Finger, Florian Schilhabel, Greg Kroah-Hartman,
	linux-staging, linux-kernel

On Fri, 2023-07-21 at 09:01 +0300, Dan Carpenter wrote:
> On Fri, Jul 21, 2023 at 06:05:57AM +0400, Sergey Rozhnov wrote:
> > Extract masked value to improve readability, apply fix suggested by checkpatch.
> > ---
> 
> I like the new format, but you need to run checkpatch on your patches.
> 

True, but this does only 1 of 2 very similar functions.
Ideally both would be done at the same time.

My preference would be to remove the int i and just
dereference rate similar to:

uint r8712_is_cckrates_included(u8 *rate)
{
	while (*rate) {
		u8 r = *rate & 0x7f;

		if (r == 2 || r == 4 || r == 11 || r == 22)
			return true;
		rate++;
	}

	return false;
}

uint r8712_is_cckratesonly_included(u8 *rate)
{
	while (*rate) {
		u8 r = *rate & 0x7f;

		if (r != 2 && r != 4 && r != 11  && r != 22)
			return false;
		rate++;
	}

	return true;
}

though the existing cckratesonly_included function
seemingly returns an incorrect true if the rate array
is empty.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-21  7:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21  2:05 [PATCH] staging: rtl8712: Remove redundant braces in if statements Sergey Rozhnov
2023-07-21  4:11 ` Greg Kroah-Hartman
2023-07-21  4:57 ` Larry Finger
2023-07-21  6:01 ` Dan Carpenter
2023-07-21  6:34   ` Joe Perches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.