diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 8aebdf08b8..51386b4701 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -50,10 +50,12 @@ static void input_autoconfigure_joypad_conf(config_file_t *conf, static int input_try_autoconfigure_joypad_from_conf(config_file_t *conf, autoconfig_params_t *params, unsigned *match) { - char ident[PATH_MAX_LENGTH], ident_idx[PATH_MAX_LENGTH]; - char input_driver[PATH_MAX_LENGTH]; - int input_vid = 0, input_pid = 0; - int ret = 0; + char ident[PATH_MAX_LENGTH] = {0}; + char ident_idx[PATH_MAX_LENGTH] = {0}; + char input_driver[PATH_MAX_LENGTH] = {0}; + int input_vid = 0; + int input_pid = 0; + int ret = 0; if (!conf) return false; @@ -114,8 +116,8 @@ static void input_autoconfigure_joypad_add( config_file_t *conf, autoconfig_params_t *params) { - char msg[PATH_MAX_LENGTH]; - settings_t *settings = config_get_ptr(); + char msg[PATH_MAX_LENGTH] = {0}; + settings_t *settings = config_get_ptr(); /* This will be the case if input driver is reinitialized. * No reason to spam autoconfigure messages every time. */ @@ -261,7 +263,7 @@ const struct retro_keybind *input_get_auto_bind(unsigned port, unsigned id) void input_config_autoconfigure_disconnect(unsigned i, const char *ident) { - char msg[PATH_MAX_LENGTH]; + char msg[PATH_MAX_LENGTH] = {0}; snprintf(msg, sizeof(msg), "Device #%u (%s) disconnected.", i, ident); rarch_main_msg_queue_push(msg, 0, 60, false); RARCH_LOG("%s\n", msg); diff --git a/input/input_common.c b/input/input_common.c index 47c713d947..5b3cda9cb5 100644 --- a/input/input_common.c +++ b/input/input_common.c @@ -167,7 +167,8 @@ void input_config_parse_key(config_file_t *conf, const char *prefix, const char *btn, struct retro_keybind *bind) { - char tmp[64], key[64]; + char tmp[64] = {0}; + char key[64] = {0}; snprintf(key, sizeof(key), "%s_%s", prefix, btn); if (config_get_array(conf, key, tmp, sizeof(tmp))) @@ -233,8 +234,9 @@ unsigned input_translate_str_to_bind_id(const char *str) static void parse_hat(struct retro_keybind *bind, const char *str) { - char *dir = NULL; - uint16_t hat_dir = 0, hat; + uint16_t hat; + uint16_t hat_dir = 0; + char *dir = NULL; if (!bind || !str) return; @@ -266,8 +268,10 @@ static void parse_hat(struct retro_keybind *bind, const char *str) void input_config_parse_joy_button(config_file_t *conf, const char *prefix, const char *btn, struct retro_keybind *bind) { - char tmp[64], key[64], key_label[64]; - char *tmp_a = NULL; + char tmp[64] = {0}; + char key[64] = {0}; + char key_label[64] = {0}; + char *tmp_a = NULL; snprintf(key, sizeof(key), "%s_%s_btn", prefix, btn); snprintf(key_label, sizeof(key_label), "%s_%s_btn_label", prefix, btn); @@ -293,8 +297,10 @@ void input_config_parse_joy_button(config_file_t *conf, const char *prefix, void input_config_parse_joy_axis(config_file_t *conf, const char *prefix, const char *axis, struct retro_keybind *bind) { - char tmp[64], key[64], key_label[64]; - char *tmp_a = NULL; + char tmp[64] = {0}; + char key[64] = {0}; + char key_label[64] = {0}; + char *tmp_a = NULL; snprintf(key, sizeof(key), "%s_%s_axis", prefix, axis); snprintf(key_label, sizeof(key_label), "%s_%s_axis_label", prefix, axis); @@ -328,7 +334,7 @@ static void input_get_bind_string_joykey(char *buf, const char *prefix, if (GET_HAT_DIR(bind->joykey)) { - const char *dir; + const char *dir = NULL; switch (GET_HAT_DIR(bind->joykey)) { @@ -367,8 +373,8 @@ static void input_get_bind_string_joykey(char *buf, const char *prefix, static void input_get_bind_string_joyaxis(char *buf, const char *prefix, const struct retro_keybind *bind, size_t size) { - unsigned axis = 0; - char dir = '\0'; + unsigned axis = 0; + char dir = '\0'; settings_t *settings = config_get_ptr(); if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE) @@ -390,7 +396,8 @@ static void input_get_bind_string_joyaxis(char *buf, const char *prefix, void input_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size) { - char key[64], keybuf[64]; + char key[64] = {0}; + char keybuf[64] = {0}; (void)key; (void)keybuf; diff --git a/input/input_hid_driver.c b/input/input_hid_driver.c index f5c9316ce3..02ec23ece2 100644 --- a/input/input_hid_driver.c +++ b/input/input_hid_driver.c @@ -77,8 +77,8 @@ const char* config_get_hid_driver_options(void) { union string_list_elem_attr attr; unsigned i; - char *options = NULL; - int options_len = 0; + char *options = NULL; + int options_len = 0; struct string_list *options_l = string_list_new(); attr.i = 0; @@ -89,6 +89,7 @@ const char* config_get_hid_driver_options(void) for (i = 0; hid_drivers[i]; i++) { const char *opt = hid_drivers[i]->ident; + options_len += strlen(opt) + 1; string_list_append(options_l, opt, attr); } diff --git a/input/input_overlay.c b/input/input_overlay.c index ac6a078aed..0333089161 100644 --- a/input/input_overlay.c +++ b/input/input_overlay.c @@ -166,15 +166,16 @@ static bool input_overlay_load_desc_image(input_overlay_t *ol, struct overlay *input_overlay, unsigned ol_idx, unsigned desc_idx) { - char overlay_desc_image_key[64], image_path[PATH_MAX_LENGTH]; - + char overlay_desc_image_key[64] = {0}; + char image_path[PATH_MAX_LENGTH] = {0}; + snprintf(overlay_desc_image_key, sizeof(overlay_desc_image_key), "overlay%u_desc%u_overlay", ol_idx, desc_idx); if (config_get_path(ol->conf, overlay_desc_image_key, image_path, sizeof(image_path))) { - char path[PATH_MAX_LENGTH]; + char path[PATH_MAX_LENGTH] = {0}; fill_pathname_resolve_relative(path, ol->overlay_path, image_path, sizeof(path)); @@ -194,15 +195,19 @@ static bool input_overlay_load_desc(input_overlay_t *ol, unsigned width, unsigned height, bool normalized, float alpha_mod, float range_mod) { - bool ret = true, by_pixel; - char overlay_desc_key[64], conf_key[64], - overlay_desc_normalized_key[64]; - char overlay[256], *save, *key; float width_mod, height_mod; - struct string_list *list = NULL; - const char *x = NULL; - const char *y = NULL; - const char *box = NULL; + bool ret = true; + bool by_pixel = false; + char overlay_desc_key[64] = {0}; + char conf_key[64] = {0}; + char overlay_desc_normalized_key[64] = {0}; + char overlay[256] = {0}; + char *save = NULL; + char *key = NULL; + struct string_list *list = NULL; + const char *x = NULL; + const char *y = NULL; + const char *box = NULL; snprintf(overlay_desc_key, sizeof(overlay_desc_key), "overlay%u_desc%u", ol_idx, desc_idx); @@ -258,7 +263,8 @@ static bool input_overlay_load_desc(input_overlay_t *ol, } else { - const char *tmp; + const char *tmp = NULL; + desc->type = OVERLAY_TYPE_BUTTONS; for (tmp = strtok_r(key, "|", &save); tmp; tmp = strtok_r(NULL, "|", &save)) { @@ -268,7 +274,8 @@ static bool input_overlay_load_desc(input_overlay_t *ol, if (desc->key_mask & (UINT64_C(1) << RARCH_OVERLAY_NEXT)) { - char overlay_target_key[64]; + char overlay_target_key[64] = {0}; + snprintf(overlay_target_key, sizeof(overlay_target_key), "overlay%u_desc%u_next_target", ol_idx, desc_idx); config_get_array(ol->conf, overlay_target_key, @@ -303,6 +310,8 @@ static bool input_overlay_load_desc(input_overlay_t *ol, desc->type == OVERLAY_TYPE_ANALOG_LEFT || desc->type == OVERLAY_TYPE_ANALOG_RIGHT) { + char overlay_analog_saturate_key[64] = {0}; + if (desc->hitbox != OVERLAY_HITBOX_RADIAL) { RARCH_ERR("[Overlay]: Analog hitbox type must be \"radial\".\n"); @@ -310,7 +319,6 @@ static bool input_overlay_load_desc(input_overlay_t *ol, goto end; } - char overlay_analog_saturate_key[64]; snprintf(overlay_analog_saturate_key, sizeof(overlay_analog_saturate_key), "overlay%u_desc%u_saturate_pct", ol_idx, desc_idx); if (!config_get_float(ol->conf, overlay_analog_saturate_key, @@ -572,10 +580,10 @@ bool input_overlay_load_overlays(input_overlay_t *ol) for (i = 0; i < ol->pos_increment; i++, ol->pos++) { - char conf_key[64]; - char overlay_full_screen_key[64]; - struct overlay *overlay = NULL; - bool to_cont = ol->pos < ol->size; + char conf_key[64] = {0}; + char overlay_full_screen_key[64] = {0}; + struct overlay *overlay = NULL; + bool to_cont = ol->pos < ol->size; if (!to_cont) { @@ -647,7 +655,7 @@ bool input_overlay_load_overlays(input_overlay_t *ol) if (overlay->config.paths.path[0] != '\0') { - char overlay_resolved_path[PATH_MAX_LENGTH]; + char overlay_resolved_path[PATH_MAX_LENGTH] = {0}; fill_pathname_resolve_relative(overlay_resolved_path, ol->overlay_path, overlay->config.paths.path, sizeof(overlay_resolved_path)); diff --git a/input/input_remapping.c b/input/input_remapping.c index 1530810525..f195d048b7 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -42,8 +42,8 @@ bool input_remapping_load_file(const char *path) for (i = 0; i < MAX_USERS; i++) { - char buf[64]; - char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128]; + char buf[64] = {0}; + char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128] = {{0}}; char key_strings[RARCH_FIRST_CUSTOM_BIND + 4][128] = { "b", "y", "select", "start", "up", "down", "left", "right", "a", "x", "l", "r", "l2", "r2", "l3", "r3", "l_x", "l_y", "r_x", "r_y" }; @@ -85,10 +85,10 @@ bool input_remapping_save_file(const char *path) { bool ret; unsigned i, j; - char buf[PATH_MAX_LENGTH]; - char remap_file[PATH_MAX_LENGTH]; - config_file_t *conf = NULL; - settings_t *settings = config_get_ptr(); + char buf[PATH_MAX_LENGTH] = {0}; + char remap_file[PATH_MAX_LENGTH] = {0}; + config_file_t *conf = NULL; + settings_t *settings = config_get_ptr(); fill_pathname_join(buf, settings->input_remapping_directory, path, sizeof(buf)); @@ -106,7 +106,7 @@ bool input_remapping_save_file(const char *path) for (i = 0; i < settings->input.max_users; i++) { - char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128]; + char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128] = {{0}}; char key_strings[RARCH_FIRST_CUSTOM_BIND + 4][128] = { "b", "y", "select", "start", "up", "down", "left", "right", "a", "x", "l", "r", "l2", "r2", "l3", "r3", "l_x", "l_y", "r_x", "r_y" }; @@ -154,9 +154,10 @@ void input_remapping_state(unsigned port, if (*idx < 2 && *id < 2) { unsigned new_id = RARCH_FIRST_CUSTOM_BIND + (*idx * 2 + *id); + new_id = settings->input.remap_ids[port][new_id]; - *idx = (new_id & 2) >> 1; - *id = new_id & 1; + *idx = (new_id & 2) >> 1; + *id = new_id & 1; } break; }