diff mbox series

[1/5] uqmi: support C reserved keywords in upstream JSON files

Message ID 20240410102509.3936469-1-jean.thomas@wifirst.fr
State Accepted
Delegated to: Alexander Couzens
Headers show
Series [1/5] uqmi: support C reserved keywords in upstream JSON files | expand

Commit Message

Jean Thomas April 10, 2024, 10:25 a.m. UTC
Add a dummy prefix in case a name in the upstream JSON files is a
C reserved keyword.

This is the case with the "Register" element of the new "Configure
Profile Event List" message.

Signed-off-by: Jean Thomas <jean.thomas@wifirst.fr>
---
 data/gen-common.pm | 52 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

Comments

Alexander 'lynxis' Couzens April 15, 2024, 10:26 p.m. UTC | #1
Hi Jean,

On Wed, 10 Apr 2024 12:25:05 +0200
Jean Thomas <jean.thomas@wifirst.fr> wrote:

> Add a dummy prefix in case a name in the upstream JSON files is a
> C reserved keyword.
> 
> This is the case with the "Register" element of the new "Configure
> Profile Event List" message.
> 
> Signed-off-by: Jean Thomas <jean.thomas@wifirst.fr>

thanks.
I merged your serie after rebasing them to the new paths.

Regards,
lynxis
diff mbox series

Patch

diff --git a/data/gen-common.pm b/data/gen-common.pm
index 278afce..31d43a0 100644
--- a/data/gen-common.pm
+++ b/data/gen-common.pm
@@ -19,6 +19,54 @@  our %tlv_types = (
 );
 our %common_ref = ();
 
+my @c_reserved_keywords = (
+	"alignas",
+	"alignof",
+	"auto",
+	"bool",
+	"break",
+	"case",
+	"char",
+	"const",
+	"constexpr",
+	"continue",
+	"default",
+	"do",
+	"double",
+	"else",
+	"enum",
+	"extern",
+	"false",
+	"float",
+	"for",
+	"goto",
+	"if",
+	"inline",
+	"int",
+	"long",
+	"nullptr",
+	"register",
+	"restrict",
+	"return",
+	"short",
+	"signed",
+	"sizeof",
+	"static",
+	"static_assert",
+	"struct",
+	"switch",
+	"thread_local",
+	"true",
+	"typedef",
+	"typeof",
+	"typeof_unqual",
+	"union",
+	"unsigned",
+	"void",
+	"volatile",
+	"while"
+);
+
 $prefix eq 'ctl_' and $ctl = 1;
 
 sub get_json() {
@@ -33,7 +81,9 @@  sub gen_cname($) {
 
 	$name =~ s/[^a-zA-Z0-9_]/_/g;
 	$name = "_${name}" if $name =~ /^\d/;
-	return lc($name);
+	$name = lc($name);
+	$name = "_${name}" if (grep {$_ eq $name} @c_reserved_keywords);
+	return $name;
 }
 
 sub gen_has_types($) {