Skip to content

Commit 7814c40

Browse files
xiaoxiang781216GUIDINGLI
authored andcommitted
fs/romfs: Replace strlcpy and strcmp with memcpy and memcmp
Signed-off-by: Xiang Xiao <[email protected]>
1 parent 4d9512f commit 7814c40

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

fs/romfs/fs_romfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath,
265265

266266
rf->rf_size = nodeinfo.rn_size;
267267
rf->rf_type = (uint8_t)(nodeinfo.rn_next & RFNEXT_ALLMODEMASK);
268-
strlcpy(rf->rf_path, relpath, len + 1);
268+
memcpy(rf->rf_path, relpath, len + 1);
269269

270270
/* Get the start of the file data */
271271

@@ -714,7 +714,7 @@ static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp)
714714
newrf->rf_startoffset = oldrf->rf_startoffset;
715715
newrf->rf_size = oldrf->rf_size;
716716
newrf->rf_type = oldrf->rf_type;
717-
strlcpy(newrf->rf_path, oldrf->rf_path, len + 1);
717+
memcpy(newrf->rf_path, oldrf->rf_path, len + 1);
718718

719719
/* Configure buffering to support access to this file */
720720

fs/romfs/fs_romfsutil.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static int romfs_nodeinfo_search(FAR const void *a, FAR const void *b)
277277
{
278278
FAR struct romfs_nodeinfo_s *nodeinfo = *(FAR struct romfs_nodeinfo_s **)b;
279279
FAR const struct romfs_entryname_s *entry = a;
280-
FAR const char *name2 = nodeinfo->rn_name;
280+
FAR const char *name = nodeinfo->rn_name;
281281
size_t len = nodeinfo->rn_namesize;
282282
int ret;
283283

@@ -286,12 +286,12 @@ static int romfs_nodeinfo_search(FAR const void *a, FAR const void *b)
286286
len = entry->re_len;
287287
}
288288

289-
ret = strncmp(entry->re_name, name2, len);
290-
if (!ret)
289+
ret = memcmp(entry->re_name, name, len);
290+
if (ret == 0)
291291
{
292292
if (entry->re_name[len] == '/' || entry->re_name[len] == '\0')
293293
{
294-
return name2[len] == '\0' ? 0 : -1;
294+
return name[len] == '\0' ? 0 : -1;
295295
}
296296
else
297297
{
@@ -642,7 +642,7 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm,
642642
nodeinfo->rn_origoffset = origoffset;
643643
nodeinfo->rn_next = next;
644644
nodeinfo->rn_namesize = nsize;
645-
strlcpy(nodeinfo->rn_name, name, nsize + 1);
645+
memcpy(nodeinfo->rn_name, name, nsize + 1);
646646

647647
#ifdef CONFIG_FS_ROMFS_WRITEABLE
648648
if (!list_is_empty(&rm->rm_sparelist))

0 commit comments

Comments
 (0)