From 96900845a52c88433dea9e0bef8216d7d2bb49f4 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 28 Jul 2024 15:29:22 +0800 Subject: [PATCH] fs/romfs: Change the type of num from uint8_t to uint16_t to support the directory with more than 255 files Signed-off-by: Xiang Xiao --- fs/romfs/fs_romfsutil.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/romfs/fs_romfsutil.c b/fs/romfs/fs_romfsutil.c index d597d157ae..3b14516b41 100644 --- a/fs/romfs/fs_romfsutil.c +++ b/fs/romfs/fs_romfsutil.c @@ -605,7 +605,7 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm, FAR struct romfs_nodeinfo_s **child; FAR struct romfs_nodeinfo_s *nodeinfo; char childname[NAME_MAX + 1]; - uint8_t num = 0; + uint16_t count = 0; uint32_t info; size_t nsize; int ret; @@ -670,21 +670,21 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm, return ret; } - if (child == NULL || nodeinfo->rn_count == num - 1) + if (child == NULL || nodeinfo->rn_count == count - 1) { FAR void *tmp; tmp = fs_heap_realloc(nodeinfo->rn_child, - (num + NODEINFO_NINCR) * sizeof(*nodeinfo->rn_child)); + (count + NODEINFO_NINCR) * sizeof(*nodeinfo->rn_child)); if (tmp == NULL) { return -ENOMEM; } nodeinfo->rn_child = tmp; - memset(nodeinfo->rn_child + num, 0, NODEINFO_NINCR * + memset(nodeinfo->rn_child + count, 0, NODEINFO_NINCR * sizeof(*nodeinfo->rn_child)); - num += NODEINFO_NINCR; + count += NODEINFO_NINCR; } child = &nodeinfo->rn_child[nodeinfo->rn_count++];