content_file_init_subsystem - cleanup

This commit is contained in:
twinaphex 2016-12-21 00:19:22 +01:00
parent 12255c9f5c
commit a2c0073678
1 changed files with 16 additions and 5 deletions

View File

@ -599,41 +599,52 @@ error:
static const struct retro_subsystem_info *content_file_init_subsystem( static const struct retro_subsystem_info *content_file_init_subsystem(
content_information_ctx_t *content_ctx, content_information_ctx_t *content_ctx,
char *error_string,
bool *ret) bool *ret)
{ {
char msg[1024];
struct string_list *subsystem = path_get_subsystem_list(); struct string_list *subsystem = path_get_subsystem_list();
const struct retro_subsystem_info *special = libretro_find_subsystem_info( const struct retro_subsystem_info *special = libretro_find_subsystem_info(
content_ctx->subsystem.data, content_ctx->subsystem.size, content_ctx->subsystem.data, content_ctx->subsystem.size,
path_get(RARCH_PATH_SUBSYSTEM)); path_get(RARCH_PATH_SUBSYSTEM));
msg[0] = '\0';
if (!special) if (!special)
{ {
RARCH_ERR( snprintf(msg, sizeof(msg),
"Failed to find subsystem \"%s\" in libretro implementation.\n", "Failed to find subsystem \"%s\" in libretro implementation.\n",
path_get(RARCH_PATH_SUBSYSTEM)); path_get(RARCH_PATH_SUBSYSTEM));
error_string = strdup(msg);
goto error; goto error;
} }
if (special->num_roms && !subsystem) if (special->num_roms && !subsystem)
{ {
RARCH_ERR("%s\n", snprintf(msg, sizeof(msg),
"%s\n",
msg_hash_to_str(MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT)); msg_hash_to_str(MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT));
error_string = strdup(msg);
goto error; goto error;
} }
else if (special->num_roms && (special->num_roms != subsystem->size)) else if (special->num_roms && (special->num_roms != subsystem->size))
{ {
RARCH_ERR("Libretro core requires %u content files for " snprintf(msg, sizeof(msg),
"Libretro core requires %u content files for "
"subsystem \"%s\", but %u content files were provided.\n", "subsystem \"%s\", but %u content files were provided.\n",
special->num_roms, special->desc, special->num_roms, special->desc,
(unsigned)subsystem->size); (unsigned)subsystem->size);
error_string = strdup(msg);
goto error; goto error;
} }
else if (!special->num_roms && subsystem && subsystem->size) else if (!special->num_roms && subsystem && subsystem->size)
{ {
RARCH_ERR("Libretro core takes no content for subsystem \"%s\", " snprintf(msg, sizeof(msg),
"Libretro core takes no content for subsystem \"%s\", "
"but %u content files were provided.\n", "but %u content files were provided.\n",
special->desc, special->desc,
(unsigned)subsystem->size); (unsigned)subsystem->size);
error_string = strdup(msg);
goto error; goto error;
} }
@ -712,7 +723,7 @@ static bool content_file_init(struct string_list *temporary_content,
bool ret = path_is_empty(RARCH_PATH_SUBSYSTEM) bool ret = path_is_empty(RARCH_PATH_SUBSYSTEM)
? true : false; ? true : false;
const struct retro_subsystem_info *special = path_is_empty(RARCH_PATH_SUBSYSTEM) const struct retro_subsystem_info *special = path_is_empty(RARCH_PATH_SUBSYSTEM)
? NULL : content_file_init_subsystem(content_ctx, &ret); ? NULL : content_file_init_subsystem(content_ctx, error_string, &ret);
if (!ret) if (!ret)
goto error; goto error;