(libretro-common) Small cleanups - don't NULL-terminate string

if we pass it off to fill_pathname_join (or another function that
uses strlcpy under the hood)
This commit is contained in:
libretroadmin 2022-07-22 19:33:30 +02:00
parent 1245cbc63b
commit 8d12918243
4 changed files with 12 additions and 17 deletions

View File

@ -150,21 +150,19 @@ function_t dylib_proc(dylib_t lib, const char *proc)
#ifdef _WIN32
HMODULE mod = (HMODULE)lib;
#ifndef __WINRT__
if (!mod)
mod = GetModuleHandle(NULL);
#else
/* GetModuleHandle is not available on UWP */
if (!mod)
{
#ifdef __WINRT__
/* GetModuleHandle is not available on UWP */
/* It's not possible to lookup symbols in current executable
* on UWP. */
DebugBreak();
return NULL;
}
#else
mod = GetModuleHandle(NULL);
#endif
sym = (function_t)GetProcAddress(mod, proc);
if (!sym)
}
if (!(sym = (function_t)GetProcAddress(mod, proc)))
{
set_dl_error();
return NULL;

View File

@ -139,7 +139,6 @@ static int dir_list_read(const char *dir,
continue;
}
file_path[0] = '\0';
fill_pathname_join(file_path, dir, name, sizeof(file_path));
if (retro_dirent_is_dir(entry, NULL))
@ -273,8 +272,8 @@ bool dir_list_initialize(struct string_list *list,
bool include_hidden, bool include_compressed,
bool recursive)
{
if (!list || !string_list_initialize(list))
return false;
return dir_list_append(list, dir, ext, include_dirs,
if (list && string_list_initialize(list))
return dir_list_append(list, dir, ext, include_dirs,
include_hidden, include_compressed, recursive);
return false;
}

View File

@ -77,9 +77,8 @@ void label_sanitize(char *label, bool (*left)(char*), bool (*right)(char*))
{
/* check for the start of the range */
if ((*left)(&label[lindex]))
copy = false;
if (copy)
copy = false;
else
new_label[rindex++] = label[lindex];
}
else if ((*right)(&label[lindex]))

View File

@ -798,7 +798,7 @@ int retro_vfs_stat_impl(const char *path, int32_t *size)
tmp = strdup(path);
len = strlen(tmp);
if (tmp[len-1] == '/')
tmp[len-1] = '\0';
tmp[len-1] = '\0';
dir_ret = sceIoGetstat(tmp, &buf);
free(tmp);
@ -1160,7 +1160,6 @@ bool retro_vfs_dirent_is_dir_impl(libretro_vfs_implementation_dir *rdir)
return false;
#endif
/* dirent struct doesn't have d_type, do it the slow way ... */
path[0] = '\0';
fill_pathname_join(path, rdir->orig_path, retro_vfs_dirent_get_name_impl(rdir), sizeof(path));
if (stat(path, &buf) < 0)
return false;