Skip to contentSkip to conversation

build: add Wformat to fix gcc compile error

PATCH In review Conor Walsh 5 participants 15 messages Nov 12, 2020 – Nov 22, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: add Wformat to fix gcc compile error

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified. This patch adds Wformat to config/meson.build

---
 config/meson.build | 1 +
 1 file changed, 1 insertion(+)
config/meson.build +1 -0
index 258b01d068..15625c346a 100644
@@ -192,6 +192,7 @@ warning_flags = [
 	# additional warnings in alphabetical order
 	'-Wcast-qual',
 	'-Wdeprecated',
+	'-Wformat',
 	'-Wformat-nonliteral',
 	'-Wformat-security',
 	'-Wmissing-declarations',
Signature · 1 line
2.25.1
#1 lore raw

12/11/2020 12:35, Conor Walsh:

Quoted 5 lines

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified. This patch adds Wformat to config/meson.build

Please could you provide (in a v2) more informations about the error and why the fix is needed?

#2 lore raw

Thanks for your reply Thomas, that's no problem.
I will expand the explanation for this patch when I push a v2, v2 will hopefully also address the issues it caused with the icc build.

/Conor

Quoted 20 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday 12 November 2020 18:47
To: Walsh, Conor <[email protected]>
Cc: Richardson, Bruce <[email protected]>; [email protected]; Chen, LingliX <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1] build: add Wformat to fix gcc compile error

12/11/2020 12:35, Conor Walsh:

Quoted 5 lines

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified. This patch adds Wformat to config/meson.build

Please could you provide (in a v2) more informations about the error and why the fix is needed?

Tested-by on v1 1/1
#3 lore raw
In reply to Conor Walsh

Regards,
Chen, LingliX

Quoted 31 lines

-----Original Message-----
From: Walsh, Conor
Sent: Thursday, November 12, 2020 7:36 PM
To: Richardson, Bruce <[email protected]>
Cc: [email protected]; Chen, LingliX <[email protected]>; Walsh, Conor <[email protected]>
Subject: [PATCH v1] build: add Wformat to fix gcc compile error

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified. This patch adds Wformat to config/meson.build

---
 config/meson.build | 1 +
 1 file changed, 1 insertion(+)
config/meson.build index renamed from config/meson.build +0 -0

258b01d068..15625c346a 100644

config/meson.build +1 -1
@@ -192,6 +192,7 @@ warning_flags = [
 	# additional warnings in alphabetical order
 	'-Wcast-qual',
 	'-Wdeprecated',
+	'-Wformat',
 	'-Wformat-nonliteral',
 	'-Wformat-security',
 	'-Wmissing-declarations',
--

2.25.1

#4 lore raw

v2 cover build: add Wformat to fix gcc compile warnings and format fixes

In reply to Conor Walsh

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified this causes a compile warning on these systems. This patchset adds Wformat to config/meson.build and fixes some format issues that this exposed.

---

v2:
- expand explaination of patches
- suppress false postives in icc
- add fixes for format issues

Conor Walsh (2):
build: fix gcc compile warnings by adding wformat net/bnxt: fix format characters for unsigned values

 config/meson.build                 | 3 ++-
 drivers/net/bnxt/tf_core/tf_core.c | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 1/2 build: fix gcc compile warnings by adding wformat

On some CentOS/RHEL systems using gcc 8.3.1 to compile dpdk, gcc shows a warning on every build step saying that -Wformat-nonliteral and -Wformat-security warnings will be ignored unless -Wformat is also specified as a compiler flag. When the build is run with -werror the build will fail due to these warnings.

Exact warning returned:
cc1: error: -Wformat-nonliteral ignored without -Wformat [-Werror=format-nonliteral]
cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]
cc1: all warnings being treated as errors

This patch adds the -Wformat flag to config/meson.build. The warning id 181 has also been suppressed in icc as icc was showing false positives with -Wformat enabled.

