Skip to content

Commit 1cd336a

Browse files
committed
Replace string_is_equal with memcmp
1 parent 2d9a7d6 commit 1cd336a

File tree

4 files changed

+65
-70
lines changed

4 files changed

+65
-70
lines changed

input/common/wayland_common_webos.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -253,32 +253,22 @@ static void wl_registry_handle_global_webos(void *data,
253253
wl->data_device_manager = (struct wl_data_device_manager*)wl_registry_bind(reg,
254254
id, &wl_data_device_manager_interface, MIN(version, 1));
255255
else if (string_is_equal(interface, "wl_shell"))
256-
{
257256
wl->shell = (struct wl_shell*)wl_registry_bind(reg,
258257
id, &wl_shell_interface, 1);
259-
}
260258
else if (string_is_equal(interface, "wl_webos_shell"))
261-
{
262259
wl->webos_shell = (struct wl_webos_shell*)wl_registry_bind(reg,
263260
id, &wl_webos_shell_interface, 1);
264-
}
265261
#ifdef HAVE_WEBOS_EXTRA_PROTOS
266262
else if (string_is_equal(interface, "wl_webos_foreign"))
267-
{
268263
wl->webos_foreign = (struct wl_webos_foreign*)wl_registry_bind(reg,
269264
id, &wl_webos_foreign_interface, MIN(version, 1));
270-
}
271265
else if (string_is_equal(interface, "wl_webos_surface_group_compositor"))
272-
{
273266
wl->webos_surface_group_compositor =
274267
(struct wl_webos_surface_group_compositor*)wl_registry_bind(reg,
275268
id, &wl_webos_surface_group_compositor_interface, 1);
276-
}
277269
else if (string_is_equal(interface, "wl_webos_input_manager"))
278-
{
279270
wl->webos_input_manager = (struct wl_webos_input_manager*)wl_registry_bind(reg,
280271
id, &wl_webos_input_manager_interface, 1);
281-
}
282272
#endif
283273
}
284274

