From: Markus Elfring <Markus.Elfring@web.de>
To: Zhu Jun <zhujun2@cmss.chinamobile.com>,
bpf@vger.kernel.org, Quentin Monnet <qmo@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>, Hao Luo <haoluo@google.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>, Stanislav Fomichev <sdf@fomichev.me>,
Yonghong Song <yonghong.song@linux.dev>
Subject: Re: [PATCH v3] tools/bpf: Fix the wrong format specifier
Date: Wed, 24 Jul 2024 16:38:58 +0200 [thread overview]
Message-ID: <9c0b08f9-7c0b-4452-bbd2-a7e23bbcf572@web.de> (raw)
In-Reply-To: <20240724100022.10850-1-zhujun2@cmss.chinamobile.com>
> The format specifier of "unsigned int" in printf() should be "%u", not
> "%d".
Would you like to add any tags (like “Fixes” and “Cc”) accordingly?
…
> ---
> Changes:
…
> v3:fix compile warninf
V3:
Fix a compilation warning?
…
> +++ b/tools/bpf/bpftool/xlated_dumper.c
> @@ -316,7 +316,7 @@ void dump_xlated_plain(struct dump_data *dd, void *buf, unsigned int len,
…
> - unsigned int i;
> + int i;
Please do not change the data type for the variable
if you would like to adjust a subsequent format string.
…
> @@ -415,7 +415,7 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end,
> }
> }
>
> - printf("%d: ", insn_off);
> + printf("%u: ", insn_off);
> print_bpf_insn(&cbs, cur, true);
…
How do you think about to care more also for the return value from such a function call?
https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors
Regards,
Markus
prev parent reply other threads:[~2024-07-24 14:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 10:00 [PATCH v3] tools/bpf:Fix the wrong format specifier Zhu Jun
2024-07-24 10:13 ` Quentin Monnet
2024-07-24 14:38 ` Markus Elfring [this message]
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=9c0b08f9-7c0b-4452-bbd2-a7e23bbcf572@web.de \
--to=markus.elfring@web.de \
--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=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=qmo@kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
--cc=zhujun2@cmss.chinamobile.com \
/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