devtools: forbid use of compiler pragmas

Message ID 20250130083741.3258965-1-david.marchand@redhat.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series devtools: forbid use of compiler pragmas |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-testing warning apply patch failure

Commit Message

David Marchand Jan. 30, 2025, 8:37 a.m. UTC
Using pragma must be prevented to avoid breaking builds with other
compilers.
Let EAL use them (like for abstraction macros).

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 devtools/checkpatches.sh | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Morten Brørup Jan. 30, 2025, 8:45 a.m. UTC | #1
> From: David Marchand [mailto:david.marchand@redhat.com]
> Sent: Thursday, 30 January 2025 09.38
> 
> Using pragma must be prevented to avoid breaking builds with other
> compilers.
> Let EAL use them (like for abstraction macros).

You are only allowing them in rte_common.h.
Do we need them elsewhere in EAL?
Not that I think so, but the patch description could be interpreted that way.

> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---

Good idea!

Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
David Marchand Jan. 30, 2025, 8:52 a.m. UTC | #2
On Thu, Jan 30, 2025 at 9:45 AM Morten Brørup <mb@smartsharesystems.com> wrote:
>
> > From: David Marchand [mailto:david.marchand@redhat.com]
> > Sent: Thursday, 30 January 2025 09.38
> >
> > Using pragma must be prevented to avoid breaking builds with other
> > compilers.
> > Let EAL use them (like for abstraction macros).
>
> You are only allowing them in rte_common.h.
> Do we need them elsewhere in EAL?
> Not that I think so, but the patch description could be interpreted that way.

Ah yes, I forgot to update description afterwards.
I can update when applying.

>
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
>
> Good idea!
>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
Thomas Monjalon Feb. 4, 2025, 3:59 p.m. UTC | #3
30/01/2025 09:37, David Marchand:
> Using pragma must be prevented to avoid breaking builds with other
> compilers.
> Let EAL use them (like for abstraction macros).
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> +	# forbid use of #pragma
> +	awk -v FOLDERS='lib drivers app examples' \
> +		-v SKIP_FILES='lib/eal/include/rte_common.h' \
> +		-v EXPRESSIONS='(#pragma|_Pragma)' \
> +		-v RET_ON_FAIL=1 \
> +		-v MESSAGE='Using compilers pragma is not allowed' \
> +		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
> +		"$1" || res=1

Acked-by: Thomas Monjalon <thomas@monjalon.net>
  

Patch

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 003bb49e04..c6920747f7 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -210,6 +210,15 @@  check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
 		"$1" || res=1
 
+	# forbid use of #pragma
+	awk -v FOLDERS='lib drivers app examples' \
+		-v SKIP_FILES='lib/eal/include/rte_common.h' \
+		-v EXPRESSIONS='(#pragma|_Pragma)' \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using compilers pragma is not allowed' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
 	# forbid use of experimental build flag except in examples
 	awk -v FOLDERS='lib drivers app' \
 		-v EXPRESSIONS='-DALLOW_EXPERIMENTAL_API allow_experimental_apis' \