From 2f172b69bda25d26790538cea7a15044f8207a7b Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 15 Sep 2023 14:50:58 +0200 Subject: libsqfs: Internalize sqfs_dir_reader_find function The only user in the code base is sqfs_dir_reader_find_by_path. Signed-off-by: David Oberhollenzer --- lib/sqfs/src/dir_reader.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'lib/sqfs') diff --git a/lib/sqfs/src/dir_reader.c b/lib/sqfs/src/dir_reader.c index d5a8cbd..c44198e 100644 --- a/lib/sqfs/src/dir_reader.c +++ b/lib/sqfs/src/dir_reader.c @@ -301,29 +301,6 @@ int sqfs_dir_reader_rewind(sqfs_dir_reader_t *rd) return 0; } -int sqfs_dir_reader_find(sqfs_dir_reader_t *rd, const char *name) -{ - sqfs_dir_node_t *ent; - int ret; - - ret = sqfs_dir_reader_rewind(rd); - if (ret != 0) - return ret; - - do { - ret = sqfs_dir_reader_read(rd, &ent); - if (ret < 0) - return ret; - if (ret > 0) - return SQFS_ERROR_NO_ENTRY; - - ret = strcmp((const char *)ent->name, name); - free(ent); - } while (ret < 0); - - return ret == 0 ? 0 : SQFS_ERROR_NO_ENTRY; -} - int sqfs_dir_reader_get_inode(sqfs_dir_reader_t *rd, sqfs_inode_generic_t **inode) { @@ -353,6 +330,25 @@ int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd, return dcache_add(rd, *inode, rd->super.root_inode_ref); } +static int find_entry(sqfs_dir_reader_t *rd, const char *name) +{ + sqfs_dir_node_t *ent; + int ret; + + do { + ret = sqfs_dir_reader_read(rd, &ent); + if (ret < 0) + return ret; + if (ret > 0) + return SQFS_ERROR_NO_ENTRY; + + ret = strcmp((const char *)ent->name, name); + free(ent); + } while (ret < 0); + + return ret == 0 ? 0 : SQFS_ERROR_NO_ENTRY; +} + int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd, const sqfs_inode_generic_t *start, const char *path, sqfs_inode_generic_t **out) @@ -389,7 +385,7 @@ int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd, if (name == NULL) return SQFS_ERROR_ALLOC; - ret = sqfs_dir_reader_find(rd, name); + ret = find_entry(rd, name); free(name); if (ret) return ret; -- cgit v1.2.3