From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2] devtools: check %l format specifier
Date: Fri, 21 May 2021 13:01:57 +0100 [thread overview]
Message-ID: <4ed3f134-a54d-9993-704b-6de1157f5fae@intel.com> (raw)
In-Reply-To: <20210519192449.2688051-1-thomas@monjalon.net>
On 5/19/2021 8:24 PM, Thomas Monjalon wrote:
> From: Ferruh Yigit <ferruh.yigit@intel.com>
>
> %lx or %llx tend to be wrong for 32-bit platform
> if used for fixed size variable like uint64_t.
> A checkpatch warning will avoid this common mistake.
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> v2: proposal to reword the message and comment
> ---
> devtools/checkpatches.sh | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
> index db4c7d8301..0e09b2cab8 100755
> --- a/devtools/checkpatches.sh
> +++ b/devtools/checkpatches.sh
> @@ -69,6 +69,14 @@ check_forbidden_additions() { # <patch>
> -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
> "$1" || res=1
>
> + # check %l or %ll format specifier
> + awk -v FOLDERS='lib drivers app examples' \
> + -v EXPRESSIONS='%ll*[xud]' \
> + -v RET_ON_FAIL=1 \
> + -v MESSAGE='Using %l format, should it be %PRI*64?' \
> + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
> + "$1" || res=1
> +
> # forbid variable declaration inside "for" loop
> awk -v FOLDERS='.' \
> -v EXPRESSIONS='for[[:space:]]*\\((char|u?int|unsigned|s?size_t)' \
>
Using the %l or %ll format specifier is correct when the variable type is "long
int" or "long long int", it is only wrong if the variable type is fixed size
like 'unit64_t'.
My concern is above warning log may cause people change the correct usage.
That was why I tried to make wording less strict, more like a reminder to double
check the usage.
If we can check that format specifier is used for 'unit64_t' variable, that will
be the best solution but that is very hard to do.
Should we add a little more information to the message to prevent false hit on
the correct usage?
next prev parent reply other threads:[~2021-05-21 12:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 15:26 [dpdk-dev] [PATCH] devtools: add llx format specifier check Ferruh Yigit
2021-02-09 16:38 ` Thomas Monjalon
2021-05-19 19:24 ` [dpdk-dev] [PATCH v2] devtools: check %l format specifier Thomas Monjalon
2021-05-21 12:01 ` Ferruh Yigit [this message]
2021-05-21 13:09 ` Thomas Monjalon
2021-05-21 13:30 ` [dpdk-dev] [PATCH v3] " Thomas Monjalon
2021-05-21 13:33 ` Ferruh Yigit
2021-05-21 13:36 ` Thomas Monjalon
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=4ed3f134-a54d-9993-704b-6de1157f5fae@intel.com \
--to=ferruh.yigit@intel.com \
--cc=dev@dpdk.org \
--cc=thomas@monjalon.net \
/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;
as well as URLs for NNTP newsgroup(s).