Prevent some implicit memsets

This commit is contained in:
twinaphex 2016-12-17 14:40:06 +01:00
parent aafae944cb
commit feae0823ce
16 changed files with 70 additions and 33 deletions

View File

@ -261,7 +261,9 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
/* Get the count of the files dropped */ /* Get the count of the files dropped */
static int win32_drag_query_file(HWND hwnd, WPARAM wparam) static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
{ {
char szFilename[1024] = {0}; char szFilename[1024];
szFilename[0] = '\0';
if (DragQueryFile((HDROP)wparam, 0xFFFFFFFF, NULL, 0)) if (DragQueryFile((HDROP)wparam, 0xFFFFFFFF, NULL, 0))
{ {

View File

@ -1306,8 +1306,11 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
if (settings->fps_show) if (settings->fps_show)
{ {
char buffer[128] = {0}; char buffer[128];
char buffer_fps[128] = {0}; char buffer_fps[128];
buffer[0] = buffer_fps[0] = '\0';
video_monitor_get_fps(buffer, sizeof(buffer), video_monitor_get_fps(buffer, sizeof(buffer),
settings->fps_show ? buffer_fps : NULL, sizeof(buffer_fps)); settings->fps_show ? buffer_fps : NULL, sizeof(buffer_fps));
runloop_msg_queue_push(buffer_fps, 1, 1, false); runloop_msg_queue_push(buffer_fps, 1, 1, false);

View File

@ -1438,13 +1438,15 @@ static bool gx_frame(void *data, const void *frame,
uint64_t frame_count, unsigned pitch, uint64_t frame_count, unsigned pitch,
const char *msg) const char *msg)
{ {
char fps_txt[128];
char fps_text_buf[128];
static struct retro_perf_counter gx_frame = {0}; static struct retro_perf_counter gx_frame = {0};
char fps_txt[128] = {0};
char fps_text_buf[128] = {0};
gx_video_t *gx = (gx_video_t*)data; gx_video_t *gx = (gx_video_t*)data;
u8 clear_efb = GX_FALSE; u8 clear_efb = GX_FALSE;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
fps_txt[0] = fps_text_buf[0] = '\0';
performance_counter_init(&gx_frame, "gx_frame"); performance_counter_init(&gx_frame, "gx_frame");
performance_counter_start(&gx_frame); performance_counter_start(&gx_frame);
@ -1540,11 +1542,13 @@ static bool gx_frame(void *data, const void *frame,
if (settings->fps_show) if (settings->fps_show)
{ {
char mem1_txt[128] = {0}; char mem1_txt[128];
char mem2_txt[128] = {0}; char mem2_txt[128];
unsigned x = 15; unsigned x = 15;
unsigned y = 35; unsigned y = 35;
mem1_txt[0] = mem2_txt[0] = '\0';
(void)mem2_txt; (void)mem2_txt;
gx_blit_line(gx, x, y, fps_text_buf); gx_blit_line(gx, x, y, fps_text_buf);

View File

@ -178,10 +178,12 @@ static int omapfb_detect_screen(omapfb_data_t *pdata)
int i, ret; int i, ret;
int w, h; int w, h;
FILE *f; FILE *f;
int fb_id, overlay_id = -1, display_id = -1; char buff[64];
char buff[64] = {0}; char manager_name[64];
char manager_name[64] = {0}; char display_name[64];
char display_name[64] = {0}; int fb_id, overlay_id = -1, display_id = -1;
buff[0] = manager_name[0] = display_name[0] = '\0';
/* Find out the native screen resolution, which is needed to /* Find out the native screen resolution, which is needed to
* properly center the scaled image data. */ * properly center the scaled image data. */

View File

@ -332,13 +332,15 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg)
{ {
char buf[128] = {0}; char buf[128];
static struct retro_perf_counter sdl_scale = {0}; static struct retro_perf_counter sdl_scale = {0};
sdl_video_t *vid = (sdl_video_t*)data; sdl_video_t *vid = (sdl_video_t*)data;
if (!frame) if (!frame)
return true; return true;
buf[0] = '\0';
if (SDL_MUSTLOCK(vid->screen)) if (SDL_MUSTLOCK(vid->screen))
SDL_LockSurface(vid->screen); SDL_LockSurface(vid->screen);

View File

@ -205,8 +205,11 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
if (settings->fps_show) if (settings->fps_show)
{ {
char buffer[128] = {0}; char buffer[128];
char buffer_fps[128] = {0}; char buffer_fps[128];
buffer[0] = buffer_fps[0] = '\0';
video_monitor_get_fps(buffer, sizeof(buffer), video_monitor_get_fps(buffer, sizeof(buffer),
settings->fps_show ? buffer_fps : NULL, sizeof(buffer_fps)); settings->fps_show ? buffer_fps : NULL, sizeof(buffer_fps));
runloop_msg_queue_push(buffer_fps, 1, 1, false); runloop_msg_queue_push(buffer_fps, 1, 1, false);

View File

@ -114,10 +114,11 @@ static bool gfx_ctx_cgl_set_resize(void *data, unsigned width, unsigned height)
static void gfx_ctx_cgl_update_window_title(void *data) static void gfx_ctx_cgl_update_window_title(void *data)
{ {
char buf[128] = {0}; char buf[128];
char buf_fps[128] = {0}; char buf_fps[128];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
buf[0] = buf_fps[0] = '\0';
(void)data; (void)data;
video_monitor_get_fps(buf, sizeof(buf), video_monitor_get_fps(buf, sizeof(buf),

View File

@ -87,11 +87,13 @@ static void gfx_ctx_d3d_swap_buffers(void *data)
static void gfx_ctx_d3d_update_title(void *data) static void gfx_ctx_d3d_update_title(void *data)
{ {
char buf[128] = {0}; char buf[128];
char buffer_fps[128] = {0}; char buffer_fps[128];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
const ui_window_t *window = ui_companion_driver_get_window_ptr(); const ui_window_t *window = ui_companion_driver_get_window_ptr();
buf[0] = buffer_fps[0] = '\0';
if (window && video_monitor_get_fps(buf, sizeof(buf), if (window && video_monitor_get_fps(buf, sizeof(buf),
buffer_fps, sizeof(buffer_fps))) buffer_fps, sizeof(buffer_fps)))
{ {
@ -104,7 +106,9 @@ static void gfx_ctx_d3d_update_title(void *data)
{ {
#ifdef _XBOX #ifdef _XBOX
MEMORYSTATUS stat; MEMORYSTATUS stat;
char mem[128] = {0}; char mem[128];
mem[0] = '\0';
GlobalMemoryStatus(&stat); GlobalMemoryStatus(&stat);
snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB",

View File

@ -113,10 +113,12 @@ static bool gfx_ctx_khr_display_set_resize(void *data,
static void gfx_ctx_khr_display_update_window_title(void *data) static void gfx_ctx_khr_display_update_window_title(void *data)
{ {
char buf[128] = {0}; char buf[128];
char buf_fps[128] = {0}; char buf_fps[128];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
buf[0] = buf_fps[0] = '\0';
(void)data; (void)data;
video_monitor_get_fps(buf, sizeof(buf), video_monitor_get_fps(buf, sizeof(buf),

View File

@ -144,10 +144,12 @@ static bool gfx_ctx_opendingux_set_resize(void *data,
static void gfx_ctx_opendingux_update_window_title(void *data) static void gfx_ctx_opendingux_update_window_title(void *data)
{ {
char buf[128] = {0}; char buf[128];
char buf_fps[128] = {0}; char buf_fps[128];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
buf[0] = buf_fps[0] = '\0';
video_monitor_get_fps(buf, sizeof(buf), video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps)); buf_fps, sizeof(buf_fps));
if (settings->fps_show) if (settings->fps_show)

View File

@ -200,10 +200,12 @@ static bool gfx_ctx_ps3_set_resize(void *data,
static void gfx_ctx_ps3_update_window_title(void *data) static void gfx_ctx_ps3_update_window_title(void *data)
{ {
char buf[128] = {0}; char buf[128];
char buf_fps[128] = {0}; char buf_fps[128];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
buf[0] = buf_fps[0] = '\0';
(void)data; (void)data;
video_monitor_get_fps(buf, sizeof(buf), video_monitor_get_fps(buf, sizeof(buf),

View File

@ -260,7 +260,9 @@ static bool hlsl_load_shader(hlsl_shader_data_t *hlsl,
void *data, const char *cgp_path, unsigned i) void *data, const char *cgp_path, unsigned i)
{ {
struct shader_program_info program_info; struct shader_program_info program_info;
char path_buf[PATH_MAX_LENGTH] = {0}; char path_buf[PATH_MAX_LENGTH];
path_buf[0] = '\0';
program_info.combined = path_buf; program_info.combined = path_buf;
program_info.is_file = true; program_info.is_file = true;

View File

@ -83,9 +83,10 @@ static void osk_update_last_codepoint(const char *word)
static void osk_update_last_char(const char c) static void osk_update_last_char(const char c)
{ {
char array[2] = {0}; char array[2];
array[0] = c; array[0] = c;
array[1] = 0;
osk_update_last_codepoint(array); osk_update_last_codepoint(array);
} }

View File

@ -101,11 +101,13 @@ bool input_remapping_save_file(const char *path)
{ {
bool ret; bool ret;
unsigned i, j; unsigned i, j;
char buf[PATH_MAX_LENGTH] = {0}; char buf[PATH_MAX_LENGTH];
char remap_file[PATH_MAX_LENGTH] = {0}; char remap_file[PATH_MAX_LENGTH];
config_file_t *conf = NULL; config_file_t *conf = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
buf[0] = remap_file[0] = '\0';
fill_pathname_join(buf, settings->directory.input_remapping, fill_pathname_join(buf, settings->directory.input_remapping,
path, sizeof(buf)); path, sizeof(buf));
@ -122,7 +124,7 @@ bool input_remapping_save_file(const char *path)
for (i = 0; i < settings->input.max_users; i++) for (i = 0; i < settings->input.max_users; i++)
{ {
char buf[64] = {0}; char buf[64];
char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128] = {{0}}; char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128] = {{0}};
char key_strings[RARCH_FIRST_CUSTOM_BIND + 4][128] = { char key_strings[RARCH_FIRST_CUSTOM_BIND + 4][128] = {
"b", "y", "select", "start", "b", "y", "select", "start",
@ -130,6 +132,8 @@ bool input_remapping_save_file(const char *path)
"a", "x", "l", "r", "l2", "r2", "a", "x", "l", "r", "l2", "r2",
"l3", "r3", "l_x", "l_y", "r_x", "r_y" }; "l3", "r3", "l_x", "l_y", "r_x", "r_y" };
buf[0] = '\0';
snprintf(buf, sizeof(buf), "input_player%u", i + 1); snprintf(buf, sizeof(buf), "input_player%u", i + 1);
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND + 4; j++) for (j = 0; j < RARCH_FIRST_CUSTOM_BIND + 4; j++)

View File

@ -33,7 +33,7 @@
struct RDIR *retro_opendir(const char *name) struct RDIR *retro_opendir(const char *name)
{ {
#if defined(_WIN32) #if defined(_WIN32)
char path_buf[1024] = {0}; char path_buf[1024];
#endif #endif
struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir)); struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
@ -41,6 +41,7 @@ struct RDIR *retro_opendir(const char *name)
return NULL; return NULL;
#if defined(_WIN32) #if defined(_WIN32)
path_buf[0] = '\0';
snprintf(path_buf, sizeof(path_buf), "%s\\*", name); snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
rdir->directory = FindFirstFile(path_buf, &rdir->entry); rdir->directory = FindFirstFile(path_buf, &rdir->entry);
#elif defined(VITA) || defined(PSP) #elif defined(VITA) || defined(PSP)

View File

@ -86,9 +86,11 @@ int string_parse_html_anchor(const char *line, char *link, char *name,
#ifndef RARCH_INTERNAL #ifndef RARCH_INTERNAL
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char link[1024];
char name[1024];
const char *line = "<a href=\"http://www.test.com/somefile.zip\">Test</a>\n"; const char *line = "<a href=\"http://www.test.com/somefile.zip\">Test</a>\n";
char link[1024] = {0};
char name[1024] = {0}; link[0] = name[0] = '\0';
string_parse_html_anchor(line, link, name, sizeof(link), sizeof(name)); string_parse_html_anchor(line, link, name, sizeof(link), sizeof(name));