From 7131b969d887fc61d510b28eeb273486cdedf210 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 29 Jul 2018 19:04:53 +0200 Subject: [PATCH] (Android) Buildfixes --- command.c | 6 +++--- managers/cheat_manager.c | 4 ++-- menu/cbs/menu_cbs_ok.c | 31 ++++++++++++++++++------------- menu/cbs/menu_cbs_right.c | 6 ++++-- menu/menu_setting.c | 30 ++++++------------------------ 5 files changed, 33 insertions(+), 44 deletions(-) diff --git a/command.c b/command.c index 105e7d761e..46a3e51a9c 100644 --- a/command.c +++ b/command.c @@ -198,8 +198,7 @@ static struct sockaddr_storage lastcmd_net_source; static socklen_t lastcmd_net_source_len; #endif -#ifdef HAVE_CHEEVOS -#if defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING) +#if defined(HAVE_CHEEVOS) && (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING)) static bool command_reply(const char * data, size_t len) { switch (lastcmd_source) @@ -226,7 +225,6 @@ static bool command_reply(const char * data, size_t len) return false; } #endif -#endif bool command_set_shader(const char *arg) { @@ -254,7 +252,9 @@ static bool command_version(const char* arg) char reply[256] = {0}; sprintf(reply, "%s\n", PACKAGE_VERSION); +#if defined(HAVE_CHEEVOS) && (defined(HAVE_STDIN_CMD) || defined(HAVE_NETWORK_CMD) && defined(HAVE_NETWORKING)) command_reply(reply, strlen(reply)); +#endif return true; } diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index bfe544e5dc..fb4d0de824 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -1317,8 +1317,8 @@ void cheat_manager_match_action(enum cheat_match_action_type match_action, unsig unsigned char *prev = cheat_manager_state.prev_memory_buf ; unsigned int curr_match_idx = 0; - if ( target_match_idx < 0 || target_match_idx > cheat_manager_state.num_matches-1) - return ; + if ( target_match_idx > cheat_manager_state.num_matches-1) + return; cheat_manager_setup_search_meta(cheat_manager_state.search_bit_size, &bytes_per_item, &mask, &bits); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index ad7957c2d0..6cce7b8028 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2674,13 +2674,14 @@ static int action_ok_cheat_add_top(const char *path, for (i = cheat_manager_state.size-2 ; i >=0 ; i--) { - memcpy(&cheat_manager_state.cheats[i+1], &cheat_manager_state.cheats[i], sizeof(struct item_cheat )) ; + memcpy(&cheat_manager_state.cheats[i+1], + &cheat_manager_state.cheats[i], sizeof(struct item_cheat )) ; cheat_manager_state.cheats[i+1].idx++ ; } memcpy(&cheat_manager_state.cheats[0], &tmp, sizeof(struct item_cheat )) ; - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_ADD_TOP_SUCCESS)) ; + strlcpy(msg, msg_hash_to_str(MSG_CHEAT_ADD_TOP_SUCCESS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true); @@ -2691,15 +2692,17 @@ static int action_ok_cheat_add_top(const char *path, static int action_ok_cheat_add_bottom(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - char msg[256] ; + char msg[256]; bool refresh = false ; - unsigned int new_size = cheat_manager_get_size() + 1; + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); cheat_manager_realloc(new_size, CHEAT_HANDLER_TYPE_RETRO); - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_ADD_BOTTOM_SUCCESS)) ; + msg[0] = '\0'; + strlcpy(msg, + msg_hash_to_str(MSG_CHEAT_ADD_BOTTOM_SUCCESS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true); @@ -2711,7 +2714,7 @@ static int action_ok_cheat_delete_all(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { char msg[256] ; - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_DELETE_ALL_INSTRUCTIONS)) ; + strlcpy(msg, msg_hash_to_str(MSG_CHEAT_DELETE_ALL_INSTRUCTIONS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 240, true); @@ -2743,7 +2746,7 @@ static int action_ok_cheat_add_new_after(const char *path, menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_ADD_AFTER_SUCCESS)) ; + strlcpy(msg, msg_hash_to_str(MSG_CHEAT_ADD_AFTER_SUCCESS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true); @@ -2771,13 +2774,15 @@ static int action_ok_cheat_add_new_before(const char *path, cheat_manager_state.cheats[i+1].idx++ ; } - memcpy(&cheat_manager_state.cheats[tmp.idx], &tmp, sizeof(struct item_cheat )) ; - memcpy(&cheat_manager_state.working_cheat, &tmp, sizeof(struct item_cheat )) ; + memcpy(&cheat_manager_state.cheats[tmp.idx], + &tmp, sizeof(struct item_cheat )) ; + memcpy(&cheat_manager_state.working_cheat, + &tmp, sizeof(struct item_cheat )) ; menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_ADD_BEFORE_SUCCESS)) ; + strlcpy(msg, msg_hash_to_str(MSG_CHEAT_ADD_BEFORE_SUCCESS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true); @@ -2810,7 +2815,7 @@ static int action_ok_cheat_copy_before(const char *path, menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_COPY_BEFORE_SUCCESS)) ; + strlcpy(msg, msg_hash_to_str(MSG_CHEAT_COPY_BEFORE_SUCCESS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true); @@ -2844,7 +2849,7 @@ static int action_ok_cheat_copy_after(const char *path, menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_COPY_AFTER_SUCCESS)) ; + strlcpy(msg, msg_hash_to_str(MSG_CHEAT_COPY_AFTER_SUCCESS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true); @@ -2872,7 +2877,7 @@ static int action_ok_cheat_delete(const char *path, cheat_manager_realloc(new_size, CHEAT_HANDLER_TYPE_RETRO); - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_DELETE_SUCCESS)) ; + strlcpy(msg, msg_hash_to_str(MSG_CHEAT_DELETE_SUCCESS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true); diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 2bf06e79b3..47c168775e 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -276,16 +276,18 @@ static int action_right_cheat_delete_all(unsigned type, const char *label, bool wraparound) { bool refresh = false ; - char msg[256] ; + char msg[256]; if ( ++cheat_manager_state.delete_state >= 5 ) { + msg[0] = '\0'; cheat_manager_state.delete_state = 0 ; cheat_manager_realloc(0, CHEAT_HANDLER_TYPE_EMU) ; menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); - snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEAT_DELETE_ALL_SUCCESS)) ; + strlcpy(msg, + msg_hash_to_str(MSG_CHEAT_DELETE_ALL_SUCCESS), sizeof(msg)); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 1, 180, true); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 73560174f2..20730ce7ba 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -443,10 +443,8 @@ static void setting_get_string_representation_uint_cheat_exact(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_EXACT_VAL), *setting->value.target.unsigned_integer, *setting->value.target.unsigned_integer); - } } static void setting_get_string_representation_uint_cheat_lt(void *data, @@ -454,9 +452,7 @@ static void setting_get_string_representation_uint_cheat_lt(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { - snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_LT_VAL)); - } + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_LT_VAL), len); } static void setting_get_string_representation_uint_cheat_gt(void *data, @@ -464,9 +460,7 @@ static void setting_get_string_representation_uint_cheat_gt(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { - snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_GT_VAL)); - } + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_GT_VAL), len); } static void setting_get_string_representation_uint_cheat_lte(void *data, @@ -474,9 +468,7 @@ static void setting_get_string_representation_uint_cheat_lte(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { - snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_LTE_VAL)); - } + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_LTE_VAL), len); } static void setting_get_string_representation_uint_cheat_gte(void *data, @@ -484,9 +476,7 @@ static void setting_get_string_representation_uint_cheat_gte(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { - snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_GTE_VAL)); - } + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_GTE_VAL), len); } static void setting_get_string_representation_uint_cheat_eq(void *data, @@ -494,9 +484,7 @@ static void setting_get_string_representation_uint_cheat_eq(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { - snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_EQ_VAL)); - } + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_EQ_VAL), len); } static void setting_get_string_representation_uint_cheat_neq(void *data, @@ -504,9 +492,7 @@ static void setting_get_string_representation_uint_cheat_neq(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { - snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_NEQ_VAL)); - } + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_NEQ_VAL), len); } static void setting_get_string_representation_uint_cheat_eqplus(void *data, @@ -514,10 +500,8 @@ static void setting_get_string_representation_uint_cheat_eqplus(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_EQPLUS_VAL), *setting->value.target.unsigned_integer, *setting->value.target.unsigned_integer); - } } static void setting_get_string_representation_uint_cheat_eqminus(void *data, @@ -525,10 +509,8 @@ static void setting_get_string_representation_uint_cheat_eqminus(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; if (setting) - { snprintf(s, len, msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_SEARCH_EQMINUS_VAL), *setting->value.target.unsigned_integer, *setting->value.target.unsigned_integer); - } } static void setting_get_string_representation_uint_video_rotation(void *data,