mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][next] bpf: replace redundant |= operation with assignmen
@ 2024-10-31 13:07 Colin Ian King
  2024-11-01 19:30 ` Andrii Nakryiko
  2024-11-02 11:27 ` Christian Heusel
  0 siblings, 2 replies; 3+ messages in thread
From: Colin Ian King @ 2024-10-31 13:07 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	bpf
  Cc: kernel-janitors, linux-kernel

The operation msk |= ~0ULL contains a redundant bit-wise or operation
since all the bits are going to be set to 1, so replace this with
an assignment since this is more optimal and probably clearer too.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 kernel/bpf/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 9aaf5124648b..fea07e12601f 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -914,7 +914,7 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
 		str = param->string;
 		while ((p = strsep(&str, ":"))) {
 			if (strcmp(p, "any") == 0) {
-				msk |= ~0ULL;
+				msk = ~0ULL;
 			} else if (find_btf_enum_const(info.btf, enum_t, enum_pfx, p, &val)) {
 				msk |= 1ULL << val;
 			} else {
-- 
2.39.5


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

* Re: [PATCH][next] bpf: replace redundant |= operation with assignmen
  2024-10-31 13:07 [PATCH][next] bpf: replace redundant |= operation with assignmen Colin Ian King
@ 2024-11-01 19:30 ` Andrii Nakryiko
  2024-11-02 11:27 ` Christian Heusel
  1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2024-11-01 19:30 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	bpf, kernel-janitors, linux-kernel

On Thu, Oct 31, 2024 at 6:07 AM Colin Ian King <colin.i.king@gmail.com> wrote:
>
> The operation msk |= ~0ULL contains a redundant bit-wise or operation
> since all the bits are going to be set to 1, so replace this with
> an assignment since this is more optimal and probably clearer too.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  kernel/bpf/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index 9aaf5124648b..fea07e12601f 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -914,7 +914,7 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
>                 str = param->string;
>                 while ((p = strsep(&str, ":"))) {
>                         if (strcmp(p, "any") == 0) {
> -                               msk |= ~0ULL;
> +                               msk = ~0ULL;

This was done for consistency with the other branch. Is there anything
wrong with this code? Doesn't seem so, so I'd like to keep it as is.

pw-bot: cr

>                         } else if (find_btf_enum_const(info.btf, enum_t, enum_pfx, p, &val)) {
>                                 msk |= 1ULL << val;
>                         } else {
> --
> 2.39.5
>

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

* Re: [PATCH][next] bpf: replace redundant |= operation with assignmen
  2024-10-31 13:07 [PATCH][next] bpf: replace redundant |= operation with assignmen Colin Ian King
  2024-11-01 19:30 ` Andrii Nakryiko
@ 2024-11-02 11:27 ` Christian Heusel
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Heusel @ 2024-11-02 11:27 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	bpf, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]

On 24/10/31 01:07PM, Colin Ian King wrote:
> The operation msk |= ~0ULL contains a redundant bit-wise or operation
> since all the bits are going to be set to 1, so replace this with
> an assignment since this is more optimal and probably clearer too.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  kernel/bpf/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index 9aaf5124648b..fea07e12601f 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -914,7 +914,7 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  		str = param->string;
>  		while ((p = strsep(&str, ":"))) {
>  			if (strcmp(p, "any") == 0) {
> -				msk |= ~0ULL;
> +				msk = ~0ULL;
>  			} else if (find_btf_enum_const(info.btf, enum_t, enum_pfx, p, &val)) {
>  				msk |= 1ULL << val;
>  			} else {
> -- 
> 2.39.5

The patch subject contains a typo ("assignmen" should be "assignment"),
but maybe this can just be fixed on apply ..

Cheers,
Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2024-11-02 11:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-31 13:07 [PATCH][next] bpf: replace redundant |= operation with assignmen Colin Ian King
2024-11-01 19:30 ` Andrii Nakryiko
2024-11-02 11:27 ` Christian Heusel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®