[PATCH] bpftool: Fix wrong format output

liujing posted 1 patch 2 days, 17 hours ago
[PATCH] bpftool: Fix wrong format output
Posted by liujing 2 days, 17 hours ago
From: liujing <liujing_yewu@cmss.chinamobile.com>

%d in format string requires 'int' but the argument type
of pf is 'unsigned int'.

Signed-off-by: liujing <liujing@cmss.chinamobile.com>

diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
index 5cd503b763d7..5bc442d93456 100644
--- a/tools/bpf/bpftool/link.c
+++ b/tools/bpf/bpftool/link.c
@@ -699,7 +699,7 @@ void netfilter_dump_plain(const struct bpf_link_info *info)
 	if (pfname)
 		printf("\n\t%s", pfname);
 	else
-		printf("\n\tpf: %d", pf);
+		printf("\n\tpf: %u", pf);
 
 	if (hookname)
 		printf(" %s", hookname);
-- 
2.27.0
Re: [PATCH] bpftool: Fix wrong format output
Posted by Quentin Monnet 2 days, 14 hours ago
2024-11-21 16:47 UTC+0800 ~ liujing <liujing@cmss.chinamobile.com>
> From: liujing <liujing_yewu@cmss.chinamobile.com>
> 
> %d in format string requires 'int' but the argument type
> of pf is 'unsigned int'.
> 
> Signed-off-by: liujing <liujing@cmss.chinamobile.com>

Reviewed-by: Quentin Monnet <qmo@kernel.org>

Thank you
Re: [PATCH] bpftool: Fix wrong format output
Posted by Quentin Monnet 2 days, 14 hours ago
2024-11-21 16:47 UTC+0800 ~ liujing <liujing@cmss.chinamobile.com>
> From: liujing <liujing_yewu@cmss.chinamobile.com>
> 
> %d in format string requires 'int' but the argument type
> of pf is 'unsigned int'.
> 
> Signed-off-by: liujing <liujing@cmss.chinamobile.com>
> 
> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
> index 5cd503b763d7..5bc442d93456 100644
> --- a/tools/bpf/bpftool/link.c
> +++ b/tools/bpf/bpftool/link.c
> @@ -699,7 +699,7 @@ void netfilter_dump_plain(const struct bpf_link_info *info)
>  	if (pfname)
>  		printf("\n\t%s", pfname);
>  	else
> -		printf("\n\tpf: %d", pf);
> +		printf("\n\tpf: %u", pf);
>  
>  	if (hookname)
>  		printf(" %s", hookname);


Thanks, but while at it can you also fix the format specifier for the
other two prints of "lines" in the function (via "p_err()"), please?

Quentin
Re: [PATCH] bpftool: Fix wrong format output
Posted by Quentin Monnet 2 days, 14 hours ago
2024-11-21 11:42 UTC+0000 ~ Quentin Monnet <qmo@kernel.org>
> 2024-11-21 16:47 UTC+0800 ~ liujing <liujing@cmss.chinamobile.com>
>> From: liujing <liujing_yewu@cmss.chinamobile.com>
>>
>> %d in format string requires 'int' but the argument type
>> of pf is 'unsigned int'.
>>
>> Signed-off-by: liujing <liujing@cmss.chinamobile.com>
>>
>> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
>> index 5cd503b763d7..5bc442d93456 100644
>> --- a/tools/bpf/bpftool/link.c
>> +++ b/tools/bpf/bpftool/link.c
>> @@ -699,7 +699,7 @@ void netfilter_dump_plain(const struct bpf_link_info *info)
>>  	if (pfname)
>>  		printf("\n\t%s", pfname);
>>  	else
>> -		printf("\n\tpf: %d", pf);
>> +		printf("\n\tpf: %u", pf);
>>  
>>  	if (hookname)
>>  		printf(" %s", hookname);
> 
> 
> Thanks, but while at it can you also fix the format specifier for the
> other two prints of "lines" in the function (via "p_err()"), please?

Apologies, I got confused between your two patches when replying. Please
disregard the above for this patch, it looks good as it is.

Quentin