linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] bpf: Convert to use the preferred fallthrough macro
@ 2020-08-15  1:48 linmiaohe
  0 siblings, 0 replies; 5+ messages in thread
From: linmiaohe @ 2020-08-15  1:48 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, john fastabend, KP Singh,
	David S. Miller, Jakub Kicinski, Jesper Dangaard Brouer,
	Networking, bpf, open list

Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
On Fri, Aug 14, 2020 at 2:58 AM Miaohe Lin <linmiaohe@huawei.com> wrote:
>>
>> Convert the uses of fallthrough comments to fallthrough macro.
>> @@ -1794,7 +1794,7 @@ static bool cg_sockopt_is_valid_access(int off, int size,
>>                         return prog->expected_attach_type ==
>>                                 BPF_CGROUP_GETSOCKOPT;
>>                 case offsetof(struct bpf_sockopt, optname):
>> -                       /* fallthrough */
>> +                       fallthrough;
>
>this fallthrough is not event necessary, let's drop it instead?

Will do. Many thanks.

>
>>                 case offsetof(struct bpf_sockopt, level):
>>                         if (size != size_default)
>>                                 return false;
>
> [...]

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

* Re: [PATCH] bpf: Convert to use the preferred fallthrough macro
@ 2020-08-15  1:50 linmiaohe
  0 siblings, 0 replies; 5+ messages in thread
From: linmiaohe @ 2020-08-15  1:50 UTC (permalink / raw)
  To: Yonghong Song
  Cc: ast, daniel, kafai, songliubraving, andriin, john.fastabend,
	kpsingh, davem, kuba, hawk, netdev, bpf, linux-kernel

Yonghong Song <yhs@fb.com> wrote:
>On 8/14/20 2:16 AM, Miaohe Lin wrote:
>> Convert the uses of fallthrough comments to fallthrough macro.
>> 
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>
>This is not a bug fix but rather an enhancement so not sure whether this should push to bpf tree or wait until bpf-next.
>
>It may be worthwhile to mention Commit 294f69e662d1
> ("compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use") so people can understand why this patch is needed.
>

Will do. Many thanks.

>With above suggestions,
>Acked-by: Yonghong Song <yhs@fb.com>
>


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

* Re: [PATCH] bpf: Convert to use the preferred fallthrough macro
  2020-08-14  9:16 Miaohe Lin
  2020-08-14 16:55 ` Yonghong Song
@ 2020-08-14 17:11 ` Andrii Nakryiko
  1 sibling, 0 replies; 5+ messages in thread
From: Andrii Nakryiko @ 2020-08-14 17:11 UTC (permalink / raw)
  To: Miaohe Lin
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, john fastabend, KP Singh,
	David S. Miller, Jakub Kicinski, Jesper Dangaard Brouer,
	Networking, bpf, open list

On Fri, Aug 14, 2020 at 2:58 AM Miaohe Lin <linmiaohe@huawei.com> wrote:
>
> Convert the uses of fallthrough comments to fallthrough macro.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  kernel/bpf/cgroup.c   | 2 +-
>  kernel/bpf/cpumap.c   | 2 +-
>  kernel/bpf/syscall.c  | 2 +-
>  kernel/bpf/verifier.c | 6 +++---
>  4 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
> index 83ff127ef7ae..e21de4f1754c 100644
> --- a/kernel/bpf/cgroup.c
> +++ b/kernel/bpf/cgroup.c
> @@ -1794,7 +1794,7 @@ static bool cg_sockopt_is_valid_access(int off, int size,
>                         return prog->expected_attach_type ==
>                                 BPF_CGROUP_GETSOCKOPT;
>                 case offsetof(struct bpf_sockopt, optname):
> -                       /* fallthrough */
> +                       fallthrough;

this fallthrough is not event necessary, let's drop it instead?

>                 case offsetof(struct bpf_sockopt, level):
>                         if (size != size_default)
>                                 return false;

[...]

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

* Re: [PATCH] bpf: Convert to use the preferred fallthrough macro
  2020-08-14  9:16 Miaohe Lin
@ 2020-08-14 16:55 ` Yonghong Song
  2020-08-14 17:11 ` Andrii Nakryiko
  1 sibling, 0 replies; 5+ messages in thread
From: Yonghong Song @ 2020-08-14 16:55 UTC (permalink / raw)
  To: Miaohe Lin, ast, daniel, kafai, songliubraving, andriin,
	john.fastabend, kpsingh, davem, kuba, hawk
  Cc: netdev, bpf, linux-kernel



On 8/14/20 2:16 AM, Miaohe Lin wrote:
> Convert the uses of fallthrough comments to fallthrough macro.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

This is not a bug fix but rather an enhancement so not sure whether
this should push to bpf tree or wait until bpf-next.

It may be worthwhile to mention Commit 294f69e662d1 
("compiler_attributes.h: Add 'fallthrough' pseudo keyword for 
switch/case use") so people can understand why this patch is
needed.

With above suggestions,
Acked-by: Yonghong Song <yhs@fb.com>

> ---
>   kernel/bpf/cgroup.c   | 2 +-
>   kernel/bpf/cpumap.c   | 2 +-
>   kernel/bpf/syscall.c  | 2 +-
>   kernel/bpf/verifier.c | 6 +++---
>   4 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
> index 83ff127ef7ae..e21de4f1754c 100644
> --- a/kernel/bpf/cgroup.c
> +++ b/kernel/bpf/cgroup.c
> @@ -1794,7 +1794,7 @@ static bool cg_sockopt_is_valid_access(int off, int size,
>   			return prog->expected_attach_type ==
>   				BPF_CGROUP_GETSOCKOPT;
>   		case offsetof(struct bpf_sockopt, optname):
> -			/* fallthrough */
> +			fallthrough;
>   		case offsetof(struct bpf_sockopt, level):
>   			if (size != size_default)
>   				return false;
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index f1c46529929b..6386b7bb98f2 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -279,7 +279,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
>   			break;
>   		default:
>   			bpf_warn_invalid_xdp_action(act);
> -			/* fallthrough */
> +			fallthrough;
>   		case XDP_DROP:
>   			xdp_return_frame(xdpf);
>   			stats->drop++;
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 86299a292214..1bf960aa615c 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -2029,7 +2029,7 @@ bpf_prog_load_check_attach(enum bpf_prog_type prog_type,
>   	case BPF_PROG_TYPE_EXT:
>   		if (expected_attach_type)
>   			return -EINVAL;
> -		/* fallthrough */
> +		fallthrough;
>   	default:
>   		return 0;
>   	}
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index ef938f17b944..1e7f34663f86 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -2639,7 +2639,7 @@ static bool may_access_direct_pkt_data(struct bpf_verifier_env *env,
>   	case BPF_PROG_TYPE_CGROUP_SKB:
>   		if (t == BPF_WRITE)
>   			return false;
> -		/* fallthrough */
> +		fallthrough;
>   
>   	/* Program types with direct read + write access go here! */
>   	case BPF_PROG_TYPE_SCHED_CLS:
> @@ -5236,7 +5236,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
>   				off_reg == dst_reg ? dst : src);
>   			return -EACCES;
>   		}
> -		/* fall-through */
> +		fallthrough;
>   	default:
>   		break;
>   	}
> @@ -10988,7 +10988,7 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
>   	default:
>   		if (!prog_extension)
>   			return -EINVAL;
> -		/* fallthrough */
> +		fallthrough;
>   	case BPF_MODIFY_RETURN:
>   	case BPF_LSM_MAC:
>   	case BPF_TRACE_FENTRY:
> 

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

* [PATCH] bpf: Convert to use the preferred fallthrough macro
@ 2020-08-14  9:16 Miaohe Lin
  2020-08-14 16:55 ` Yonghong Song
  2020-08-14 17:11 ` Andrii Nakryiko
  0 siblings, 2 replies; 5+ messages in thread
From: Miaohe Lin @ 2020-08-14  9:16 UTC (permalink / raw)
  To: ast, daniel, kafai, songliubraving, yhs, andriin, john.fastabend,
	kpsingh, davem, kuba, hawk
  Cc: netdev, bpf, linux-kernel, linmiaohe

Convert the uses of fallthrough comments to fallthrough macro.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 kernel/bpf/cgroup.c   | 2 +-
 kernel/bpf/cpumap.c   | 2 +-
 kernel/bpf/syscall.c  | 2 +-
 kernel/bpf/verifier.c | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 83ff127ef7ae..e21de4f1754c 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -1794,7 +1794,7 @@ static bool cg_sockopt_is_valid_access(int off, int size,
 			return prog->expected_attach_type ==
 				BPF_CGROUP_GETSOCKOPT;
 		case offsetof(struct bpf_sockopt, optname):
-			/* fallthrough */
+			fallthrough;
 		case offsetof(struct bpf_sockopt, level):
 			if (size != size_default)
 				return false;
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index f1c46529929b..6386b7bb98f2 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -279,7 +279,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
 			break;
 		default:
 			bpf_warn_invalid_xdp_action(act);
-			/* fallthrough */
+			fallthrough;
 		case XDP_DROP:
 			xdp_return_frame(xdpf);
 			stats->drop++;
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 86299a292214..1bf960aa615c 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2029,7 +2029,7 @@ bpf_prog_load_check_attach(enum bpf_prog_type prog_type,
 	case BPF_PROG_TYPE_EXT:
 		if (expected_attach_type)
 			return -EINVAL;
-		/* fallthrough */
+		fallthrough;
 	default:
 		return 0;
 	}
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index ef938f17b944..1e7f34663f86 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2639,7 +2639,7 @@ static bool may_access_direct_pkt_data(struct bpf_verifier_env *env,
 	case BPF_PROG_TYPE_CGROUP_SKB:
 		if (t == BPF_WRITE)
 			return false;
-		/* fallthrough */
+		fallthrough;
 
 	/* Program types with direct read + write access go here! */
 	case BPF_PROG_TYPE_SCHED_CLS:
@@ -5236,7 +5236,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
 				off_reg == dst_reg ? dst : src);
 			return -EACCES;
 		}
-		/* fall-through */
+		fallthrough;
 	default:
 		break;
 	}
@@ -10988,7 +10988,7 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
 	default:
 		if (!prog_extension)
 			return -EINVAL;
-		/* fallthrough */
+		fallthrough;
 	case BPF_MODIFY_RETURN:
 	case BPF_LSM_MAC:
 	case BPF_TRACE_FENTRY:
-- 
2.19.1


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

end of thread, other threads:[~2020-08-16  1:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-15  1:48 [PATCH] bpf: Convert to use the preferred fallthrough macro linmiaohe
  -- strict thread matches above, loose matches on Subject: below --
2020-08-15  1:50 linmiaohe
2020-08-14  9:16 Miaohe Lin
2020-08-14 16:55 ` Yonghong Song
2020-08-14 17:11 ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).