Skip to content

Commit

Permalink
Use string_is_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Jun 28, 2016
1 parent 58b9575 commit 7a745c3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
17 changes: 9 additions & 8 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ static bool command_read_ram(const char *arg)

static bool command_write_ram(const char *arg)
{
cheevos_var_t var;
uint8_t * data;
unsigned nbytes;
int i;
char reply[256];
cheevos_var_t var;
unsigned nbytes;
uint8_t * data = NULL;

cheevos_parse_guest_addr(&var, strtoul(arg, (char**)&arg, 16));
data = cheevos_get_memory(&var);
Expand Down Expand Up @@ -859,7 +859,7 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log)
msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY));
}

if (*msg)
if (!string_is_empty(msg))
{
if (error)
RARCH_ERR("%s\n", msg);
Expand Down Expand Up @@ -918,7 +918,7 @@ static void command_event_disk_control_set_index(unsigned idx)
error = true;
}

if (*msg)
if (!string_is_empty(msg))
{
if (error)
RARCH_ERR("%s\n", msg);
Expand Down Expand Up @@ -1543,11 +1543,12 @@ void command_event_save_current_config(void)
*/

/* Flush out the core specific config. */
if (*global->path.core_specific_config &&
settings->core_specific_config)
if (!string_is_empty(global->path.core_specific_config)
&& settings->core_specific_config)
ret = config_save_file(global->path.core_specific_config);
else
ret = config_save_file(global->path.config);

if (ret)
{
snprintf(msg, sizeof(msg), "Saved new config to \"%s\".",
Expand Down Expand Up @@ -2092,7 +2093,7 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_CORE_INFO_INIT:
command_event(CMD_EVENT_CORE_INFO_DEINIT, NULL);

if (*settings->directory.libretro)
if (!string_is_empty(settings->directory.libretro))
core_info_init_list();
break;
case CMD_EVENT_CORE_DEINIT:
Expand Down
10 changes: 5 additions & 5 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ static void config_set_defaults(void)
g_defaults.dir.content_history,
sizeof(settings->directory.content_history));

if (*g_defaults.path.config)
if (!string_is_empty(g_defaults.path.config))
fill_pathname_expand_special(global->path.config,
g_defaults.path.config, sizeof(global->path.config));

Expand Down Expand Up @@ -1949,7 +1949,7 @@ static void config_load_core_specific(void)
#endif

#ifdef HAVE_MENU
if (*settings->directory.menu_config)
if (!string_is_empty(settings->directory.menu_config))
{
path_resolve_realpath(settings->directory.menu_config,
sizeof(settings->directory.menu_config));
Expand Down Expand Up @@ -2277,14 +2277,14 @@ static void parse_config_file(void)
bool ret = config_load_file((*global->path.config)
? global->path.config : NULL, false);

if (*global->path.config)
if (!string_is_empty(global->path.config))
{
RARCH_LOG("Config: loading config from: %s.\n", global->path.config);
}
else
{
RARCH_LOG("Loading default config.\n");
if (*global->path.config)
if (!string_is_empty(global->path.config))
RARCH_LOG("Config: found default config: %s.\n", global->path.config);
}

Expand Down Expand Up @@ -2466,7 +2466,7 @@ void config_load(void)
global_t *global = global_get_ptr();

/* Flush out per-core configs before loading a new config. */
if (*global->path.core_specific_config &&
if (!string_is_empty(global->path.core_specific_config) &&
settings->config_save_on_exit && settings->core_specific_config)
config_save_file(global->path.core_specific_config);

Expand Down
2 changes: 1 addition & 1 deletion file_path_special.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void fill_pathname_abbreviate_special(char *out_path,

for (i = 0; candidates[i]; i++)
{
if (*candidates[i] && strstr(in_path, candidates[i]) == in_path)
if (!string_is_empty(candidates[i]) && strstr(in_path, candidates[i]) == in_path)
{
size_t src_size = strlcpy(out_path, notations[i], size);

Expand Down
2 changes: 1 addition & 1 deletion menu/cbs/menu_cbs_get_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static void menu_action_setting_disp_set_label_shader_pass(
if (!shader)
return;

if (*shader->pass[pass].source.path)
if (!string_is_empty(shader->pass[pass].source.path))
fill_pathname_base(s,
shader->pass[pass].source.path, len);
#endif
Expand Down
7 changes: 4 additions & 3 deletions menu/menu_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <compat/strl.h>
#include <retro_assert.h>
#include <file/file_path.h>
#include <string/stdstring.h>

#include "menu_driver.h"
#include "menu_shader.h"
Expand Down Expand Up @@ -48,10 +49,10 @@ void menu_shader_manager_init(menu_handle_t *menu)

if (global)
{
if (*global->path.core_specific_config
if (!string_is_empty(global->path.core_specific_config)
&& settings->core_specific_config)
config_path = global->path.core_specific_config;
else if (*global->path.config)
else if (!string_is_empty(global->path.config))
config_path = global->path.config;
}

Expand Down Expand Up @@ -288,7 +289,7 @@ void menu_shader_manager_save_preset(
strlcpy(buffer, conf_path, sizeof(buffer));
}

if (*global->path.config)
if (!string_is_empty(global->path.config))
fill_pathname_basedir(
config_directory,
global->path.config,
Expand Down
4 changes: 2 additions & 2 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,13 +1062,13 @@ static void retroarch_parse_input(int argc, char *argv[])
}
}

if (!*global->subsystem && optind < argc)
if (string_is_empty(global->subsystem) && optind < argc)
{
/* We requested explicit ROM, so use PLAIN core type. */
retroarch_set_current_core_type(CORE_TYPE_PLAIN, false);
retroarch_set_pathnames((const char*)argv[optind]);
}
else if (*global->subsystem && optind < argc)
else if (!string_is_empty(global->subsystem) && optind < argc)
{
/* We requested explicit ROM, so use PLAIN core type. */
retroarch_set_current_core_type(CORE_TYPE_PLAIN, false);
Expand Down
4 changes: 2 additions & 2 deletions tasks/task_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ static bool task_overlay_resolve_targets(struct overlay *ol,

for (i = 0; i < current->size; i++)
{
const char *next = current->descs[i].next_index_name;
ssize_t next_idx = 0;
const char *next = current->descs[i].next_index_name;

if (*next)
if (!string_is_empty(next))
{
next_idx = task_overlay_find_index(ol, next, size);

Expand Down

0 comments on commit 7a745c3

Please sign in to comment.