summaryrefslogtreecommitdiff
path: root/apps/tagtree.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-11-14 11:32:34 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2022-11-14 23:56:16 -0500
commitf6c719d7ec71cc7771c46d3daa390924a3871ba3 (patch)
treee6209f23565db01809f75067247e667963092ff6 /apps/tagtree.c
parentb25a9d8f99b75570d18ea64602de7fe48da612d6 (diff)
downloadrockbox-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/tagtree.c')
-rw-r--r--apps/tagtree.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index abb6cf5cb0..fc1ce26f40 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -779,7 +779,7 @@ static bool parse_search(struct menu_entry *entry, const char *str)
779 logf("tagtree failed to allocate %s", "menu"); 779 logf("tagtree failed to allocate %s", "menu");
780 return false; 780 return false;
781 } 781 }
782 strlcpy(menus[menu_count]->id, buf, MAX_MENU_ID_SIZE); 782 strmemccpy(menus[menu_count]->id, buf, MAX_MENU_ID_SIZE);
783 entry->link = menu_count; 783 entry->link = menu_count;
784 ++menu_count; 784 ++menu_count;
785 785
@@ -1118,7 +1118,7 @@ static int parse_line(int n, char *buf, void *parameters)
1118 } 1118 }
1119 menu = menus[menu_count]; 1119 menu = menus[menu_count];
1120 ++menu_count; 1120 ++menu_count;
1121 strlcpy(menu->id, data, MAX_MENU_ID_SIZE); 1121 strmemccpy(menu->id, data, MAX_MENU_ID_SIZE);
1122 } 1122 }
1123 1123
1124 if (get_token_str(menu->title, sizeof(menu->title)) < 0) 1124 if (get_token_str(menu->title, sizeof(menu->title)) < 0)
@@ -1898,8 +1898,8 @@ int tagtree_enter(struct tree_context* c, bool is_visible)
1898 csi = &menu->items[seek]->si; 1898 csi = &menu->items[seek]->si;
1899 c->currextra = 0; 1899 c->currextra = 0;
1900 1900
1901 strlcpy(current_title[c->currextra], dptr->name, 1901 strmemccpy(current_title[c->currextra], dptr->name,
1902 sizeof(current_title[0])); 1902 sizeof(current_title[0]));
1903 1903
1904 /* Read input as necessary. */ 1904 /* Read input as necessary. */
1905 for (i = 0; i < csi->tagorder_count; i++) 1905 for (i = 0; i < csi->tagorder_count; i++)
@@ -1928,7 +1928,7 @@ int tagtree_enter(struct tree_context* c, bool is_visible)
1928 if (source == source_current_path && id3) 1928 if (source == source_current_path && id3)
1929 { 1929 {
1930 char *e; 1930 char *e;
1931 strlcpy(searchstring, id3->path, SEARCHSTR_SIZE); 1931 strmemccpy(searchstring, id3->path, SEARCHSTR_SIZE);
1932 e = strrchr(searchstring, '/'); 1932 e = strrchr(searchstring, '/');
1933 if (e) 1933 if (e)
1934 *e = '\0'; 1934 *e = '\0';
@@ -1941,7 +1941,7 @@ int tagtree_enter(struct tree_context* c, bool is_visible)
1941 char **src = (char**)((char*)id3 + offset); 1941 char **src = (char**)((char*)id3 + offset);
1942 if (*src) 1942 if (*src)
1943 { 1943 {
1944 strlcpy(searchstring, *src, SEARCHSTR_SIZE); 1944 strmemccpy(searchstring, *src, SEARCHSTR_SIZE);
1945 } 1945 }
1946 } 1946 }
1947 else 1947 else
@@ -1994,8 +1994,8 @@ int tagtree_enter(struct tree_context* c, bool is_visible)
1994 c->dirlevel--; 1994 c->dirlevel--;
1995 1995
1996 /* Update the statusbar title */ 1996 /* Update the statusbar title */
1997 strlcpy(current_title[c->currextra], dptr->name, 1997 strmemccpy(current_title[c->currextra], dptr->name,
1998 sizeof(current_title[0])); 1998 sizeof(current_title[0]));
1999 break; 1999 break;
2000 2000
2001 default: 2001 default:
@@ -2251,7 +2251,7 @@ char* tagtree_get_entry_name(struct tree_context *c, int id,
2251 struct tagentry *entry = tagtree_get_entry(c, id); 2251 struct tagentry *entry = tagtree_get_entry(c, id);
2252 if (!entry) 2252 if (!entry)
2253 return NULL; 2253 return NULL;
2254 strlcpy(buf, entry->name, bufsize); 2254 strmemccpy(buf, entry->name, bufsize);
2255 return buf; 2255 return buf;
2256} 2256}
2257 2257