fs/romfs: Replace strlcpy and strcmp with memcpy and memcmp

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2024-07-28 15:16:28 +08:00 committed by GUIDINGLI
parent 4d9512f0d4
commit 7814c40a99
2 changed files with 7 additions and 7 deletions

View file

@ -265,7 +265,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath,
rf->rf_size = nodeinfo.rn_size;
rf->rf_type = (uint8_t)(nodeinfo.rn_next & RFNEXT_ALLMODEMASK);
strlcpy(rf->rf_path, relpath, len + 1);
memcpy(rf->rf_path, relpath, len + 1);
/* Get the start of the file data */
@ -714,7 +714,7 @@ static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp)
newrf->rf_startoffset = oldrf->rf_startoffset;
newrf->rf_size = oldrf->rf_size;
newrf->rf_type = oldrf->rf_type;
strlcpy(newrf->rf_path, oldrf->rf_path, len + 1);
memcpy(newrf->rf_path, oldrf->rf_path, len + 1);
/* Configure buffering to support access to this file */

View file

@ -277,7 +277,7 @@ static int romfs_nodeinfo_search(FAR const void *a, FAR const void *b)
{
FAR struct romfs_nodeinfo_s *nodeinfo = *(FAR struct romfs_nodeinfo_s **)b;
FAR const struct romfs_entryname_s *entry = a;
FAR const char *name2 = nodeinfo->rn_name;
FAR const char *name = nodeinfo->rn_name;
size_t len = nodeinfo->rn_namesize;
int ret;
@ -286,12 +286,12 @@ static int romfs_nodeinfo_search(FAR const void *a, FAR const void *b)
len = entry->re_len;
}
ret = strncmp(entry->re_name, name2, len);
if (!ret)
ret = memcmp(entry->re_name, name, len);
if (ret == 0)
{
if (entry->re_name[len] == '/' || entry->re_name[len] == '\0')
{
return name2[len] == '\0' ? 0 : -1;
return name[len] == '\0' ? 0 : -1;
}
else
{
@ -642,7 +642,7 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm,
nodeinfo->rn_origoffset = origoffset;
nodeinfo->rn_next = next;
nodeinfo->rn_namesize = nsize;
strlcpy(nodeinfo->rn_name, name, nsize + 1);
memcpy(nodeinfo->rn_name, name, nsize + 1);
#ifdef CONFIG_FS_ROMFS_WRITEABLE
if (!list_is_empty(&rm->rm_sparelist))