From 5f5571e241a8e6f56cabcef6c4a0e816b0f382ca Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 8 Oct 2016 20:04:48 +0200 Subject: [PATCH] (libretro-common) don't do implicit memset --- libretro-common/file/archive_file.c | 10 +++++++--- libretro-common/file/file_path.c | 12 +++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libretro-common/file/archive_file.c b/libretro-common/file/archive_file.c index cfb68db5ae..766b198a13 100644 --- a/libretro-common/file/archive_file.c +++ b/libretro-common/file/archive_file.c @@ -232,10 +232,12 @@ static int file_archive_extract_cb(const char *name, const char *valid_exts, /* Extract first file that matches our list. */ if (ext && string_list_find_elem(userdata->ext, ext)) { - char new_path[PATH_MAX_LENGTH] = {0}; - char wanted_file[PATH_MAX_LENGTH] = {0}; + char new_path[PATH_MAX_LENGTH]; + char wanted_file[PATH_MAX_LENGTH]; const char *delim = NULL; + new_path[0] = wanted_file[0] = '\0'; + if (userdata->extraction_directory) fill_pathname_join(new_path, userdata->extraction_directory, path_basename(name), sizeof(new_path)); @@ -754,9 +756,11 @@ const struct file_archive_file_backend *file_archive_get_7z_file_backend(void) const struct file_archive_file_backend* file_archive_get_file_backend(const char *path) { + char newpath[PATH_MAX_LENGTH]; const char *file_ext = NULL; char *last = NULL; - char newpath[PATH_MAX_LENGTH] = {0}; + + newpath[0] = '\0'; strlcpy(newpath, path, sizeof(newpath)); diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index e854deac2e..6b0c5e12a4 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -257,9 +257,11 @@ bool path_file_exists(const char *path) void fill_pathname(char *out_path, const char *in_path, const char *replace, size_t size) { - char tmp_path[PATH_MAX_LENGTH] = {0}; + char tmp_path[PATH_MAX_LENGTH]; char *tok = NULL; + tmp_path[0] = '\0'; + retro_assert(strlcpy(tmp_path, in_path, sizeof(tmp_path)) < sizeof(tmp_path)); if ((tok = (char*)strrchr(path_basename(tmp_path), '.'))) @@ -575,7 +577,9 @@ bool path_is_absolute(const char *path) void path_resolve_realpath(char *buf, size_t size) { #ifndef RARCH_CONSOLE - char tmp[PATH_MAX_LENGTH] = {0}; + char tmp[PATH_MAX_LENGTH]; + + tmp[0] = '\0'; strlcpy(tmp, buf, sizeof(tmp)); @@ -728,11 +732,13 @@ void fill_pathname_join_delim_concat(char *out_path, const char *dir, void fill_short_pathname_representation(char* out_rep, const char *in_path, size_t size) { - char path_short[PATH_MAX_LENGTH] = {0}; + char path_short[PATH_MAX_LENGTH]; #ifdef HAVE_COMPRESSION char *last_slash = NULL; #endif + path_short[0] = '\0'; + fill_pathname(path_short, path_basename(in_path), "", sizeof(path_short));