@@ -672,9 +662,14 @@ bool gfx_ctx_wl_set_video_mode_common_fullscreen_webos(gfx_ctx_wayland_data_t *w
672662
#ifdef HAVE_USERLAND
673663
static bool screenSaverCallback(LSHandle* sh, LSMessage* reply, void* context)
674664
{
665+
char *resp;
675666
enum rjson_type t;
676-
rjson_t *json = NULL;
677-
const char *key = NULL, *val = NULL;
667+
HContext response_ctx;
668+
bool suspend_screensaver;
669+
settings_t *settings;
670+
rjsonwriter_t *w = NULL;
671+
rjson_t *json = NULL;
672+
const char *key = NULL, *val = NULL;
678673
const char *msg = HLunaServiceMessage(reply);
679674
size_t _len = msg ? strlen(msg) : 0;
680675
char state[32] = {0};
@@ -693,7 +688,7 @@ static bool screenSaverCallback(LSHandle* sh, LSMessage* reply, void* context)
693688
if (t == RJSON_STRING)
694689
{
695690
key = rjson_get_string(json, NULL);
696-
t = rjson_next(json);
691+
t = rjson_next(json);
697692
if (t == RJSON_STRING || t == RJSON_NUMBER)
698693
{
699694
val = rjson_get_string(json, NULL);
@@ -709,10 +704,10 @@ static bool screenSaverCallback(LSHandle* sh, LSMessage* reply, void* context)
709704
if (strcmp(state, "Active") != 0)
710705
return true;
711706

712-
settings_t *settings = config_get_ptr();
713-
bool suspend_screensaver = settings->bools.ui_suspend_screensaver_enable;
707+
settings = config_get_ptr();
708+
suspend_screensaver = settings->bools.ui_suspend_screensaver_enable;
714709

715-
rjsonwriter_t *w = rjsonwriter_open_memory();
710+
w = rjsonwriter_open_memory();
716711
rjsonwriter_raw(w, "{", 1);
717712
rjsonwriter_add_string(w, "clientName");
718713
rjsonwriter_raw(w, ":", 1);
@@ -727,10 +722,9 @@ static bool screenSaverCallback(LSHandle* sh, LSMessage* reply, void* context)
727722
rjsonwriter_add_string(w, timestamp);
728723
rjsonwriter_raw(w, "}", 1);
729724

730-
char *resp = rjsonwriter_get_memory_buffer(w, NULL);
725+
resp = rjsonwriter_get_memory_buffer(w, NULL);
731726
RARCH_DBG("[LunaRequest] responseScreenSaverRequest payload: %s\n", resp);
732727

733-
HContext response_ctx;
734728
memset(&response_ctx, 0, sizeof(response_ctx));
735729
response_ctx.multiple = false;
736730
response_ctx.pub = true;
@@ -748,6 +742,7 @@ static bool screenSaverCallback(LSHandle* sh, LSMessage* reply, void* context)
748742
bool gfx_ctx_wl_suppress_screensaver_webos(void *data, bool state)
749743
{
750744
#ifdef HAVE_USERLAND
745+
char payload[256];
751746
const char *appId = get_app_id();
752747
if (!g_screensaver_ctx)
753748
g_screensaver_ctx = (HContext*)malloc(sizeof(HContext));
@@ -766,7 +761,6 @@ bool gfx_ctx_wl_suppress_screensaver_webos(void *data, bool state)
766761
g_screensaver_ctx->userdata = client_name;
767762
}
768763

769-
char payload[256];
770764
snprintf(payload, sizeof(payload),
771765
"{\"clientName\":\"%s\",\"subscribe\":true}",
772766
(const char *)g_screensaver_ctx->userdata);
@@ -864,7 +858,7 @@ void wl_keyboard_handle_key_webos(void *data,
864858
0, 0, RETRO_DEVICE_KEYBOARD);
865859
}
866860

867-
void shutdown_webos_contexts()
861+
void shutdown_webos_contexts(void)
868862
{
869863
#ifdef HAVE_USERLAND
870864
if (g_register_ctx)

libretro-common/formats/logiqx_dat/logiqx_dat.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ bool logiqx_dat_path_is_valid(const char *path, uint64_t *file_size)
6868
if (string_is_empty(file_ext))
6969
return false;
7070

71-
if (!string_is_equal_noncase(file_ext, "dat") &&
72-
!string_is_equal_noncase(file_ext, "xml"))
71+
if ( !string_is_equal_noncase(file_ext, "dat")
72+
&& !string_is_equal_noncase(file_ext, "xml"))
7373
return false;
7474

7575
/* Ensure file exists */
@@ -128,9 +128,9 @@ logiqx_dat_t *logiqx_dat_init(const char *path)
128128
/* > Logiqx XML uses: 'datafile'
129129
* > MAME List XML uses: 'mame'
130130
* > MAME 'Software List' uses: 'softwarelist' */
131-
if (!string_is_equal(root_node->name, "datafile") &&
132-
!string_is_equal(root_node->name, "mame") &&
133-
!string_is_equal(root_node->name, "softwarelist"))
131+
if ( !string_is_equal(root_node->name, "datafile")
132+
&& !string_is_equal(root_node->name, "mame")
133+
&& !string_is_equal(root_node->name, "softwarelist"))
134134
goto error;
135135

136136
/* Get pointer to initial child node */
@@ -184,9 +184,9 @@ static bool logiqx_dat_is_game_node(rxml_node_t *node)
184184
/* > Logiqx XML uses: 'game'
185185
* > MAME List XML uses: 'machine'
186186
* > MAME 'Software List' uses: 'software' */
187-
return string_is_equal(node_name, "game") ||
188-
string_is_equal(node_name, "machine") ||
189-
string_is_equal(node_name, "software");
187+
return string_is_equal(node_name, "game")
188+
|| string_is_equal(node_name, "machine")
189+
|| string_is_equal(node_name, "software");
190190
}
191191

192192
/* Returns true if specified node is a game
@@ -197,8 +197,8 @@ static bool logiqx_dat_game_node_matches_name(
197197
{
198198
const char *node_game_name = NULL;
199199

200-
if (!logiqx_dat_is_game_node(node) ||
201-
string_is_empty(game_name))
200+
if ( !logiqx_dat_is_game_node(node)
201+
|| string_is_empty(game_name))
202202
return false;
203203

204204
/* Get 'name' attribute of XML node */

menu/cbs/menu_cbs_get_value.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,8 +1437,7 @@ static size_t menu_action_setting_disp_set_label_playlist_associations(file_list
14371437

14381438
core_name = playlist_get_default_core_name(playlist);
14391439

1440-
if ( !string_is_empty(core_name)
1441-
&& !string_is_equal(core_name, "DETECT"))
1440+
if (memcmp(core_name, "DETECT", 7) != 0)
14421441
return strlcpy(s, core_name, len);
14431442
return strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);
14441443
}

menu/menu_displaylist.c

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@ static int filebrowser_parse(
260260
msg_hash_to_str(MENU_ENUM_LABEL_SCAN_FILE)))
261261
filter_ext = false;
262262

263-
if ( string_is_equal(label, "database_manager_list")
263+
if ( memcmp(label, "database_manager_list", STRLEN_CONST("database_manager_list")) == 0
264264
#ifdef IOS
265-
|| string_is_equal(label, "video_filter")
266-
|| string_is_equal(label, "audio_dsp_plugin")
265+
|| memcmp(label, "video_filter", STRLEN_CONST("video_filter")) == 0
266+
|| memcmp(label, "audio_dsp_plugin", STRLEN_CONST("audio_dsp_plugin")) == 0
267267
#endif
268-
|| string_is_equal(label, "cursor_manager_list"))
268+
|| memcmp(label, "cursor_manager_list", STRLEN_CONST("cursor_manager_list")) == 0)
269269
allow_parent_directory = false;
270270

271271
if (filebrowser_type == FILEBROWSER_SELECT_FILE_SUBSYSTEM)
@@ -620,9 +620,8 @@ static int menu_displaylist_parse_core_info(
620620
if (memcmp(entry->core_path, FILE_PATH_DETECT, sizeof(FILE_PATH_DETECT)) == 0)
621621
{
622622
const char* default_core_path = playlist_get_default_core_path(playlist);
623-
624-
if ( !string_is_empty(default_core_path)
625-
&& !string_is_equal(default_core_path, FILE_PATH_DETECT))
623+
if ( default_core_path
624+
&& memcmp(default_core_path, FILE_PATH_DETECT, sizeof(FILE_PATH_DETECT)) != 0)
626625
core_path = default_core_path;
627626
}
628627
}
@@ -666,7 +665,8 @@ static int menu_displaylist_parse_core_info(
666665
info_list[0].name = core_info->core_name;
667666
info_list[1].name = core_info->display_name;
668667
info_list[2].name =
669-
(string_is_equal(runloop_st->current_library_name, core_info->core_name)
668+
(string_is_equal(runloop_st->current_library_name,
669+
core_info->core_name)
670670
&& !string_is_empty(runloop_st->current_library_version))
671671
? runloop_st->current_library_version
672672
: core_info->display_version;
@@ -2604,8 +2604,8 @@ static int menu_displaylist_parse_playlist(
26042604
* 'download thumbnails' option, we must also extend
26052605
* this to music_history and video_history */
26062606
if (
2607-
string_is_equal(path_playlist, "history")
2608-
|| string_is_equal(path_playlist, "favorites")
2607+
memcmp(path_playlist, "history", sizeof("history")) == 0
2608+
|| memcmp(path_playlist, "favorites", sizeof("favorites")) == 0
26092609
|| string_ends_with_size(path_playlist, "_history",
26102610
path_playlist_size, STRLEN_CONST("_history")))
26112611
gfx_thumbnail_set_system(menu_st->thumbnail_path_data,
@@ -2681,10 +2681,10 @@ static int menu_displaylist_parse_playlist(
26812681
if (show_inline_core_name)
26822682
{
26832683
/* Both core name and core path must be valid */
2684-
if ( !string_is_empty(entry->core_name)
2685-
&& !string_is_equal(entry->core_name, FILE_PATH_DETECT)
2686-
&& !string_is_empty(entry->core_path)
2687-
&& !string_is_equal(entry->core_path, FILE_PATH_DETECT))
2684+
if ( entry->core_name[0] != '\0'
2685+
&& memcmp(entry->core_name, FILE_PATH_DETECT, STRLEN_CONST(FILE_PATH_DETECT) + 1)
2686+
&& entry->core_path[0] != '\0'
2687+
&& memcmp(entry->core_path, FILE_PATH_DETECT, STRLEN_CONST(FILE_PATH_DETECT) + 1))
26882688
{
26892689
_len += strlcpy(
26902690
menu_entry_lbl + _len,
@@ -3357,9 +3357,10 @@ static void menu_displaylist_set_new_playlist(
33573357
if (string_ends_with_size(playlist_file_name, "_history.lpl",
33583358
strlen(playlist_file_name), STRLEN_CONST("_history.lpl")))
33593359
playlist_config.capacity = content_history_size;
3360-
else if (string_is_equal(playlist_file_name,
3361-
FILE_PATH_CONTENT_FAVORITES)
3362-
&& (content_favorites_size >= 0))
3360+
else if (memcmp(playlist_file_name,
3361+
FILE_PATH_CONTENT_FAVORITES,
3362+
strlen(FILE_PATH_CONTENT_FAVORITES) + 1) == 0
3363+
&& (content_favorites_size >= 0))
33633364
playlist_config.capacity = (unsigned)content_favorites_size;
33643365
}
33653366

@@ -3685,8 +3686,7 @@ static int menu_displaylist_parse_load_content_settings(
36853686
if (!string_is_empty(playlist_path))
36863687
playlist_file = path_basename_nocompression(playlist_path);
36873688

3688-
if ( !string_is_empty(playlist_file)
3689-
&& string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES))
3689+
if (memcmp(playlist_file, FILE_PATH_CONTENT_FAVORITES, strlen(FILE_PATH_CONTENT_FAVORITES)) == 0)
36903690
add_to_favorites_enabled = false;
36913691
}
36923692

@@ -3932,8 +3932,8 @@ static int menu_displaylist_parse_horizontal_content_actions(
39323932
{
39333933
if (!string_is_empty(menu_st->thumbnail_path_data->system))
39343934
remove_entry_enabled =
3935-
string_is_equal(menu_st->thumbnail_path_data->system, "history")
3936-
|| string_is_equal(menu_st->thumbnail_path_data->system, "favorites")
3935+
memcmp(menu_st->thumbnail_path_data->system, "history", sizeof("history")) == 0
3936+
|| memcmp(menu_st->thumbnail_path_data->system, "favorites", sizeof("favorites")) == 0
39373937
|| string_ends_with_size(menu_st->thumbnail_path_data->system, "_history",
39383938
menu_st->thumbnail_path_data->system_len, STRLEN_CONST("_history"));
39393939

@@ -3947,7 +3947,8 @@ static int menu_displaylist_parse_horizontal_content_actions(
39473947
if ( !remove_entry_enabled
39483948
&& settings->bools.quick_menu_show_information
39493949
&& !string_is_empty(playlist_file))
3950-
remove_entry_enabled = string_is_equal(playlist_file, FILE_PATH_CONTENT_HISTORY)
3950+
remove_entry_enabled =
3951+
string_is_equal(playlist_file, FILE_PATH_CONTENT_HISTORY)
39513952
|| string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES);
39523953
}
39533954
break;
@@ -4149,7 +4150,7 @@ static unsigned menu_displaylist_parse_information_list(file_list_t *info_list)
41494150

41504151
if ( !settings->bools.menu_content_show_settings
41514152
&& !settings->bools.kiosk_mode_enable
4152-
&& !( string_is_equal(menu_ident, "glui")
4153+
&& !(string_is_equal(menu_ident, "glui")
41534154
&& settings->bools.menu_materialui_show_nav_bar)
41544155
&& !string_is_empty(settings->paths.menu_content_show_settings_password))
41554156
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(
@@ -4977,7 +4978,7 @@ static unsigned menu_displaylist_parse_content_information(
49774978
unsigned count = 0;
49784979
bool content_loaded = !retroarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)
49794980
&& !string_is_empty(loaded_content_path)
4980-
&& string_is_equal(menu->deferred_path, loaded_content_path);
4981+
&& string_is_equal(menu->deferred_path, loaded_content_path);
49814982
bool core_supports_no_game = false;
49824983

49834984
core_name[0] = '\0';
@@ -5850,7 +5851,7 @@ static int menu_displaylist_parse_input_select_physical_keyboard_list(
58505851
bool keyboard_added = false;
58515852
input_driver_state_t *st = input_state_get_ptr();
58525853
input_driver_t *current_input = st->current_driver;
5853-
bool is_android_driver = string_is_equal(current_input->ident, "android");
5854+
bool is_android_driver = (memcmp(current_input->ident, "android", 8) == 0);
58545855

58555856
device_lbl[0] = '\0';
58565857

@@ -7288,9 +7289,9 @@ unsigned menu_displaylist_build_list(
72887289
count++;
72897290

72907291
/* TODO/FIXME - should we dehardcode this? */
7291-
if ( string_is_equal(current_input->ident, "android")
7292-
|| (string_is_equal(current_input->ident, "cocoa")
7293-
&& string_is_equal(os_ver, "iOS")))
7292+
if ( memcmp(current_input->ident, "android", 8) == 0
7293+
|| (memcmp(current_input->ident, "cocoa", 6) == 0
7294+
&& memcmp(os_ver, "iOS", 4) == 0))
72947295
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
72957296
MENU_ENUM_LABEL_ENABLE_DEVICE_VIBRATION,
72967297
PARSE_ONLY_BOOL, false) == 0)
@@ -8626,7 +8627,8 @@ unsigned menu_displaylist_build_list(
86268627
i + 1, 0, NULL))
86278628
count++;
86288629

8629-
if (string_is_equal(current_core_name, core_info->display_name))
8630+
if (string_is_equal(current_core_name,
8631+
core_info->display_name))
86308632
{
86318633
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)list->list[i + 1].actiondata;
86328634
if (cbs)
@@ -9453,11 +9455,11 @@ unsigned menu_displaylist_build_list(
94539455
case DISPLAYLIST_RECORDING_SETTINGS_LIST:
94549456
{
94559457
unsigned streaming_mode = settings->uints.streaming_mode;
9456-
bool is_ffmpeg = string_is_equal(
9457-
settings->arrays.record_driver, "ffmpeg");
9458+
bool is_ffmpeg = (memcmp(
9459+
settings->arrays.record_driver, "ffmpeg", 6) == 0);
94589460
bool has_video = is_ffmpeg
9459-
|| string_is_equal(
9460-
settings->arrays.record_driver, "avfoundation");
9461+
|| memcmp(
9462+
settings->arrays.record_driver, "avfoundation", 13) == 0;
94619463
menu_displaylist_build_info_selective_t build_list[] = {
94629464
{MENU_ENUM_LABEL_RECORD_DRIVER, PARSE_ONLY_STRING_OPTIONS, true},
94639465
{MENU_ENUM_LABEL_VIDEO_RECORD_QUALITY, PARSE_ONLY_UINT, false},
@@ -15281,9 +15283,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
1528115283
}
1528215284

1528315285
/* Show History and Favorites in menus without sidebar/tabs */
15284-
if ( (string_is_equal(menu_ident, "rgui"))
15285-
|| (string_is_equal(menu_ident, "glui")
15286-
&& !settings->bools.menu_materialui_show_nav_bar))
15286+
if (( memcmp(menu_ident, "rgui", 4) == 0
15287+
|| memcmp(menu_ident, "glui", 4) == 0)
15288+
&& !settings->bools.menu_materialui_show_nav_bar)
1528715289
{
1528815290
if (settings->bools.menu_content_show_favorites_first)
1528915291
{
@@ -15412,9 +15414,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
1541215414
{
1541315415
if ( !settings->bools.menu_content_show_settings
1541415416
&& !settings->bools.kiosk_mode_enable
15415-
&& !( string_is_equal(menu_ident, "glui")
15417+
&& !( memcmp(menu_ident, "glui", 4) == 0
1541615418
&& settings->bools.menu_materialui_show_nav_bar)
15417-
&& !string_is_empty(settings->paths.menu_content_show_settings_password))
15419+
&& settings->paths.menu_content_show_settings_password[0] != '\0')
1541815420
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(
1541915421
info->list,
1542015422
MENU_ENUM_LABEL_XMB_MAIN_MENU_ENABLE_SETTINGS,

0 commit comments

Comments
 (0)