* [PATCH 2/2] btf: Fix error of Macros with multiple statements
@ 2022-06-29 17:19 Jules Irenge
2022-06-29 17:36 ` Martin KaFai Lau
0 siblings, 1 reply; 2+ messages in thread
From: Jules Irenge @ 2022-06-29 17:19 UTC (permalink / raw)
To: Martin KaFai Lau
Cc: Elana.Copperman, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Song Liu, Yonghong Song, John Fastabend,
KP Singh, netdev, bpf, linux-kernel
This patch fixes an error reported by checkpatch.pl
ERROR: Macros with multiple statements should be
enclosed in a do while loop
To fix this a do while(0) loop is used
to encloses the multiple statements.
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
kernel/bpf/btf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 1bc496162572..95c1ee525e28 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -5057,8 +5057,10 @@ extern struct btf *btf_vmlinux;
static union {
struct bpf_ctx_convert {
#define BPF_PROG_TYPE(_id, _name, prog_ctx_type, kern_ctx_type) \
- prog_ctx_type _id##_prog; \
- kern_ctx_type _id##_kern;
+ do { \
+ prog_ctx_type _id##_prog; \
+ kern_ctx_type _id##_kern; \
+ } while (0)
#include <linux/bpf_types.h>
#undef BPF_PROG_TYPE
} *__t;
--
2.36.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] btf: Fix error of Macros with multiple statements
2022-06-29 17:19 [PATCH 2/2] btf: Fix error of Macros with multiple statements Jules Irenge
@ 2022-06-29 17:36 ` Martin KaFai Lau
0 siblings, 0 replies; 2+ messages in thread
From: Martin KaFai Lau @ 2022-06-29 17:36 UTC (permalink / raw)
To: Jules Irenge
Cc: Elana.Copperman, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Song Liu, Yonghong Song, John Fastabend,
KP Singh, netdev, bpf, linux-kernel
On Wed, Jun 29, 2022 at 06:19:30PM +0100, Jules Irenge wrote:
> This patch fixes an error reported by checkpatch.pl
No. It is not a fix.
Have you at least compiler tested it ?
>
> ERROR: Macros with multiple statements should be
> enclosed in a do while loop
>
> To fix this a do while(0) loop is used
> to encloses the multiple statements.
>
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> ---
> kernel/bpf/btf.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 1bc496162572..95c1ee525e28 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -5057,8 +5057,10 @@ extern struct btf *btf_vmlinux;
> static union {
> struct bpf_ctx_convert {
> #define BPF_PROG_TYPE(_id, _name, prog_ctx_type, kern_ctx_type) \
> - prog_ctx_type _id##_prog; \
> - kern_ctx_type _id##_kern;
> + do { \
> + prog_ctx_type _id##_prog; \
> + kern_ctx_type _id##_kern; \
> + } while (0)
> #include <linux/bpf_types.h>
> #undef BPF_PROG_TYPE
> } *__t;
> --
> 2.36.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-29 17:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-29 17:19 [PATCH 2/2] btf: Fix error of Macros with multiple statements Jules Irenge
2022-06-29 17:36 ` Martin KaFai Lau
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).