This commit is contained in:
twinaphex 2017-10-04 06:53:47 +02:00
parent 6bb5af8ee0
commit 8238545bef
15 changed files with 47 additions and 56 deletions

View file

@ -46,8 +46,7 @@ bool input_remapping_load_file(void *data, const char *path)
if (!conf || string_is_empty(path)) if (!conf || string_is_empty(path))
return false; return false;
if (global->name.remapfile if (!string_is_empty(global->name.remapfile))
&& !string_is_empty(global->name.remapfile))
free(global->name.remapfile); free(global->name.remapfile);
global->name.remapfile = strdup(path); global->name.remapfile = strdup(path);
@ -259,8 +258,7 @@ void input_remapping_set_defaults(bool deinit)
if (deinit) if (deinit)
{ {
if (global->name.remapfile if (!string_is_empty(global->name.remapfile))
&& !string_is_empty(global->name.remapfile))
free(global->name.remapfile); free(global->name.remapfile);
global->name.remapfile = NULL; global->name.remapfile = NULL;
rarch_ctl(RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE, NULL); rarch_ctl(RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE, NULL);

View file

@ -896,7 +896,7 @@ bool config_file_write(config_file_t *conf, const char *path)
{ {
FILE *file; FILE *file;
if (path && !string_is_empty(path)) if (!string_is_empty(path))
{ {
file = fopen(path, "w"); file = fopen(path, "w");
if (!file) if (!file)

View file

@ -206,7 +206,7 @@ void libretrodb_close(libretrodb_t *db)
{ {
if (db->fd) if (db->fd)
filestream_close(db->fd); filestream_close(db->fd);
if (db->path && !string_is_empty(db->path)) if (!string_is_empty(db->path))
free(db->path); free(db->path);
db->path = NULL; db->path = NULL;
db->fd = NULL; db->fd = NULL;
@ -222,7 +222,7 @@ int libretrodb_open(const char *path, libretrodb_t *db)
if (!fd) if (!fd)
return -errno; return -errno;
if (db->path && !string_is_empty(db->path)) if (!string_is_empty(db->path))
free(db->path); free(db->path);
db->path = strdup(path); db->path = strdup(path);
@ -428,7 +428,7 @@ void libretrodb_cursor_close(libretrodb_cursor_t *cursor)
int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor, int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor,
libretrodb_query_t *q) libretrodb_query_t *q)
{ {
if (!db || !db->path || string_is_empty(db->path)) if (!db || string_is_empty(db->path))
return -errno; return -errno;
cursor->fd = filestream_open(db->path, RFILE_MODE_READ | RFILE_HINT_MMAP, -1); cursor->fd = filestream_open(db->path, RFILE_MODE_READ | RFILE_HINT_MMAP, -1);

View file

@ -282,9 +282,9 @@ static int deferred_push_core_collection_list_deferred(
static int deferred_push_database_manager_list_deferred( static int deferred_push_database_manager_list_deferred(
menu_displaylist_info_t *info) menu_displaylist_info_t *info)
{ {
if (info->path_b && !string_is_empty(info->path_b)) if (!string_is_empty(info->path_b))
free(info->path_b); free(info->path_b);
if (info->path_c && !string_is_empty(info->path_c)) if (!string_is_empty(info->path_c))
free(info->path_c); free(info->path_c);
info->path_b = strdup(info->path); info->path_b = strdup(info->path);
@ -464,11 +464,11 @@ static int deferred_push_cursor_manager_list_deferred(
settings->paths.path_content_database, settings->paths.path_content_database,
rdb, sizeof(rdb_path)); rdb, sizeof(rdb_path));
if (info->path_b && !string_is_empty(info->path_b)) if (!string_is_empty(info->path_b))
free(info->path_b); free(info->path_b);
if (info->path_c && !string_is_empty(info->path_c)) if (!string_is_empty(info->path_c))
free(info->path_c); free(info->path_c);
if (info->path && !string_is_empty(info->path)) if (!string_is_empty(info->path))
free(info->path); free(info->path);
info->path_b = strdup(info->path); info->path_b = strdup(info->path);
@ -505,11 +505,11 @@ static int deferred_push_cursor_manager_list_generic(
if (string_is_empty(query)) if (string_is_empty(query))
goto end; goto end;
if (info->path_b && !string_is_empty(info->path_b)) if (!string_is_empty(info->path_b))
free(info->path_b); free(info->path_b);
if (info->path_c && !string_is_empty(info->path_c)) if (!string_is_empty(info->path_c))
free(info->path_c); free(info->path_c);
if (info->path && !string_is_empty(info->path)) if (!string_is_empty(info->path))
free(info->path); free(info->path);
info->path = strdup(str_list->elems[1].data); info->path = strdup(str_list->elems[1].data);
@ -637,11 +637,11 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch(
if (string_is_empty(query)) if (string_is_empty(query))
goto end; goto end;
if (info->path && !string_is_empty(info->path)) if (!string_is_empty(info->path))
free(info->path); free(info->path);
if (info->path_b && !string_is_empty(info->path_b)) if (!string_is_empty(info->path_b))
free(info->path_b); free(info->path_b);
if (info->path_c && !string_is_empty(info->path_c)) if (!string_is_empty(info->path_c))
free(info->path_c); free(info->path_c);
info->path = strdup(str_list->elems[1].data); info->path = strdup(str_list->elems[1].data);
info->path_b = strdup(str_list->elems[0].data); info->path_b = strdup(str_list->elems[0].data);
@ -689,9 +689,9 @@ static int general_push(menu_displaylist_info_t *info,
fill_pathname_join(tmp_str2, menu->scratch2_buf, fill_pathname_join(tmp_str2, menu->scratch2_buf,
menu->scratch_buf, sizeof(tmp_str2)); menu->scratch_buf, sizeof(tmp_str2));
if (info->path && !string_is_empty(info->path)) if (!string_is_empty(info->path))
free(info->path); free(info->path);
if (info->label && !string_is_empty(info->label)) if (!string_is_empty(info->label))
free(info->label); free(info->label);
info->path = strdup(tmp_str); info->path = strdup(tmp_str);
@ -761,7 +761,7 @@ static int general_push(menu_displaylist_info_t *info,
if (!new_exts) if (!new_exts)
new_exts = info->exts; new_exts = info->exts;
if (new_exts && !string_is_empty(new_exts)) if (!string_is_empty(new_exts))
{ {
union string_list_elem_attr attr; union string_list_elem_attr attr;
size_t path_size = PATH_MAX_LENGTH * sizeof(char); size_t path_size = PATH_MAX_LENGTH * sizeof(char);
@ -886,7 +886,7 @@ static int general_push(menu_displaylist_info_t *info,
if (!string_is_empty(newstring2)) if (!string_is_empty(newstring2))
{ {
if (info->exts && !string_is_empty(info->exts)) if (!string_is_empty(info->exts))
free(info->exts); free(info->exts);
info->exts = strdup(newstring2); info->exts = strdup(newstring2);
} }

View file

@ -107,8 +107,7 @@ static void menu_action_setting_disp_set_label_remap_file_load(
*w = 19; *w = 19;
strlcpy(s2, path, len2); strlcpy(s2, path, len2);
if (global && global->name.remapfile if (global && !string_is_empty(global->name.remapfile))
&& !string_is_empty(global->name.remapfile))
fill_pathname_base(s, global->name.remapfile, fill_pathname_base(s, global->name.remapfile,
len); len);
} }
@ -622,7 +621,7 @@ static void menu_action_setting_disp_set_label_menu_more(
{ {
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MORE), len); strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MORE), len);
*w = 19; *w = 19;
if (path && !string_is_empty(path)) if (!string_is_empty(path))
strlcpy(s2, path, len2); strlcpy(s2, path, len2);
} }
@ -637,7 +636,7 @@ static void menu_action_setting_disp_set_label_db_entry(
{ {
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MORE), len); strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MORE), len);
*w = 10; *w = 10;
if (path && !string_is_empty(path)) if (!string_is_empty(path))
strlcpy(s2, path, len2); strlcpy(s2, path, len2);
} }

View file

@ -1384,16 +1384,16 @@ static int action_ok_file_load(const char *path,
file_list_get_last(menu_stack, &menu_path, &menu_label, NULL, NULL); file_list_get_last(menu_stack, &menu_path, &menu_label, NULL, NULL);
if (menu_label && !string_is_empty(menu_label)) if (!string_is_empty(menu_label))
setting = menu_setting_find(menu_label); setting = menu_setting_find(menu_label);
if (setting_get_type(setting) == ST_PATH) if (setting_get_type(setting) == ST_PATH)
return action_ok_set_path(path, label, type, idx, entry_idx); return action_ok_set_path(path, label, type, idx, entry_idx);
if (menu_path && !string_is_empty(menu_path)) if (!string_is_empty(menu_path))
strlcpy(menu_path_new, menu_path, sizeof(menu_path_new)); strlcpy(menu_path_new, menu_path, sizeof(menu_path_new));
if (menu_label && !string_is_empty(menu_label)) if (!string_is_empty(menu_label))
{ {
if ( if (
string_is_equal(menu_label, string_is_equal(menu_label,
@ -2424,7 +2424,7 @@ static int action_ok_file_load_ffmpeg(const char *path,
content_info.args = NULL; content_info.args = NULL;
content_info.environ_get = NULL; content_info.environ_get = NULL;
if (menu_path && !string_is_empty(menu_path)) if (!string_is_empty(menu_path))
fill_pathname_join(new_path, menu_path, path, fill_pathname_join(new_path, menu_path, path,
sizeof(new_path)); sizeof(new_path));
@ -2486,7 +2486,7 @@ static int action_ok_file_load_imageviewer(const char *path,
content_info.args = NULL; content_info.args = NULL;
content_info.environ_get = NULL; content_info.environ_get = NULL;
if (menu_path && !string_is_empty(menu_path)) if (!string_is_empty(menu_path))
fill_pathname_join(fullpath, menu_path, path, fill_pathname_join(fullpath, menu_path, path,
sizeof(fullpath)); sizeof(fullpath));
@ -3645,9 +3645,7 @@ static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const cha
if (!strstr(data->data, file_path_str(FILE_PATH_NETPLAY_ROOM_LIST_URL))) if (!strstr(data->data, file_path_str(FILE_PATH_NETPLAY_ROOM_LIST_URL)))
{ {
if (string_is_empty(data->data)) if (string_is_empty(data->data))
{
netplay_room_count = 0; netplay_room_count = 0;
}
else else
{ {
char s[PATH_MAX_LENGTH]; char s[PATH_MAX_LENGTH];

View file

@ -41,7 +41,7 @@ static void sanitize_to_string(char *s, const char *label, size_t len)
new_label[0] = '\0'; new_label[0] = '\0';
if (label && !string_is_empty(label)) if (!string_is_empty(label))
strlcpy(new_label, label, sizeof(new_label)); strlcpy(new_label, label, sizeof(new_label));
if (s && !string_is_empty(new_label)) if (s && !string_is_empty(new_label))
{ {
@ -52,9 +52,7 @@ static void sanitize_to_string(char *s, const char *label, size_t len)
static int fill_title(char *s, const char *title, const char *path, size_t len) static int fill_title(char *s, const char *title, const char *path, size_t len)
{ {
if ( (path && !string_is_empty(path)) if (!string_is_empty(path) && !string_is_empty(title))
&&
(title && !string_is_empty(title)))
fill_pathname_join_delim(s, title, path, ' ', len); fill_pathname_join_delim(s, title, path, ' ', len);
return 0; return 0;
} }

View file

@ -603,7 +603,7 @@ static void xui_render(void *data, bool is_idle)
xui_set_list_text(i, msg_left, msg_right); xui_set_list_text(i, msg_left, msg_right);
menu_entry_free(&entry); menu_entry_free(&entry);
if (entry_path && !string_is_empty(entry_path)) if (!string_is_empty(entry_path))
free(entry_path); free(entry_path);
} }

View file

@ -534,7 +534,7 @@ static int zarch_zui_render_lay_root_recent(
if (menu_entry_action(&entry, i, MENU_ACTION_OK)) if (menu_entry_action(&entry, i, MENU_ACTION_OK))
{ {
menu_entry_free(&entry); menu_entry_free(&entry);
if (rich_label && !string_is_empty(rich_label)) if (!string_is_empty(rich_label))
free(rich_label); free(rich_label);
return 1; return 1;
} }
@ -542,7 +542,7 @@ static int zarch_zui_render_lay_root_recent(
j++; j++;
menu_entry_free(&entry); menu_entry_free(&entry);
if (rich_label && !string_is_empty(rich_label)) if (!string_is_empty(rich_label))
free(rich_label); free(rich_label);
} }

View file

@ -384,7 +384,7 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
if (!string_is_empty(newpath)) if (!string_is_empty(newpath))
entry->path = strdup(newpath); entry->path = strdup(newpath);
if (entry_label && !string_is_empty(entry_label)) if (!string_is_empty(entry_label))
entry->label = strdup(entry_label); entry->label = strdup(entry_label);
} }

View file

@ -64,7 +64,7 @@ void filebrowser_parse(void *data, unsigned type_data)
enum menu_displaylist_ctl_state type = (enum menu_displaylist_ctl_state) enum menu_displaylist_ctl_state type = (enum menu_displaylist_ctl_state)
type_data; type_data;
const char *path = info ? info->path : NULL; const char *path = info ? info->path : NULL;
bool path_is_compressed = (path && !string_is_empty(path)) bool path_is_compressed = !string_is_empty(path)
? path_is_compressed_file(path) : false; ? path_is_compressed_file(path) : false;
bool filter_ext = bool filter_ext =
settings->bools.menu_navigation_browser_filter_supported_extensions_enable; settings->bools.menu_navigation_browser_filter_supported_extensions_enable;

View file

@ -72,8 +72,7 @@ void path_set_redirect(void)
new_savefile_dir[0] = new_savestate_dir[0] = '\0'; new_savefile_dir[0] = new_savestate_dir[0] = '\0';
if (info && info->info.library_name && if (info && !string_is_empty(info->info.library_name))
!string_is_empty(info->info.library_name))
library_name_hash = library_name_hash =
msg_hash_calculate(info->info.library_name); msg_hash_calculate(info->info.library_name);

View file

@ -325,8 +325,7 @@ static void global_free(void)
dir_clear_all(); dir_clear_all();
if (global) if (global)
{ {
if (global->name.remapfile if (!string_is_empty(global->name.remapfile))
&& !string_is_empty(global->name.remapfile))
free(global->name.remapfile); free(global->name.remapfile);
} }
memset(global, 0, sizeof(struct global)); memset(global, 0, sizeof(struct global));

View file

@ -133,12 +133,12 @@ static void RunActionSheet(const char* title, const struct string_list* items,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(buffer)); sizeof(buffer));
if (label && !string_is_empty(label)) if (!string_is_empty(label))
result.textLabel.text = BOXSTRING(label); result.textLabel.text = BOXSTRING(label);
result.detailTextLabel.text = BOXSTRING(buffer); result.detailTextLabel.text = BOXSTRING(buffer);
menu_entry_free(&entry); menu_entry_free(&entry);
if (label && !string_is_empty(label)) if (!string_is_empty(label))
free(label); free(label);
return result; return result;
@ -177,7 +177,7 @@ static void RunActionSheet(const char* title, const struct string_list* items,
label = menu_entry_get_path(&entry); label = menu_entry_get_path(&entry);
if (label && !string_is_empty(label)) if (!string_is_empty(label))
result.textLabel.text = BOXSTRING(label); result.textLabel.text = BOXSTRING(label);
[(id)result.accessoryView removeTarget:nil [(id)result.accessoryView removeTarget:nil
@ -188,7 +188,7 @@ static void RunActionSheet(const char* title, const struct string_list* items,
forControlEvents:UIControlEventValueChanged]; forControlEvents:UIControlEventValueChanged];
[(id)result.accessoryView setOn:(menu_entry_get_bool_value(self.i))]; [(id)result.accessoryView setOn:(menu_entry_get_bool_value(self.i))];
menu_entry_free(&entry); menu_entry_free(&entry);
if (label && !string_is_empty(label)) if (!string_is_empty(label))
free(label); free(label);
return result; return result;
} }
@ -234,7 +234,7 @@ static void RunActionSheet(const char* title, const struct string_list* items,
label = menu_entry_get_path(&entry); label = menu_entry_get_path(&entry);
items = menu_entry_enum_values(self.i); items = menu_entry_enum_values(self.i);
if (label && !string_is_empty(label)) if (!string_is_empty(label))
{ {
RunActionSheet(label, items, self.parentTable, RunActionSheet(label, items, self.parentTable,
^(UIActionSheet* actionSheet, NSInteger buttonIndex) ^(UIActionSheet* actionSheet, NSInteger buttonIndex)
@ -249,7 +249,7 @@ static void RunActionSheet(const char* title, const struct string_list* items,
} }
string_list_free(items); string_list_free(items);
menu_entry_free(&entry); menu_entry_free(&entry);
if (label && !string_is_empty(label)) if (!string_is_empty(label))
free(label); free(label);
} }
@end @end
@ -291,7 +291,7 @@ static void RunActionSheet(const char* title, const struct string_list* items,
userInfo:nil userInfo:nil
repeats:YES]; repeats:YES];
menu_entry_free(&entry); menu_entry_free(&entry);
if (label && !string_is_empty(label)) if (!string_is_empty(label))
free(label); free(label);
} }
@ -476,7 +476,7 @@ replacementString:(NSString *)string
menu_entry_free(&entry); menu_entry_free(&entry);
if (label && !string_is_empty(label)) if (!string_is_empty(label))
free(label); free(label);
[alertView show]; [alertView show];

View file

@ -30,7 +30,7 @@ static bool ui_browser_window_cocoa_open(ui_browser_window_state_t *state)
NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel]; NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel];
NSArray *filetypes = NULL; NSArray *filetypes = NULL;
if (state->filters && !string_is_empty(state->filters)) if (!string_is_empty(state->filters))
filetypes = [[NSArray alloc] initWithObjects:BOXSTRING(state->filters), BOXSTRING(state->filters_title), nil]; filetypes = [[NSArray alloc] initWithObjects:BOXSTRING(state->filters), BOXSTRING(state->filters_title), nil];
[panel setAllowedFileTypes:filetypes]; [panel setAllowedFileTypes:filetypes];
#if defined(MAC_OS_X_VERSION_10_6) #if defined(MAC_OS_X_VERSION_10_6)