lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1d21ee8a-837d-807d-14a4-4ee1af640089@vivo.com>
Date:   Thu, 17 Mar 2022 14:51:51 +0800
From:   Guo Zhengkui <guozhengkui@...o.com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Shuah Khan <shuah@...nel.org>,
        "open list:NETWORKING [GENERAL]" <netdev@...r.kernel.org>,
        "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        "zhengkui_guo@...look.com" <zhengkui_guo@...look.com>
Subject: Re: [PATCH] selftests: net: fix warning when compiling selftest/net

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