Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

libbpf: Constify few bpf_program getters

bpf_program__get_type() and bpf_program__get_expected_attach_type() shouldn't
modify given bpf_program, so mark input parameter as const struct bpf_program.
This eliminates unnecessary compilation warnings or explicit casts in user
programs.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210324172941.2609884-1-andrii@kernel.org

authored by

Andrii Nakryiko and committed by
Daniel Borkmann
a46410d5 5d903493

+4 -4
+2 -2
tools/lib/bpf/libbpf.c
··· 8458 8458 return fd; 8459 8459 } 8460 8460 8461 - enum bpf_prog_type bpf_program__get_type(struct bpf_program *prog) 8461 + enum bpf_prog_type bpf_program__get_type(const struct bpf_program *prog) 8462 8462 { 8463 8463 return prog->type; 8464 8464 } ··· 8503 8503 BPF_PROG_TYPE_FNS(sk_lookup, BPF_PROG_TYPE_SK_LOOKUP); 8504 8504 8505 8505 enum bpf_attach_type 8506 - bpf_program__get_expected_attach_type(struct bpf_program *prog) 8506 + bpf_program__get_expected_attach_type(const struct bpf_program *prog) 8507 8507 { 8508 8508 return prog->expected_attach_type; 8509 8509 }
+2 -2
tools/lib/bpf/libbpf.h
··· 361 361 LIBBPF_API int bpf_program__set_extension(struct bpf_program *prog); 362 362 LIBBPF_API int bpf_program__set_sk_lookup(struct bpf_program *prog); 363 363 364 - LIBBPF_API enum bpf_prog_type bpf_program__get_type(struct bpf_program *prog); 364 + LIBBPF_API enum bpf_prog_type bpf_program__get_type(const struct bpf_program *prog); 365 365 LIBBPF_API void bpf_program__set_type(struct bpf_program *prog, 366 366 enum bpf_prog_type type); 367 367 368 368 LIBBPF_API enum bpf_attach_type 369 - bpf_program__get_expected_attach_type(struct bpf_program *prog); 369 + bpf_program__get_expected_attach_type(const struct bpf_program *prog); 370 370 LIBBPF_API void 371 371 bpf_program__set_expected_attach_type(struct bpf_program *prog, 372 372 enum bpf_attach_type type);