* [dpdk-dev] [PATCH] devtools: add llx format specifier check
@ 2021-02-09 15:26 Ferruh Yigit
2021-02-09 16:38 ` Thomas Monjalon
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Ferruh Yigit @ 2021-02-09 15:26 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: Ferruh Yigit, dev, David Marchand, Aaron Conole
%llx tends to be wrong when used for fixed size, like uint64_t,
variables, adding a warning to double check them.
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: David Marchand <david.marchand@redhat.com>
Cc: Aaron Conole <aconole@redhat.com>
---
devtools/checkpatches.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 78a408ef9823..68005389820a 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -118,6 +118,14 @@ check_forbidden_additions() { # <patch>
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
"$1" || res=1
+ # check %llx usage
+ awk -v FOLDERS='lib drivers app examples' \
+ -v EXPRESSIONS='%ll*[xud]' \
+ -v RET_ON_FAIL=1 \
+ -v MESSAGE='Please check %llx usage which tends to be wrong most of the times' \
+ -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+ "$1" || res=1
+
# svg figures must be included with wildcard extension
# because of png conversion for pdf docs
awk -v FOLDERS='doc' \
--
2.29.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH] devtools: add llx format specifier check
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 13:30 ` [dpdk-dev] [PATCH v3] " Thomas Monjalon
2 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2021-02-09 16:38 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, David Marchand, Aaron Conole
09/02/2021 16:26, Ferruh Yigit:
> %llx tends to be wrong when used for fixed size, like uint64_t,
> variables, adding a warning to double check them.
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> + # check %llx usage
> + awk -v FOLDERS='lib drivers app examples' \
> + -v EXPRESSIONS='%ll*[xud]' \
> + -v RET_ON_FAIL=1 \
> + -v MESSAGE='Please check %llx usage which tends to be wrong most of the times' \
+1
It reminds me this old email:
http://mails.dpdk.org/archives/dev/2018-February/091483.html
The title mentions llx, but it should be %ll in general:
devtools: check %ll format specifier
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v2] devtools: check %l format specifier
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 ` Thomas Monjalon
2021-05-21 12:01 ` Ferruh Yigit
2021-05-21 13:30 ` [dpdk-dev] [PATCH v3] " Thomas Monjalon
2 siblings, 1 reply; 8+ messages in thread
From: Thomas Monjalon @ 2021-05-19 19:24 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit
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)' \
--
2.31.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v2] devtools: check %l format specifier
2021-05-19 19:24 ` [dpdk-dev] [PATCH v2] devtools: check %l format specifier Thomas Monjalon
@ 2021-05-21 12:01 ` Ferruh Yigit
2021-05-21 13:09 ` Thomas Monjalon
0 siblings, 1 reply; 8+ messages in thread
From: Ferruh Yigit @ 2021-05-21 12:01 UTC (permalink / raw)
To: Thomas Monjalon, dev
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?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v2] devtools: check %l format specifier
2021-05-21 12:01 ` Ferruh Yigit
@ 2021-05-21 13:09 ` Thomas Monjalon
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2021-05-21 13:09 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, david.marchand
21/05/2021 14:01, Ferruh Yigit:
> 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
> > ---
> > + # 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
>
> 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.
This is a question now: "should it be", why do you think it is strict?
> 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?
Your message was:
"Please check %llx usage which tends to be wrong most of the times"
Mine:
"Using %l format, should it be %PRI*64?"
Trying to give more info about what can be wrong while keeping short:
"Using %l format, is it a long variable or should it be %PRI*64?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v3] devtools: check %l format specifier
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 13:30 ` Thomas Monjalon
2021-05-21 13:33 ` Ferruh Yigit
2 siblings, 1 reply; 8+ messages in thread
From: Thomas Monjalon @ 2021-05-21 13:30 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit
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>
---
v3: more explicit message
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 ba43f84e64..c30dadd962 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, prefer %PRI*64 if type is [u]int64_t' \
+ -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)' \
--
2.31.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v3] devtools: check %l format specifier
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
0 siblings, 1 reply; 8+ messages in thread
From: Ferruh Yigit @ 2021-05-21 13:33 UTC (permalink / raw)
To: Thomas Monjalon, dev
On 5/21/2021 2:30 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>
Ack.
Thanks for update.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v3] devtools: check %l format specifier
2021-05-21 13:33 ` Ferruh Yigit
@ 2021-05-21 13:36 ` Thomas Monjalon
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2021-05-21 13:36 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev
21/05/2021 15:33, Ferruh Yigit:
> On 5/21/2021 2:30 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>
>
> Ack.
>
> Thanks for update.
Applied, thanks
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-05-21 13:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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).