From e1e655b02f6c54177f9070eeb221ab95c6d4e20f Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 19 Apr 2023 10:13:49 +0200 Subject: libfstree: hoist file link pointer into parent structure Instead of having a file_info_t next pointer, requiring an up-cast to tree_node_t all the time, simply add a "next_by_type" pointer to the tree node itself, which can also be used for other purposes by other node types and removes the need for up-casting. Signed-off-by: David Oberhollenzer --- bin/gensquashfs/test/sort_file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'bin/gensquashfs/test') diff --git a/bin/gensquashfs/test/sort_file.c b/bin/gensquashfs/test/sort_file.c index 4b5caf8..8022cff 100644 --- a/bin/gensquashfs/test/sort_file.c +++ b/bin/gensquashfs/test/sort_file.c @@ -151,7 +151,7 @@ static istream_t memstream = { int main(int argc, char **argv) { fstree_defaults_t fsd; - file_info_t *fi; + tree_node_t *n; fstree_t fs; size_t i; (void)argc; (void)argv; @@ -167,8 +167,7 @@ int main(int argc, char **argv) fstree_post_process(&fs); - for (i = 0, fi = fs.files; fi != NULL; fi = fi->next, ++i) { - tree_node_t *n = container_of(fi, tree_node_t, data.file); + for (i = 0, n = fs.files; n != NULL; n = n->next_by_type, ++i) { char *path = fstree_get_path(n); int ret; @@ -180,8 +179,8 @@ int main(int argc, char **argv) TEST_STR_EQUAL(initial_order[i], path); free(path); - TEST_EQUAL_I(fi->priority, 0); - TEST_EQUAL_I(fi->flags, 0); + TEST_EQUAL_I(n->data.file.priority, 0); + TEST_EQUAL_I(n->data.file.flags, 0); } TEST_EQUAL_UI(i, sizeof(initial_order) / sizeof(initial_order[0])); @@ -194,8 +193,7 @@ int main(int argc, char **argv) TEST_ASSERT(fstree_sort_files(&fs, &memstream) == 0); - for (i = 0, fi = fs.files; fi != NULL; fi = fi->next, ++i) { - tree_node_t *n = container_of(fi, tree_node_t, data.file); + for (i = 0, n = fs.files; n != NULL; n = n->next_by_type, ++i) { char *path = fstree_get_path(n); int ret; @@ -207,8 +205,8 @@ int main(int argc, char **argv) TEST_STR_EQUAL(after_sort_order[i], path); free(path); - TEST_EQUAL_I(fi->priority, priorities[i]); - TEST_EQUAL_I(fi->flags, flags[i]); + TEST_EQUAL_I(n->data.file.priority, priorities[i]); + TEST_EQUAL_I(n->data.file.flags, flags[i]); } TEST_EQUAL_UI(i, sizeof(after_sort_order) / -- cgit v1.2.3