diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-11-14 11:32:34 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2022-11-14 23:56:16 -0500 |
commit | f6c719d7ec71cc7771c46d3daa390924a3871ba3 (patch) | |
tree | e6209f23565db01809f75067247e667963092ff6 /firmware/common/dircache.c | |
parent | b25a9d8f99b75570d18ea64602de7fe48da612d6 (diff) | |
download | rockbox-f6c719d7ec71cc7771c46d3daa390924a3871ba3.tar.gz rockbox-f6c719d7ec71cc7771c46d3daa390924a3871ba3.zip |
replace strlcpy with strmemccpy
replace applicable calls to strlcpy with calls to strmemccpy
which null terminates on truncation
in theory the strmemccpy calls should be slightly faster since they
don't traverse the rest of the source string on truncation
but I seriously doubt there is too much of that going on in the code base
Change-Id: Ia0251514e36a6242bbf3f03c5e0df123aba60ed2
Diffstat (limited to 'firmware/common/dircache.c')
-rw-r--r-- | firmware/common/dircache.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 1d6371a6b5..5902f8b3fd 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c | |||
@@ -1707,8 +1707,8 @@ static int sab_process_dir(struct dircache_entry *ce) | |||
1707 | /* save current paths size */ | 1707 | /* save current paths size */ |
1708 | int pathpos = strlen(sab_path); | 1708 | int pathpos = strlen(sab_path); |
1709 | /* append entry */ | 1709 | /* append entry */ |
1710 | strlcpy(&sab_path[pathpos], "/", sizeof(sab_path) - pathpos); | 1710 | strmemccpy(&sab_path[pathpos], "/", sizeof(sab_path) - pathpos); |
1711 | strlcpy(&sab_path[pathpos+1], entry->d_name, sizeof(sab_path) - pathpos - 1); | 1711 | strmemccpy(&sab_path[pathpos+1], entry->d_name, sizeof(sab_path) - pathpos - 1); |
1712 | 1712 | ||
1713 | int rc = sab_process_dir(ce->down); | 1713 | int rc = sab_process_dir(ce->down); |
1714 | /* restore path */ | 1714 | /* restore path */ |
@@ -1735,7 +1735,7 @@ static int sab_process_dir(struct dircache_entry *ce) | |||
1735 | static int sab_process_volume(IF_MV(int volume,) struct dircache_entry *ce) | 1735 | static int sab_process_volume(IF_MV(int volume,) struct dircache_entry *ce) |
1736 | { | 1736 | { |
1737 | memset(ce, 0, sizeof(struct dircache_entry)); | 1737 | memset(ce, 0, sizeof(struct dircache_entry)); |
1738 | strlcpy(sab_path, "/", sizeof sab_path); | 1738 | strmemccpy(sab_path, "/", sizeof sab_path); |
1739 | return sab_process_dir(ce); | 1739 | return sab_process_dir(ce); |
1740 | } | 1740 | } |
1741 | 1741 | ||
@@ -1755,7 +1755,7 @@ int dircache_readdir_r(struct dircache_dirscan *dir, struct DIRENT *result) | |||
1755 | 1755 | ||
1756 | dir->scanidx = ce - dircache_root; | 1756 | dir->scanidx = ce - dircache_root; |
1757 | 1757 | ||
1758 | strlcpy(result->d_name, ce->d_name, sizeof (result->d_name)); | 1758 | strmemccpy(result->d_name, ce->d_name, sizeof (result->d_name)); |
1759 | result->info = ce->dirinfo; | 1759 | result->info = ce->dirinfo; |
1760 | 1760 | ||
1761 | return 1; | 1761 | return 1; |