From f6c719d7ec71cc7771c46d3daa390924a3871ba3 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 14 Nov 2022 11:32:34 -0500 Subject: 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 --- apps/shortcuts.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apps/shortcuts.c') 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) if (type == SHORTCUT_SETTING) sc->u.setting = (void*)value; else - strlcpy(sc->u.path, value, MAX_PATH); + strmemccpy(sc->u.path, value, MAX_PATH); if (first_idx_to_writeback < 0) first_idx_to_writeback = shortcut_count - 1; @@ -325,7 +325,7 @@ static int readline_cb(int n, char *buf, void *parameters) } else if (nm_op == 1) /*name*/ { - strlcpy(sc->name, value, MAX_SHORTCUT_NAME); + strmemccpy(sc->name, value, MAX_SHORTCUT_NAME); } else if (nm_op == 2) /*data*/ { @@ -339,7 +339,7 @@ static int readline_cb(int n, char *buf, void *parameters) case SHORTCUT_FILE: case SHORTCUT_DEBUGITEM: case SHORTCUT_PLAYLISTMENU: - strlcpy(sc->u.path, value, MAX_PATH); + strmemccpy(sc->u.path, value, MAX_PATH); break; case SHORTCUT_SETTING: sc->u.setting = find_setting_by_cfgname(value, NULL); @@ -374,7 +374,7 @@ static int readline_cb(int n, char *buf, void *parameters) } else if (nm_op == 4) /*talkclip*/ { - strlcpy(sc->talk_clip, value, MAX_PATH); + strmemccpy(sc->talk_clip, value, MAX_PATH); } } return 0; @@ -534,7 +534,7 @@ static int shortcut_menu_speak_item(int selected_item, void * data) if (*filename != '\0') { int dirlen = (filename - sc->u.path); - strlcpy(path, sc->u.path, dirlen + 1); + strmemccpy(path, sc->u.path, dirlen + 1); dir = opendir(path); if (dir) { -- cgit v1.2.3