From: Guo Zhengkui <guozhengkui@vivo.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Shuah Khan <shuah@kernel.org>,
"open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
"zhengkui_guo@outlook.com" <zhengkui_guo@outlook.com>
Subject: Re: [PATCH] selftests: net: fix warning when compiling selftest/net
Date: Thu, 17 Mar 2022 14:51:51 +0800 [thread overview]
Message-ID: <1d21ee8a-837d-807d-14a4-4ee1af640089@vivo.com> (raw)
In-Reply-To: <20220316202251.382b687e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On 2022/3/17 11:22, Jakub Kicinski wrote:
> On Wed, 16 Mar 2022 19:50:40 +0800 Guo Zhengkui wrote:
>> When I compile tools/testing/selftests/net/ by
>> `make -C tools/testing/selftests/net` with gcc (Debian 8.3.0-6) 8.3.0,
>> it reports the following warnings:
>>
>> txtimestamp.c: In function 'validate_timestamp':
>> txtimestamp.c:164:29: warning: format '%lu' expects argument of type
>> 'long unsigned int', but argument 3 has type 'int64_t'
>> {aka 'long long int'} [-Wformat=]
>> fprintf(stderr, "ERROR: %lu us expected between %d and %d\n",
>> ~~^
>> %llu
>> cur64 - start64, min_delay, max_delay);
>> ~~~~~~~~~~~~~~~
>> txtimestamp.c: In function '__print_ts_delta_formatted':
>> txtimestamp.c:173:22: warning: format '%lu' expects argument of type
>> 'long unsigned int', but argument 3 has type 'int64_t'
>> {aka 'long long int'} [-Wformat=]
>> fprintf(stderr, "%lu ns", ts_delta);
>> ~~^ ~~~~~~~~
>> %llu
>> txtimestamp.c:175:22: warning: format '%lu' expects argument of type
>> 'long unsigned int', but argument 3 has type 'int64_t'
>> {aka 'long long int'} [-Wformat=]
>> fprintf(stderr, "%lu us", ts_delta / NSEC_PER_USEC);
>> ~~^
>> %llu
>>
>> `int64_t` is the alias for `long long int`. '%lld' is more suitable.
>
> That's on 32bit machines, I think what you need to use is PRId64.
> Or just cast the result / change variable types to long long.
But it should be '%ld' instead of '%lu', right?
Zhengkui
next prev parent reply other threads:[~2022-03-17 6:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-16 11:50 Guo Zhengkui
2022-03-17 3:22 ` Jakub Kicinski
2022-03-17 6:51 ` Guo Zhengkui [this message]
2022-03-18 7:50 ` [PATCH linux-next v2] selftests: net: change fprintf format specifiers Guo Zhengkui
2022-03-18 16:33 ` Jakub Kicinski
2022-03-19 7:09 ` Guo Zhengkui
2022-03-19 7:37 ` [PATCH linux-next v3] " Guo Zhengkui
2022-03-22 0:00 ` 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=1d21ee8a-837d-807d-14a4-4ee1af640089@vivo.com \
--to=guozhengkui@vivo.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=zhengkui_guo@outlook.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
all inboxes | Powered by JetHome®