Fixes 524a0d5d66b9 ("build: enable extra warnings with meson")
---
 config/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
config/meson.build +2 -1
index a29693b883..c02802c18e 100644
@@ -194,6 +194,7 @@ warning_flags = [
 	# additional warnings in alphabetical order
 	'-Wcast-qual',
 	'-Wdeprecated',
+	'-Wformat',
 	'-Wformat-nonliteral',
 	'-Wformat-security',
 	'-Wmissing-declarations',
@@ -220,7 +221,7 @@ if not dpdk_conf.get('RTE_ARCH_64')
 	warning_flags += '-Wno-pointer-to-int-cast'
 endif
 if cc.get_id() == 'intel'
-	warning_ids = [188, 2203, 2279, 2557, 3179, 3656]
+	warning_ids = [181, 188, 2203, 2279, 2557, 3179, 3656]
 	foreach i:warning_ids
 		warning_flags += '-diag-disable=@0@'.format(i)
 	endforeach
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 2/2 net/bnxt: fix format characters for unsigned values

In reply to Conor Walsh

&device requires the %u format specifer not the %d specifier, as &device is unsigned.

Fixes a46bbb57605b ("net/bnxt: update multi device design")
---
 drivers/net/bnxt/tf_core/tf_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/tf_core/tf_core.c +4 -4
index 0f49a00256..24d49096a7 100644
@@ -44,7 +44,7 @@ tf_open_session(struct tf *tfp,
 
 	/* Verify control channel and build the beginning of session_id */
 	rc = sscanf(parms->ctrl_chan_name,
-		    "%x:%x:%x.%d",
+		    "%x:%x:%x.%u",
 		    &domain,
 		    &bus,
 		    &slot,
@@ -57,7 +57,7 @@ tf_open_session(struct tf *tfp,
 
 		/* Check parsing of bus/slot/device */
 		rc = sscanf(parms->ctrl_chan_name,
-			    "%x:%x.%d",
+			    "%x:%x.%u",
 			    &bus,
 			    &slot,
 			    &device);
@@ -102,7 +102,7 @@ tf_attach_session(struct tf *tfp,
 
 	/* Verify control channel */
 	rc = sscanf(parms->ctrl_chan_name,
-		    "%x:%x:%x.%d",
+		    "%x:%x:%x.%u",
 		    &domain,
 		    &bus,
 		    &slot,
@@ -115,7 +115,7 @@ tf_attach_session(struct tf *tfp,
 
 	/* Verify 'attach' channel */
 	rc = sscanf(parms->attach_chan_name,
-		    "%x:%x:%x.%d",
+		    "%x:%x:%x.%u",
 		    &domain,
 		    &bus,
 		    &slot,
Signature · 1 line
2.25.1
#7 lore raw

Re: [dpdk-dev] [PATCH v2 0/2] build: add Wformat to fix gcc compile warnings and format fixes

In reply to Conor Walsh
Quoted 12 lines · Conor Walsh

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified this causes a compile warning on these systems. This patchset adds Wformat to config/meson.build and fixes some format issues that this exposed.

---

v2:
- expand explaination of patches
- suppress false postives in icc
- add fixes for format issues

Quoted 7 lines

Conor Walsh (2):
build: fix gcc compile warnings by adding wformat net/bnxt: fix format characters for unsigned values

 config/meson.build                 | 3 ++-
 drivers/net/bnxt/tf_core/tf_core.c | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

Looks good to me, but it should be cc'ed to stable as well I think

Signature · 2 lines
Kind regards,
Luca Boccassi
#8 lore raw

Re: [dpdk-dev] [PATCH v2 0/2] build: add Wformat to fix gcc compile warnings and format fixes

Thank you for your feedback Luca,
I pushed a v3 that now has stable cc'ed.
/Conor

Quoted 37 lines

From: Luca Boccassi <[email protected]>
Sent: Wednesday 18 November 2020 18:38
To: Walsh, Conor <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Chen, LingliX <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 0/2] build: add Wformat to fix gcc compile warnings and format fixes

Quoted 12 lines · Conor Walsh

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified this causes a compile warning on these systems. This patchset adds Wformat to config/meson.build and fixes some format issues that this exposed.

---

v2:
- expand explaination of patches
- suppress false postives in icc
- add fixes for format issues

Quoted 7 lines

Conor Walsh (2):
build: fix gcc compile warnings by adding wformat net/bnxt: fix format characters for unsigned values

 config/meson.build                 | 3 ++-
 drivers/net/bnxt/tf_core/tf_core.c | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

Looks good to me, but it should be cc'ed to stable as well I think

--
Kind regards,
Luca Boccassi

#9 lore raw

v3 cover build: add Wformat to fix gcc compile warnings and format fixes

In reply to Conor Walsh

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified this causes a compile warning on these systems. This patchset adds Wformat to config/meson.build and fixes some format issues that this exposed.

---

v3: add [email protected] to cc list following list feedback

v2:
- expand explaination of patches
- suppress false postives in icc
- add fixes for format issues

Conor Walsh (2):
build: fix gcc compile warnings by adding wformat net/bnxt: fix format characters for unsigned values

 config/meson.build                 | 3 ++-
 drivers/net/bnxt/tf_core/tf_core.c | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#10 lore raw

PATCH v3 1/2 build: fix gcc compile warnings by adding wformat

On some CentOS/RHEL systems using gcc 8.3.1 to compile dpdk, gcc shows a warning on every build step saying that -Wformat-nonliteral and -Wformat-security warnings will be ignored unless -Wformat is also specified as a compiler flag. When the build is run with -werror the build will fail due to these warnings.

Exact warning returned:
cc1: error: -Wformat-nonliteral ignored without -Wformat [-Werror=format-nonliteral]
cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]
cc1: all warnings being treated as errors

This patch adds the -Wformat flag to config/meson.build. The warning id 181 has also been suppressed in icc as icc was showing false positives with -Wformat enabled.

Fixes 524a0d5d66b9 ("build: enable extra warnings with meson")
---
 config/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
config/meson.build +2 -1
index a29693b883..c02802c18e 100644
@@ -194,6 +194,7 @@ warning_flags = [
 	# additional warnings in alphabetical order
 	'-Wcast-qual',
 	'-Wdeprecated',
+	'-Wformat',
 	'-Wformat-nonliteral',
 	'-Wformat-security',
 	'-Wmissing-declarations',
@@ -220,7 +221,7 @@ if not dpdk_conf.get('RTE_ARCH_64')
 	warning_flags += '-Wno-pointer-to-int-cast'
 endif
 if cc.get_id() == 'intel'
-	warning_ids = [188, 2203, 2279, 2557, 3179, 3656]
+	warning_ids = [181, 188, 2203, 2279, 2557, 3179, 3656]
 	foreach i:warning_ids
 		warning_flags += '-diag-disable=@0@'.format(i)
 	endforeach
Signature · 1 line
2.25.1
Tested-by on v3 1/2
#11 lore raw

Re: [dpdk-dev] [PATCH v3 1/2] build: fix gcc compile warnings by adding wformat

Regards,
Chen, LingliX

Quoted 10 lines

-----Original Message-----
From: Walsh, Conor
Sent: Thursday, November 19, 2020 6:17 PM
To: Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Chen, LingliX <[email protected]>; [email protected]; Walsh, Conor <[email protected]>; Chen
Subject: [PATCH v3 1/2] build: fix gcc compile warnings by adding wformat

#12 lore raw

PATCH v3 2/2 net/bnxt: fix format characters for unsigned values

In reply to Conor Walsh

&device requires the %u format specifer not the %d specifier, as &device is unsigned.

Fixes a46bbb57605b ("net/bnxt: update multi device design")
---
 drivers/net/bnxt/tf_core/tf_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/tf_core/tf_core.c +4 -4
index 0f49a00256..24d49096a7 100644
@@ -44,7 +44,7 @@ tf_open_session(struct tf *tfp,
 
 	/* Verify control channel and build the beginning of session_id */
 	rc = sscanf(parms->ctrl_chan_name,
-		    "%x:%x:%x.%d",
+		    "%x:%x:%x.%u",
 		    &domain,
 		    &bus,
 		    &slot,
@@ -57,7 +57,7 @@ tf_open_session(struct tf *tfp,
 
 		/* Check parsing of bus/slot/device */
 		rc = sscanf(parms->ctrl_chan_name,
-			    "%x:%x.%d",
+			    "%x:%x.%u",
 			    &bus,
 			    &slot,
 			    &device);
@@ -102,7 +102,7 @@ tf_attach_session(struct tf *tfp,
 
 	/* Verify control channel */
 	rc = sscanf(parms->ctrl_chan_name,
-		    "%x:%x:%x.%d",
+		    "%x:%x:%x.%u",
 		    &domain,
 		    &bus,
 		    &slot,
@@ -115,7 +115,7 @@ tf_attach_session(struct tf *tfp,
 
 	/* Verify 'attach' channel */
 	rc = sscanf(parms->attach_chan_name,
-		    "%x:%x:%x.%d",
+		    "%x:%x:%x.%u",
 		    &domain,
 		    &bus,
 		    &slot,
Signature · 1 line
2.25.1
Acked-by on v3 2/2
#13 lore raw

Re: [dpdk-dev] [PATCH v3 2/2] net/bnxt: fix format characters for unsigned values

Quoted 8 lines · Conor Walsh

&device requires the %u format specifer not the %d specifier, as &device is unsigned.

Fixes a46bbb57605b ("net/bnxt: update multi device design")
Quoted 47 lines
---
 drivers/net/bnxt/tf_core/tf_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/tf_core/tf_core.c +4 -5
index 0f49a00256..24d49096a7 100644
@@ -44,7 +44,7 @@ tf_open_session(struct tf *tfp,
 
        /* Verify control channel and build the beginning of session_id */
        rc = sscanf(parms->ctrl_chan_name,
-                   "%x:%x:%x.%d",
+                   "%x:%x:%x.%u",
                    &domain,
                    &bus,
                    &slot,
@@ -57,7 +57,7 @@ tf_open_session(struct tf *tfp,
 
                /* Check parsing of bus/slot/device */
                rc = sscanf(parms->ctrl_chan_name,
-                           "%x:%x.%d",
+                           "%x:%x.%u",
                            &bus,
                            &slot,
                            &device);
@@ -102,7 +102,7 @@ tf_attach_session(struct tf *tfp,
 
        /* Verify control channel */
        rc = sscanf(parms->ctrl_chan_name,
-                   "%x:%x:%x.%d",
+                   "%x:%x:%x.%u",
                    &domain,
                    &bus,
                    &slot,
@@ -115,7 +115,7 @@ tf_attach_session(struct tf *tfp,
 
        /* Verify 'attach' channel */
        rc = sscanf(parms->attach_chan_name,
-                   "%x:%x:%x.%d",
+                   "%x:%x:%x.%u",
                    &domain,
                    &bus,
                    &slot,
--

2.25.1

#14 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v3 0/2] build: add Wformat to fix gcc compile warnings and format fixes

In reply to Conor Walsh

19/11/2020 11:16, Conor Walsh:

Quoted 8 lines

On some systems Wformat-nonliteral and Wformat-security could not be checked without Wformat also being specified this causes a compile warning on these systems. This patchset adds Wformat to config/meson.build and fixes some format issues that this exposed.

---

v3: add [email protected] to cc list following list feedback

The Cc: [email protected] must be part of the commit log. Please at other patches (and contributors guidelines) for inspiration.

Series applied, thanks.