Re: [PATCH bpf-next v1 1/2] bpf: changes_pkt_data: correct the 'main' error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/3/25 6:39 PM, Jason Xing wrote:
When compiling the selftests, the following error is printed out:
selftests/bpf/prog_tests/changes_pkt_data.c: In function ‘test_aux’:
selftests/bpf/prog_tests/changes_pkt_data.c:22:27: error: ‘main’ is usually a function [-Werror=main]
   struct changes_pkt_data *main = NULL;

The bpf CI has been testing this piece with different compilers. I also don't see it in my environment. How to reproduce it and which compiler?

Fix it by replacing with 'main_data'.

Signed-off-by: Jason Xing <kerneljasonxing@xxxxxxxxx>
---
  .../selftests/bpf/prog_tests/changes_pkt_data.c      | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c b/tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c
index 7526de379081..b5c9031ec470 100644
--- a/tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c
+++ b/tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c
@@ -19,7 +19,7 @@ static void test_aux(const char *main_prog_name,
  	struct bpf_program *freplace_prog = NULL;
  	struct bpf_program *main_prog = NULL;
  	LIBBPF_OPTS(bpf_object_open_opts, opts);
-	struct changes_pkt_data *main = NULL;
+	struct changes_pkt_data *main_data = NULL;
  	char log[16*1024];
  	int err;
@@ -27,14 +27,14 @@ static void test_aux(const char *main_prog_name,
  	opts.kernel_log_size = sizeof(log);
  	if (env.verbosity >= VERBOSE_SUPER)
  		opts.kernel_log_level = 1 | 2 | 4;
-	main = changes_pkt_data__open_opts(&opts);
-	if (!ASSERT_OK_PTR(main, "changes_pkt_data__open"))
+	main_data = changes_pkt_data__open_opts(&opts);
+	if (!ASSERT_OK_PTR(main_data, "changes_pkt_data__open"))
  		goto out;
-	main_prog = bpf_object__find_program_by_name(main->obj, main_prog_name);
+	main_prog = bpf_object__find_program_by_name(main_data->obj, main_prog_name);
  	if (!ASSERT_OK_PTR(main_prog, "main_prog"))
  		goto out;
  	bpf_program__set_autoload(main_prog, true);
-	err = changes_pkt_data__load(main);
+	err = changes_pkt_data__load(main_data);
  	print_verifier_log(log);
  	if (!ASSERT_OK(err, "changes_pkt_data__load"))
  		goto out;
@@ -60,7 +60,7 @@ static void test_aux(const char *main_prog_name,
out:
  	changes_pkt_data_freplace__destroy(freplace);
-	changes_pkt_data__destroy(main);
+	changes_pkt_data__destroy(main_data);
  }
/* There are two global subprograms in both changes_pkt_data.skel.h:





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux