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/gui/folder_select.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/gui/folder_select.c')
-rw-r--r-- | apps/gui/folder_select.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/apps/gui/folder_select.c b/apps/gui/folder_select.c index 50d25e7305..a76d77562b 100644 --- a/apps/gui/folder_select.c +++ b/apps/gui/folder_select.c | |||
@@ -185,7 +185,7 @@ static struct folder* load_folder(struct folder* parent, char *folder) | |||
185 | if (len >= sizeof(fullpath)) | 185 | if (len >= sizeof(fullpath)) |
186 | goto fail; | 186 | goto fail; |
187 | } | 187 | } |
188 | strlcpy(&fullpath[len], folder, sizeof(fullpath) - len); | 188 | strmemccpy(&fullpath[len], folder, sizeof(fullpath) - len); |
189 | logf("load_folder: [%s]", fullpath); | 189 | logf("load_folder: [%s]", fullpath); |
190 | 190 | ||
191 | dir = opendir(fullpath); | 191 | dir = opendir(fullpath); |
@@ -518,7 +518,7 @@ static int select_paths(struct folder* root, const char* filenames) | |||
518 | lastfnp = fnp; | 518 | lastfnp = fnp; |
519 | if (len <= 0 || len + 1 >= buflen) | 519 | if (len <= 0 || len + 1 >= buflen) |
520 | continue; | 520 | continue; |
521 | strlcpy(buf, sstr, len + 1); | 521 | strmemccpy(buf, sstr, len + 1); |
522 | struct child *item = find_from_filename(buf, root); | 522 | struct child *item = find_from_filename(buf, root); |
523 | if (item) | 523 | if (item) |
524 | item->state = SELECTED; | 524 | item->state = SELECTED; |
@@ -563,7 +563,7 @@ static void save_folders_r(struct folder *root, char* dst, size_t maxlen, size_t | |||
563 | int dlen = strlen(dst); | 563 | int dlen = strlen(dst); |
564 | if (dlen + len >= maxlen) | 564 | if (dlen + len >= maxlen) |
565 | continue; | 565 | continue; |
566 | strlcpy(&dst[dlen], buffer_front, maxlen - dlen); | 566 | strmemccpy(&dst[dlen], buffer_front, maxlen - dlen); |
567 | } | 567 | } |
568 | else | 568 | else |
569 | { | 569 | { |