Skip to contentSkip to conversation

docparse/docparse.c: Make docparse check implied flags recursively

PATCH New Xiao Yang 3 participants 7 messages Mar 3, 2021 – Mar 10, 2021 Library code

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/3 docparse/docparse.c: Make docparse check implied flags recursively

Current docparse cannot check implied flags recursively.

---
 docparse/docparse.c | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)
docparse/docparse.c +24 -14
index 9f617c8bb..5879a9944 100644
@@ -361,14 +361,16 @@ static const char *filter_out[] = {
 
 static struct implies {
 	const char *flag;
-	const char *implies;
+	const char **implies;
 } implies[] = {
-	{"format_device", "needs_device"},
-	{"mount_device", "needs_device"},
-	{"mount_device", "format_device"},
-	{"all_filesystems", "needs_device"},
-	{"needs_device", "needs_tmpdir"},
-	{NULL, NULL}
+	{"mount_device", (const char *[]) {"format_device", "needs_device",
+		"needs_tmpdir", NULL}},
+	{"format_device", (const char *[]) {"needs_device", "needs_tmpdir",
+		NULL}},
+	{"all_filesystems", (const char *[]) {"needs_device", "needs_tmpdir",
+		NULL}},
+	{"needs_device", (const char *[]) {"needs_tmpdir", NULL}},
+	{NULL, (const char *[]) {NULL}}
 };
 
 const char *strip_name(char *path)
@@ -384,7 +386,7 @@ const char *strip_name(char *path)
 
 int main(int argc, char *argv[])
 {
-	unsigned int i;
+	unsigned int i, j;
 	struct data_node *res;
 
 	if (argc != 2) {
@@ -402,15 +404,23 @@ int main(int argc, char *argv[])
 
 	/* Normalize the result */
 	for (i = 0; implies[i].flag; i++) {
-		if (data_node_hash_get(res, implies[i].flag) &&
-		    data_node_hash_get(res, implies[i].implies))
-			fprintf(stderr, "%s: useless tag: %s\n", argv[1], implies[i].implies);
+		if (data_node_hash_get(res, implies[i].flag)) {
+			for (j = 0; implies[i].implies[j]; j++) {
+				if (data_node_hash_get(res, implies[i].implies[j]))
+					fprintf(stderr, "%s: useless tag: %s\n",
+						argv[1], implies[i].implies[j]);
+			}
+		}
 	}
 
 	for (i = 0; implies[i].flag; i++) {
-		if (data_node_hash_get(res, implies[i].flag) &&
-		    !data_node_hash_get(res, implies[i].implies))
-			data_node_hash_add(res, implies[i].implies, data_node_string("1"));
+		if (data_node_hash_get(res, implies[i].flag)) {
+			for (j = 0; implies[i].implies[j]; j++) {
+				if (!data_node_hash_get(res, implies[i].implies[j]))
+					data_node_hash_add(res, implies[i].implies[j],
+							   data_node_string("1"));
+			}
+		}
 	}
 
 	data_node_hash_add(res, "fname", data_node_string(argv[1]));
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/3 docparse/docparse.c: Add missing entries into struct implies

needs_checkpoints and resource_files imply needs_tmpdir.

---
 docparse/docparse.c | 2 ++
 1 file changed, 2 insertions(+)
docparse/docparse.c +2 -0
index 5879a9944..790c84a84 100644
@@ -370,6 +370,8 @@ static struct implies {
 	{"all_filesystems", (const char *[]) {"needs_device", "needs_tmpdir",
 		NULL}},
 	{"needs_device", (const char *[]) {"needs_tmpdir", NULL}},
+	{"needs_checkpoints", (const char *[]) {"needs_tmpdir", NULL}},
+	{"resource_files", (const char *[]) {"needs_tmpdir", NULL}},
 	{NULL, (const char *[]) {NULL}}
 };
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/3 docparse/docparse.c: Add missing entries into struct implies

Hi Yang,

Quoted 1 line

needs_checkpoints and resource_files imply needs_tmpdir.

Thanks!

Kind regards,
Petr

author
#3 lore raw

PATCH 3/3 lib/tst_test.c: Remove redundant needs_device

In reply to Xiao Yang
---
 lib/tst_test.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
lib/tst_test.c +3 -5
index 6bbee030b..9987e9543 100644
@@ -942,13 +942,11 @@ static void do_setup(int argc, char *argv[])
 				tst_brk(TCONF, "%s driver not available", name);
 	}
 
-	if (tst_test->format_device)
-		tst_test->needs_device = 1;
+	if (tst_test->mount_device)
+		tst_test->format_device = 1;
 
-	if (tst_test->mount_device) {
+	if (tst_test->format_device)
 		tst_test->needs_device = 1;
-		tst_test->format_device = 1;
-	}
 
 	if (tst_test->all_filesystems)
 		tst_test->needs_device = 1;
Signature · 1 line
2.25.1
#6 lore raw

PATCH 1/3 docparse/docparse.c: Make docparse check implied flags recursively

Hi Petr,

Thanks for your review and pushed the patch set.

Best Regards,

Xiao Yang

Quoted 9 lines · Petr Vorel

Hi Yang,

Quoted 1 line

Current docparse cannot check implied flags recursively.

Thanks!

Kind regards,
Petr