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/shortcuts.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/shortcuts.c')
-rw-r--r-- | apps/shortcuts.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/apps/shortcuts.c b/apps/shortcuts.c index 1253e77a65..752ca977e6 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c | |||
@@ -284,7 +284,7 @@ void shortcuts_add(enum shortcut_type type, const char* value) | |||
284 | if (type == SHORTCUT_SETTING) | 284 | if (type == SHORTCUT_SETTING) |
285 | sc->u.setting = (void*)value; | 285 | sc->u.setting = (void*)value; |
286 | else | 286 | else |
287 | strlcpy(sc->u.path, value, MAX_PATH); | 287 | strmemccpy(sc->u.path, value, MAX_PATH); |
288 | 288 | ||
289 | if (first_idx_to_writeback < 0) | 289 | if (first_idx_to_writeback < 0) |
290 | first_idx_to_writeback = shortcut_count - 1; | 290 | first_idx_to_writeback = shortcut_count - 1; |
@@ -325,7 +325,7 @@ static int readline_cb(int n, char *buf, void *parameters) | |||
325 | } | 325 | } |
326 | else if (nm_op == 1) /*name*/ | 326 | else if (nm_op == 1) /*name*/ |
327 | { | 327 | { |
328 | strlcpy(sc->name, value, MAX_SHORTCUT_NAME); | 328 | strmemccpy(sc->name, value, MAX_SHORTCUT_NAME); |
329 | } | 329 | } |
330 | else if (nm_op == 2) /*data*/ | 330 | else if (nm_op == 2) /*data*/ |
331 | { | 331 | { |
@@ -339,7 +339,7 @@ static int readline_cb(int n, char *buf, void *parameters) | |||
339 | case SHORTCUT_FILE: | 339 | case SHORTCUT_FILE: |
340 | case SHORTCUT_DEBUGITEM: | 340 | case SHORTCUT_DEBUGITEM: |
341 | case SHORTCUT_PLAYLISTMENU: | 341 | case SHORTCUT_PLAYLISTMENU: |
342 | strlcpy(sc->u.path, value, MAX_PATH); | 342 | strmemccpy(sc->u.path, value, MAX_PATH); |
343 | break; | 343 | break; |
344 | case SHORTCUT_SETTING: | 344 | case SHORTCUT_SETTING: |
345 | sc->u.setting = find_setting_by_cfgname(value, NULL); | 345 | sc->u.setting = find_setting_by_cfgname(value, NULL); |
@@ -374,7 +374,7 @@ static int readline_cb(int n, char *buf, void *parameters) | |||
374 | } | 374 | } |
375 | else if (nm_op == 4) /*talkclip*/ | 375 | else if (nm_op == 4) /*talkclip*/ |
376 | { | 376 | { |
377 | strlcpy(sc->talk_clip, value, MAX_PATH); | 377 | strmemccpy(sc->talk_clip, value, MAX_PATH); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | return 0; | 380 | return 0; |
@@ -534,7 +534,7 @@ static int shortcut_menu_speak_item(int selected_item, void * data) | |||
534 | if (*filename != '\0') | 534 | if (*filename != '\0') |
535 | { | 535 | { |
536 | int dirlen = (filename - sc->u.path); | 536 | int dirlen = (filename - sc->u.path); |
537 | strlcpy(path, sc->u.path, dirlen + 1); | 537 | strmemccpy(path, sc->u.path, dirlen + 1); |
538 | dir = opendir(path); | 538 | dir = opendir(path); |
539 | if (dir) | 539 | if (dir) |
540 | { | 540 | { |