[LTP] [PATCH 2/2] metaparse: Map arrays with designated initializers to JSON objects
    Cyril Hrubis 
    chrubis@suse.cz
       
    Fri Jul 11 13:33:04 CEST 2025
    
    
  
Hi!
> This patch is actually causing documentation build failure due to the 
> way we are defining .hugepages as:
> 
>      .hugepages = {TST_NO_HUGEPAGES},
> 
> The shmget02 metadata (for instance) will have an empty hugepages 
> dictionary:
Ah, right, I've missed a special case in the C structure parsing.
This on the top of the patchset fixes the problem:
diff --git a/metadata/metaparse.c b/metadata/metaparse.c
index e9e9aee10..36736ac06 100644
--- a/metadata/metaparse.c
+++ b/metadata/metaparse.c
@@ -379,13 +379,17 @@ static int array_is_hash(FILE *f)
        long pos = ftell(f);
        int has_ids = 1;
        int elem_seen = 0;
+       int comma_last = 0;
        int in_id = 1;
        char *token;
        while ((token = next_token(f, NULL))) {
-               if (!strcmp(token, "}"))
+               if (!strcmp(token, "}")) {
+                       if (in_id && !comma_last)
+                               has_ids = 0;
                        goto ret;
+               }
                elem_seen = 1;
@@ -419,8 +423,12 @@ static int array_is_hash(FILE *f)
                        }
                        in_id = 1;
+
+                       comma_last = 1;
                } else if (!strcmp(token, "=")) {
                        in_id = 0;
+               } else {
+                       comma_last = 0;
                }
        }
I will send a new version.
-- 
Cyril Hrubis
chrubis@suse.cz
    
    
More information about the ltp
mailing list