diff mbox series

parser: check consistency for partition after running embscript

Message ID 20241106181036.407648-1-stefano.babic@swupdate.org
State New
Headers show
Series parser: check consistency for partition after running embscript | expand

Commit Message

Stefano Babic Nov. 6, 2024, 6:10 p.m. UTC
It should be possible to leave empty some fields if they are filled by
a Lua function in the embedded script. Check for consistency of a
partition entry should be done after running a hook if present.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 parser/parser.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/parser/parser.c b/parser/parser.c
index f5113f94..3ef7fe4a 100644
--- a/parser/parser.c
+++ b/parser/parser.c
@@ -515,13 +515,6 @@  static int _parse_partitions(parsertype p, void *cfg, void *setting, const char

 		partition->provided = 1;

-		if ((!strlen(partition->volname) && !strcmp(partition->type, "ubipartition")) ||
-				!strlen(partition->device)) {
-			ERROR("Partition incompleted in description file");
-			free_image(partition);
-			return -1;
-		}
-
 		GET_FIELD_INT64(p, elem, "size", &partition->partsize);

 		add_properties(p, elem, partition);
@@ -535,6 +528,14 @@  static int _parse_partitions(parsertype p, void *cfg, void *setting, const char
 			free_image(partition);
 			continue;
 		}
+
+		if ((!strlen(partition->volname) && !strcmp(partition->type, "ubipartition")) ||
+				!strlen(partition->device)) {
+			ERROR("Partition incompleted in description file");
+			free_image(partition);
+			return -1;
+		}
+
 		TRACE("Partition: %s new size %lld bytes",
 			!strcmp(partition->type, "ubipartition") ? partition->volname : partition->device,
 			partition->partsize);