All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii@kernel.org>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>
Cc: <andrii@kernel.org>, <kernel-team@meta.com>, Tejun Heo <tj@kernel.org>
Subject: [PATCH bpf-next 1/4] selftests/bpf: prevent unused variable warning in bpf_for()
Date: Wed, 8 Mar 2023 21:40:12 -0800	[thread overview]
Message-ID: <20230309054015.4068562-2-andrii@kernel.org> (raw)
In-Reply-To: <20230309054015.4068562-1-andrii@kernel.org>

Add __attribute__((unused)) to inner __p variable inside bpf_for(),
bpf_for_each(), and bpf_repeat() macros to avoid compiler warnings about
unused variable.

Reported-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/testing/selftests/bpf/progs/bpf_misc.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
index 43b154a639e7..c95eb603403c 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -115,7 +115,8 @@ extern void bpf_iter_num_destroy(struct bpf_iter_num *it) __ksym;
 	struct bpf_iter_##type ___it __attribute__((aligned(8), /* enforce, just in case */,	\
 						    cleanup(bpf_iter_##type##_destroy))),	\
 	/* ___p pointer is just to call bpf_iter_##type##_new() *once* to init ___it */		\
-			       *___p = (bpf_iter_##type##_new(&___it, ##args),			\
+			       *___p __attribute__((unused)) = (				\
+					bpf_iter_##type##_new(&___it, ##args),			\
 	/* this is a workaround for Clang bug: it currently doesn't emit BTF */			\
 	/* for bpf_iter_##type##_destroy() when used from cleanup() attribute */		\
 					(void)bpf_iter_##type##_destroy, (void *)0);		\
@@ -143,7 +144,8 @@ extern void bpf_iter_num_destroy(struct bpf_iter_num *it) __ksym;
 	struct bpf_iter_num ___it __attribute__((aligned(8), /* enforce, just in case */	\
 						 cleanup(bpf_iter_num_destroy))),		\
 	/* ___p pointer is necessary to call bpf_iter_num_new() *once* to init ___it */		\
-			    *___p = (bpf_iter_num_new(&___it, (start), (end)),			\
+			    *___p __attribute__((unused)) = (					\
+				bpf_iter_num_new(&___it, (start), (end)),			\
 	/* this is a workaround for Clang bug: it currently doesn't emit BTF */			\
 	/* for bpf_iter_num_destroy() when used from cleanup() attribute */			\
 				(void)bpf_iter_num_destroy, (void *)0);				\
@@ -167,7 +169,8 @@ extern void bpf_iter_num_destroy(struct bpf_iter_num *it) __ksym;
 	struct bpf_iter_num ___it __attribute__((aligned(8), /* enforce, just in case */	\
 						 cleanup(bpf_iter_num_destroy))),		\
 	/* ___p pointer is necessary to call bpf_iter_num_new() *once* to init ___it */		\
-			    *___p = (bpf_iter_num_new(&___it, 0, (N)),				\
+			    *___p __attribute__((unused)) = (					\
+				bpf_iter_num_new(&___it, 0, (N)),				\
 	/* this is a workaround for Clang bug: it currently doesn't emit BTF */			\
 	/* for bpf_iter_num_destroy() when used from cleanup() attribute */			\
 				(void)bpf_iter_num_destroy, (void *)0);				\
-- 
2.34.1


  reply	other threads:[~2023-03-09  5:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09  5:40 [PATCH bpf-next 0/4] selftests/bpf: make BPF_CFLAGS stricter with -Wall Andrii Nakryiko
2023-03-09  5:40 ` Andrii Nakryiko [this message]
2023-03-09  5:40 ` [PATCH bpf-next 2/4] selftests/bpf: add __sink() macro to fake variable consumption Andrii Nakryiko
2023-03-09  5:40 ` [PATCH bpf-next 3/4] selftests/bpf: fix lots of silly mistakes pointed out by compiler Andrii Nakryiko
2023-03-09  5:40 ` [PATCH bpf-next 4/4] selftests/bpf: make BPF compiler flags stricter Andrii Nakryiko
2023-03-10 16:20 ` [PATCH bpf-next 0/4] selftests/bpf: make BPF_CFLAGS stricter with -Wall patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230309054015.4068562-2-andrii@kernel.org \
    --to=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.