2020-02-03 02:10:15

by Hongbo Yao

[permalink] [raw]
Subject: [PATCH -next] bpf: make btf_check_func_type_match() static

Fix sparse warning:
kernel/bpf/btf.c:4131:5: warning: symbol 'btf_check_func_type_match' was
not declared. Should it be static?

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Hongbo Yao <[email protected]>
---
kernel/bpf/btf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 8c9d8f266bef..83d3d92023af 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -4144,7 +4144,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log,
* EFAULT - verifier bug
* 0 - 99% match. The last 1% is validated by the verifier.
*/
-int btf_check_func_type_match(struct bpf_verifier_log *log,
+static int btf_check_func_type_match(struct bpf_verifier_log *log,
struct btf *btf1, const struct btf_type *t1,
struct btf *btf2, const struct btf_type *t2)
{
--
2.20.1


2020-02-03 08:13:38

by Yonghong Song

[permalink] [raw]
Subject: Re: [PATCH -next] bpf: make btf_check_func_type_match() static



On 2/2/20 6:02 PM, Hongbo Yao wrote:
> Fix sparse warning:
> kernel/bpf/btf.c:4131:5: warning: symbol 'btf_check_func_type_match' was
> not declared. Should it be static?

Yes, static is better since the function is only used in one file.

Please use the tag "[PATCH bpf-next]" instead of "[PATCH -next]".
Since this is to fix a sparse warning, I think it should be okay
to target bpf-next. Please resubmit after bpf-next reopens in
about a week.

>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Hongbo Yao <[email protected]>
> ---
> kernel/bpf/btf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 8c9d8f266bef..83d3d92023af 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -4144,7 +4144,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log,
> * EFAULT - verifier bug
> * 0 - 99% match. The last 1% is validated by the verifier.
> */
> -int btf_check_func_type_match(struct bpf_verifier_log *log,
> +static int btf_check_func_type_match(struct bpf_verifier_log *log,
> struct btf *btf1, const struct btf_type *t1,
> struct btf *btf2, const struct btf_type *t2)

Please also align
struct btf *btf1, const struct btf_type *t1,
struct btf *btf2, const struct btf_type *t2)
properly after you added 'static' before the function declaration.

> {
>

2020-02-03 10:00:13

by Hongbo Yao

[permalink] [raw]
Subject: Re: [PATCH -next] bpf: make btf_check_func_type_match() static



On 2/3/2020 2:20 PM, Yonghong Song wrote:
>
>
> On 2/2/20 6:02 PM, Hongbo Yao wrote:
>> Fix sparse warning:
>> kernel/bpf/btf.c:4131:5: warning: symbol 'btf_check_func_type_match' was
>> not declared. Should it be static?
>
> Yes, static is better since the function is only used in one file.
>
> Please use the tag "[PATCH bpf-next]" instead of "[PATCH -next]".
> Since this is to fix a sparse warning, I think it should be okay
> to target bpf-next. Please resubmit after bpf-next reopens in
> about a week.

OK.

>>
>> Reported-by: Hulk Robot <[email protected]>
>> Signed-off-by: Hongbo Yao <[email protected]>
>> ---
>>   kernel/bpf/btf.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
>> index 8c9d8f266bef..83d3d92023af 100644
>> --- a/kernel/bpf/btf.c
>> +++ b/kernel/bpf/btf.c
>> @@ -4144,7 +4144,7 @@ int btf_distill_func_proto(struct bpf_verifier_log *log,
>>    * EFAULT - verifier bug
>>    * 0 - 99% match. The last 1% is validated by the verifier.
>>    */
>> -int btf_check_func_type_match(struct bpf_verifier_log *log,
>> +static int btf_check_func_type_match(struct bpf_verifier_log *log,
>>                     struct btf *btf1, const struct btf_type *t1,
>>                     struct btf *btf2, const struct btf_type *t2)
>
> Please also align
>   struct btf *btf1, const struct btf_type *t1,
>   struct btf *btf2, const struct btf_type *t2)
> properly after you added 'static' before the function declaration.

I'll fix it, thanks.

>>   {
>>
>
> .
>