[RFC PATCH v2 01/74] dtc-parser.y: Avoid an empty proplist
From: Herve Codina
Date: Wed Aug 26 2026 - 05:57:20 EST
In the dts parser grammar, a nodedef is defined by
'{' proplist subnodes '}' ';'
with both proplist and subnodes that can be empty lists.
Having multiple possible empty list can lead to Bison warnings such as
warning: 4 shift/reduce conflicts [-Wconflicts-sr]
warning: 1 reduce/reduce conflict [-Wconflicts-rr]
This will happen as soon as a new list (which also could be empty) is
added in the nodedef definition.
The simpler way to remove those warning and thus have a robust parsing
is to avoid multiple empty lists.
Update the proplist definition and nodedef definition to avoid those
multiple empty lists. Instead of allowing a proplist to be an empty
list, force the list to be a non empty one and update the nodedef to
handle explicitly the absence of the proplist to support the case where
no properties are available, i.e. the case of a node composed only of
sub-nodes.
This doesn't change the functional behavior.
Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
---
dtc-parser.y | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dtc-parser.y b/dtc-parser.y
index 4d5eece5..e47f80d4 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -267,12 +267,16 @@ nodedef:
{
$$ = build_node($2, $3, &@$);
}
+ | '{' subnodes '}' ';'
+ {
+ $$ = build_node(NULL, $2, &@$);
+ }
;
proplist:
- /* empty */
+ propdef
{
- $$ = NULL;
+ $$ = chain_property($1, NULL);
}
| proplist propdef
{
--
2.55.0