Skip to content

Commit 3349158

Browse files
roxellborkmann
authored andcommitted
kernel/bpf/syscall: fix warning defined but not used
There will be a build warning -Wunused-function if CONFIG_CGROUP_BPF isn't defined, since the only user is inside #ifdef CONFIG_CGROUP_BPF: kernel/bpf/syscall.c:1229:12: warning: ‘bpf_prog_attach_check_attach_type’ defined but not used [-Wunused-function] static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Current code moves function bpf_prog_attach_check_attach_type inside ifdef CONFIG_CGROUP_BPF. Fixes: 5e43f89 ("bpf: Check attach type at prog load time") Signed-off-by: Anders Roxell <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 0e94d87 commit 3349158

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

kernel/bpf/syscall.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,18 +1226,6 @@ bpf_prog_load_check_attach_type(enum bpf_prog_type prog_type,
12261226
}
12271227
}
12281228

1229-
static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
1230-
enum bpf_attach_type attach_type)
1231-
{
1232-
switch (prog->type) {
1233-
case BPF_PROG_TYPE_CGROUP_SOCK:
1234-
case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
1235-
return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
1236-
default:
1237-
return 0;
1238-
}
1239-
}
1240-
12411229
/* last field in 'union bpf_attr' used by this command */
12421230
#define BPF_PROG_LOAD_LAST_FIELD expected_attach_type
12431231

@@ -1465,6 +1453,18 @@ static int bpf_raw_tracepoint_open(const union bpf_attr *attr)
14651453

14661454
#ifdef CONFIG_CGROUP_BPF
14671455

1456+
static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
1457+
enum bpf_attach_type attach_type)
1458+
{
1459+
switch (prog->type) {
1460+
case BPF_PROG_TYPE_CGROUP_SOCK:
1461+
case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
1462+
return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
1463+
default:
1464+
return 0;
1465+
}
1466+
}
1467+
14681468
#define BPF_PROG_ATTACH_LAST_FIELD attach_flags
14691469

14701470
static int sockmap_get_from_fd(const union bpf_attr *attr,

0 commit comments

Comments
 (0)