Commit 925a0157 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Daniel Borkmann
Browse files

selftests/bpf: Fix compiler warnings reported in -O2 mode



Fix a bunch of potentially unitialized variable usage warnings that are
reported by GCC in -O2 mode. Also silence overzealous stringop-truncation
class of warnings.

Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20231006175744.3136675-1-andrii@kernel.org
parent bc5bc309
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ endif
BPF_GCC		?= $(shell command -v bpf-gcc;)
SAN_CFLAGS	?=
SAN_LDFLAGS	?= $(SAN_CFLAGS)
CFLAGS += -g -O0 -rdynamic -Wall -Werror $(GENFLAGS) $(SAN_CFLAGS)	\
CFLAGS += -g -O0 -rdynamic						\
	  -Wall -Werror 						\
	  $(GENFLAGS) $(SAN_CFLAGS)					\
	  -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR)		\
	  -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT)
LDFLAGS += $(SAN_LDFLAGS)
+2 −2
Original line number Diff line number Diff line
@@ -33,11 +33,11 @@ static void create_inner_maps(enum bpf_map_type map_type,
{
	int map_fd, map_index, ret;
	__u32 map_key = 0, map_id;
	char map_name[15];
	char map_name[16];

	for (map_index = 0; map_index < OUTER_MAP_ENTRIES; map_index++) {
		memset(map_name, 0, sizeof(map_name));
		sprintf(map_name, "inner_map_fd_%d", map_index);
		snprintf(map_name, sizeof(map_name), "inner_map_fd_%d", map_index);
		map_fd = bpf_map_create(map_type, map_name, sizeof(__u32),
					sizeof(__u32), 1, NULL);
		CHECK(map_fd < 0,
+2 −2
Original line number Diff line number Diff line
@@ -193,8 +193,8 @@ static int setup_progs(struct bloom_filter_map **out_skel, __u32 **out_rand_vals

void test_bloom_filter_map(void)
{
	__u32 *rand_vals, nr_rand_vals;
	struct bloom_filter_map *skel;
	__u32 *rand_vals = NULL, nr_rand_vals = 0;
	struct bloom_filter_map *skel = NULL;
	int err;

	test_fail_cases();
+2 −2
Original line number Diff line number Diff line
@@ -28,9 +28,9 @@ static void subtest(int cgroup_fd, struct connect_ping *skel,
		.sin6_family = AF_INET6,
		.sin6_addr = IN6ADDR_LOOPBACK_INIT,
	};
	struct sockaddr *sa;
	struct sockaddr *sa = NULL;
	socklen_t sa_len;
	int protocol;
	int protocol = -1;
	int sock_fd;

	switch (family) {
+1 −1
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ static struct btf *init_btf(void)

static void list_and_rb_node_same_struct(bool refcount_field)
{
	int bpf_rb_node_btf_id, bpf_refcount_btf_id, foo_btf_id;
	int bpf_rb_node_btf_id, bpf_refcount_btf_id = 0, foo_btf_id;
	struct btf *btf;
	int id, err;

Loading