devtools: forbid additions of __reserved
Checks
Commit Message
__reserved is a reserved keyword in Windows system headers.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
devtools/checkpatches.sh | 9 +++++++++
1 file changed, 9 insertions(+)
Comments
On Sat, Oct 23, 2021 at 12:29:00PM +0200, David Marchand wrote:
> __reserved is a reserved keyword in Windows system headers.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> From: dev <dev-bounces@dpdk.org> On Behalf Of David Marchand
> Sent: Saturday 23 October 2021 11:29
> To: dev@dpdk.org
> Cc: dmitry.kozliuk@gmail.com; Thomas Monjalon <thomas@monjalon.net>
> Subject: [dpdk-dev] [PATCH] devtools: forbid additions of __reserved
>
> __reserved is a reserved keyword in Windows system headers.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
Tested-by: Conor Walsh <conor.walsh@intel.com>
On Sat, Oct 23, 2021 at 12:29:00PM +0200, David Marchand wrote:
> __reserved is a reserved keyword in Windows system headers.
>
fwiw it's the c standard that stipulates identifiers starting with __
are reserved for any use.
C11/C99 "ANSI-C"
7.1.3 Reserved Identifiers
`All identifiers that begin with an underscore and either an
uppercase letter or another underscore are always reserved for
any use.'
Public DPDK headers are also subject to the C++ standard.
C++ (n3690)
5.10 Identifiers
`(3.1) -- Each identifier that contains a double underscore __ or
begins with an underscore followed by an uppercase letter is reserved
to the implementation for any use.'
`(3.2) -- Each identifier that begins with an underscore is reserved
to the implementation for use as a name in the global namespace.'
dpdk is pretty comprehensive in violating these clauses with
identifiers of the form `__rte_’ fortunately since preprocessors,
compilers, standard library headers are unlikely to use `rte’ it’s
fairly safe in spite of being non-compliant.
23/10/2021 12:29, David Marchand:
> __reserved is a reserved keyword in Windows system headers.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
[...]
> + # refrain from using __reserved which is a reserved keyword in Windows
> + # system headers
Reworded as "forbid"
Applied, thanks.
@@ -134,6 +134,15 @@ check_forbidden_additions() { # <patch>
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
"$1" || res=1
+ # refrain from using __reserved which is a reserved keyword in Windows
+ # system headers
+ awk -v FOLDERS="lib drivers app examples" \
+ -v EXPRESSIONS='\\<__reserved\\>' \
+ -v RET_ON_FAIL=1 \
+ -v MESSAGE='Using __reserved' \
+ -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+ "$1" || res=1
+
# SVG must be included with wildcard extension to allow conversion
awk -v FOLDERS='doc' \
-v EXPRESSIONS='::[[:space:]]*[^[:space:]]*\\.svg' \