aboutsummaryrefslogtreecommitdiff
path: root/bin/gensquashfs/test
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-19 10:13:49 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-19 11:17:54 +0200
commite1e655b02f6c54177f9070eeb221ab95c6d4e20f (patch)
treeb5e64c6aa8ca6121858e49f691aaf87de329081b /bin/gensquashfs/test
parent982db0d8d6fdc32d605f716bd891b5bbc4838608 (diff)
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs/test')
-rw-r--r--bin/gensquashfs/test/sort_file.c16
1 files changed, 7 insertions, 9 deletions
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) /