diff mbox series

[bpf-next,03/11] btf: make btf_set_contains take a const pointer

Message ID 20200904112401.667645-4-lmb@cloudflare.com
State RFC
Delegated to: BPF Maintainers
Headers show
Series RFC: Make check_func_arg table driven | expand

Commit Message

Lorenz Bauer Sept. 4, 2020, 11:23 a.m. UTC
bsearch doesn't modify the contents of the array, so we can take a const pointer.

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
 include/linux/bpf.h | 2 +-
 kernel/bpf/btf.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Andrii Nakryiko Sept. 9, 2020, 4:13 a.m. UTC | #1
On Fri, Sep 4, 2020 at 4:30 AM Lorenz Bauer <lmb@cloudflare.com> wrote:
>
> bsearch doesn't modify the contents of the array, so we can take a const pointer.
>
> Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
> ---

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  include/linux/bpf.h | 2 +-
>  kernel/bpf/btf.c    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index c6d9f2c444f4..6b72cdf52ebc 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -1900,6 +1900,6 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,
>                        void *addr1, void *addr2);
>
>  struct btf_id_set;
> -bool btf_id_set_contains(struct btf_id_set *set, u32 id);
> +bool btf_id_set_contains(const struct btf_id_set *set, u32 id);
>
>  #endif /* _LINUX_BPF_H */
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index f9ac6935ab3c..a2330f6fe2e6 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -4772,7 +4772,7 @@ static int btf_id_cmp_func(const void *a, const void *b)
>         return *pa - *pb;
>  }
>
> -bool btf_id_set_contains(struct btf_id_set *set, u32 id)
> +bool btf_id_set_contains(const struct btf_id_set *set, u32 id)
>  {
>         return bsearch(&id, set->ids, set->cnt, sizeof(u32), btf_id_cmp_func) != NULL;
>  }
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index c6d9f2c444f4..6b72cdf52ebc 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1900,6 +1900,6 @@  int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,
 		       void *addr1, void *addr2);
 
 struct btf_id_set;
-bool btf_id_set_contains(struct btf_id_set *set, u32 id);
+bool btf_id_set_contains(const struct btf_id_set *set, u32 id);
 
 #endif /* _LINUX_BPF_H */
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index f9ac6935ab3c..a2330f6fe2e6 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -4772,7 +4772,7 @@  static int btf_id_cmp_func(const void *a, const void *b)
 	return *pa - *pb;
 }
 
-bool btf_id_set_contains(struct btf_id_set *set, u32 id)
+bool btf_id_set_contains(const struct btf_id_set *set, u32 id)
 {
 	return bsearch(&id, set->ids, set->cnt, sizeof(u32), btf_id_cmp_func) != NULL;
 }