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 /apps/tagcache.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 'apps/tagcache.c')
-rw-r--r-- | apps/tagcache.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index c5c40b9d50..a6c4c875be 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -853,7 +853,7 @@ static bool retrieve(struct tagcache_search *tcs, IF_DIRCACHE(int idx_id,) | |||
853 | { | 853 | { |
854 | struct tagfile_entry *ep = | 854 | struct tagfile_entry *ep = |
855 | (struct tagfile_entry *)&tcramcache.hdr->tags[tag][seek]; | 855 | (struct tagfile_entry *)&tcramcache.hdr->tags[tag][seek]; |
856 | strlcpy(buf, ep->tag_data, bufsz); | 856 | strmemccpy(buf, ep->tag_data, bufsz); |
857 | 857 | ||
858 | return true; | 858 | return true; |
859 | } | 859 | } |
@@ -3469,7 +3469,7 @@ static bool write_tag(int fd, const char *tagstr, const char *datastr) | |||
3469 | } | 3469 | } |
3470 | 3470 | ||
3471 | str_setlen(buf, bufsz - 1); | 3471 | str_setlen(buf, bufsz - 1); |
3472 | strlcpy(&buf[i], "\" ", (bufsz - i - 1)); | 3472 | strmemccpy(&buf[i], "\" ", (bufsz - i - 1)); |
3473 | 3473 | ||
3474 | write(fd, buf, i + 2); | 3474 | write(fd, buf, i + 2); |
3475 | 3475 | ||
@@ -4737,7 +4737,7 @@ void do_tagcache_build(const char *path[]) | |||
4737 | /* check_dir might add new roots */ | 4737 | /* check_dir might add new roots */ |
4738 | for(this = &roots_ll[0]; this; this = this->next) | 4738 | for(this = &roots_ll[0]; this; this = this->next) |
4739 | { | 4739 | { |
4740 | strlcpy(curpath, this->path, sizeof(curpath)); | 4740 | strmemccpy(curpath, this->path, sizeof(curpath)); |
4741 | ret = ret && check_dir(this->path, true); | 4741 | ret = ret && check_dir(this->path, true); |
4742 | } | 4742 | } |
4743 | free_search_roots(&roots_ll[0]); | 4743 | free_search_roots(&roots_ll[0]); |
@@ -4792,7 +4792,7 @@ void tagcache_build(void) | |||
4792 | { | 4792 | { |
4793 | char *vect[MAX_STATIC_ROOTS + 1]; /* +1 to ensure NULL sentinel */ | 4793 | char *vect[MAX_STATIC_ROOTS + 1]; /* +1 to ensure NULL sentinel */ |
4794 | char str[sizeof(global_settings.tagcache_scan_paths)]; | 4794 | char str[sizeof(global_settings.tagcache_scan_paths)]; |
4795 | strlcpy(str, global_settings.tagcache_scan_paths, sizeof(str)); | 4795 | strmemccpy(str, global_settings.tagcache_scan_paths, sizeof(str)); |
4796 | 4796 | ||
4797 | int res = split_string(str, ':', vect, MAX_STATIC_ROOTS); | 4797 | int res = split_string(str, ':', vect, MAX_STATIC_ROOTS); |
4798 | vect[res] = NULL; | 4798 | vect[res] = NULL; |