BPF List
 help / color / mirror / Atom feed
From: Quentin Monnet <qmo@kernel.org>
To: Luo Yifan <luoyifan@cmss.chinamobile.com>,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
	yonghong.song@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
	jolsa@kernel.org
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bpftool: Fix incorrect format specifier for var
Date: Mon, 11 Nov 2024 13:08:25 +0000	[thread overview]
Message-ID: <7e382bfd-cb1b-4d67-9e2d-a007af86e90d@kernel.org> (raw)
In-Reply-To: <20241111024814.272940-1-luoyifan@cmss.chinamobile.com>

2024-11-11 10:48 UTC+0800 ~ Luo Yifan <luoyifan@cmss.chinamobile.com>
> In cases where the SIGNED condition is met, the variable var is still
> used as an unsigned long long. Therefore, the %llu format specifier
> should be used to avoid incorrect data print. This patch fixes it.
> 
> Signed-off-by: Luo Yifan <luoyifan@cmss.chinamobile.com>
> ---
>  tools/bpf/bpftool/btf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> index 7d2af1ff3..ff58ff85e 100644
> --- a/tools/bpf/bpftool/btf.c
> +++ b/tools/bpf/bpftool/btf.c
> @@ -283,7 +283,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
>  				jsonw_end_object(w);
>  			} else {
>  				if (btf_kflag(t))
> -					printf("\n\t'%s' val=%lldLL", name,
> +					printf("\n\t'%s' val=%lluLL", name,
>  					       (unsigned long long)val);
>  				else
>  					printf("\n\t'%s' val=%lluULL", name,


Hi, I don't think your change is correct, it seems to me that we do want
to make the distinction between the signed and unsigned version here (as
for all the other enum cases in the function). What are you trying to
address, did you find a bug in the output or a warning during compilation?

Quentin

  reply	other threads:[~2024-11-11 13:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11  2:48 [PATCH] bpftool: Fix incorrect format specifier for var Luo Yifan
2024-11-11 13:08 ` Quentin Monnet [this message]
2024-11-12  1:44   ` Luo Yifan
2024-11-12  4:08 ` Andrii Nakryiko
2024-11-12  7:37   ` [PATCH] bpftool: Cast variable `var` to long long Luo Yifan
2024-11-12  9:33     ` Quentin Monnet
2024-11-13 20:20     ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e382bfd-cb1b-4d67-9e2d-a007af86e90d@kernel.org \
    --to=qmo@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luoyifan@cmss.chinamobile.com \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox