Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Oct 10, 2020
1 parent cb45f08 commit 81fc3a1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 63 deletions.
10 changes: 1 addition & 9 deletions tasks/task_autodetect_blissbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,9 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type_win3
unsigned len = 0;
unsigned i = 0;
char vidPidString[32] = {0};
char vidString[5] = {0};
char pidString[5] = {0};
char report[USB_PACKET_CTRL_LEN + 1] = {0};

snprintf(vidString, sizeof(vidString), "%04x", vid);
snprintf(pidString, sizeof(pidString), "%04x", pid);

strlcat(vidPidString, "vid_", sizeof(vidPidString));
strlcat(vidPidString, vidString, sizeof(vidPidString));
strlcat(vidPidString, "&pid_", sizeof(vidPidString));
strlcat(vidPidString, pidString, sizeof(vidPidString));
snprintf(vidPidString, sizeof(vidPidString), "vid_%04x&pid_%04x", vid, pid);

HidD_GetHidGuid(&guidDeviceInterface);

Expand Down
2 changes: 1 addition & 1 deletion tasks/task_core_updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static uint32_t task_core_updater_get_core_crc(const char *core_path)
{
uint32_t crc = 0;

/* Get crc value */
/* Get CRC value */
bool success = intfstream_get_crc(core_file, &crc);

/* Close core file */
Expand Down
109 changes: 56 additions & 53 deletions tasks/task_playlist_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,22 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task)
switch (pl_manager->status)
{
case PL_MANAGER_BEGIN:
{
/* Load playlist */
if (!path_is_valid(pl_manager->playlist_config.path))
goto task_finished;

pl_manager->playlist = playlist_init(&pl_manager->playlist_config);

if (!pl_manager->playlist)
goto task_finished;

pl_manager->list_size = playlist_size(pl_manager->playlist);

if (pl_manager->list_size < 1)
goto task_finished;

/* All good - can start iterating */
pl_manager->status = PL_MANAGER_ITERATE_ENTRY_RESET_CORE;
}
/* Load playlist */
if (!path_is_valid(pl_manager->playlist_config.path))
goto task_finished;

pl_manager->playlist = playlist_init(&pl_manager->playlist_config);

if (!pl_manager->playlist)
goto task_finished;

pl_manager->list_size = playlist_size(pl_manager->playlist);

if (pl_manager->list_size < 1)
goto task_finished;

/* All good - can start iterating */
pl_manager->status = PL_MANAGER_ITERATE_ENTRY_RESET_CORE;
break;
case PL_MANAGER_ITERATE_ENTRY_RESET_CORE:
{
Expand Down Expand Up @@ -270,7 +268,8 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task)
task_set_finished(task, true);
}

static bool task_pl_manager_reset_cores_finder(retro_task_t *task, void *user_data)
static bool task_pl_manager_reset_cores_finder(
retro_task_t *task, void *user_data)
{
pl_manager_handle_t *pl_manager = NULL;

Expand All @@ -284,7 +283,8 @@ static bool task_pl_manager_reset_cores_finder(retro_task_t *task, void *user_da
if (!pl_manager)
return false;

return string_is_equal((const char*)user_data, pl_manager->playlist_config.path);
return string_is_equal((const char*)user_data,
pl_manager->playlist_config.path);
}

bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config)
Expand All @@ -293,7 +293,8 @@ bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config)
char playlist_name[PATH_MAX_LENGTH];
char task_title[PATH_MAX_LENGTH];
retro_task_t *task = task_init();
pl_manager_handle_t *pl_manager = (pl_manager_handle_t*)calloc(1, sizeof(pl_manager_handle_t));
pl_manager_handle_t *pl_manager = (pl_manager_handle_t*)
calloc(1, sizeof(pl_manager_handle_t));

playlist_name[0] = '\0';
task_title[0] = '\0';
Expand All @@ -305,7 +306,8 @@ bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config)
if (string_is_empty(playlist_config->path))
goto error;

fill_pathname_base_noext(playlist_name, playlist_config->path, sizeof(playlist_name));
fill_pathname_base_noext(playlist_name,
playlist_config->path, sizeof(playlist_name));

if (string_is_empty(playlist_name))
goto error;
Expand Down Expand Up @@ -590,21 +592,19 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task)
}
break;
case PL_MANAGER_VALIDATE_END:
/* Sanity check - if all (or all but one)
* playlist entries were removed during the
* 'validate' phase, we can stop now */
if (pl_manager->list_size < 2)
{
/* Sanity check - if all (or all but one)
* playlist entries were removed during the
* 'validate' phase, we can stop now */
if (pl_manager->list_size < 2)
{
pl_manager->status = PL_MANAGER_END;
break;
}

/* ...otherwise, reset index counter and
* start the duplicates check */
pl_manager->list_index = 0;
pl_manager->status = PL_MANAGER_ITERATE_ENTRY_CHECK_DUPLICATE;
pl_manager->status = PL_MANAGER_END;
break;
}

/* ...otherwise, reset index counter and
* start the duplicates check */
pl_manager->list_index = 0;
pl_manager->status = PL_MANAGER_ITERATE_ENTRY_CHECK_DUPLICATE;
break;
case PL_MANAGER_ITERATE_ENTRY_CHECK_DUPLICATE:
{
Expand Down Expand Up @@ -659,21 +659,19 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task)
}
break;
case PL_MANAGER_CHECK_DUPLICATE_END:
/* Sanity check - if all (or all but one)
* playlist entries were removed during the
* 'check duplicate' phase, we can stop now */
if (pl_manager->list_size < 2)
{
/* Sanity check - if all (or all but one)
* playlist entries were removed during the
* 'check duplicate' phase, we can stop now */
if (pl_manager->list_size < 2)
{
pl_manager->status = PL_MANAGER_END;
break;
}

/* ...otherwise, reset index counter and
* start building the M3U file list */
pl_manager->list_index = 0;
pl_manager->status = PL_MANAGER_ITERATE_FETCH_M3U;
pl_manager->status = PL_MANAGER_END;
break;
}

/* ...otherwise, reset index counter and
* start building the M3U file list */
pl_manager->list_index = 0;
pl_manager->status = PL_MANAGER_ITERATE_FETCH_M3U;
break;
case PL_MANAGER_ITERATE_FETCH_M3U:
{
Expand Down Expand Up @@ -790,7 +788,8 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task)
task_set_finished(task, true);
}

static bool task_pl_manager_clean_playlist_finder(retro_task_t *task, void *user_data)
static bool task_pl_manager_clean_playlist_finder(
retro_task_t *task, void *user_data)
{
pl_manager_handle_t *pl_manager = NULL;

Expand All @@ -804,16 +803,19 @@ static bool task_pl_manager_clean_playlist_finder(retro_task_t *task, void *user
if (!pl_manager)
return false;

return string_is_equal((const char*)user_data, pl_manager->playlist_config.path);
return string_is_equal((const char*)user_data,
pl_manager->playlist_config.path);
}

bool task_push_pl_manager_clean_playlist(const playlist_config_t *playlist_config)
bool task_push_pl_manager_clean_playlist(
const playlist_config_t *playlist_config)
{
task_finder_data_t find_data;
char playlist_name[PATH_MAX_LENGTH];
char task_title[PATH_MAX_LENGTH];
retro_task_t *task = task_init();
pl_manager_handle_t *pl_manager = (pl_manager_handle_t*)calloc(1, sizeof(pl_manager_handle_t));
pl_manager_handle_t *pl_manager = (pl_manager_handle_t*)
calloc(1, sizeof(pl_manager_handle_t));

playlist_name[0] = '\0';
task_title[0] = '\0';
Expand All @@ -825,7 +827,8 @@ bool task_push_pl_manager_clean_playlist(const playlist_config_t *playlist_confi
if (string_is_empty(playlist_config->path))
goto error;

fill_pathname_base_noext(playlist_name, playlist_config->path, sizeof(playlist_name));
fill_pathname_base_noext(playlist_name,
playlist_config->path, sizeof(playlist_name));

if (string_is_empty(playlist_name))
goto error;
Expand Down

0 comments on commit 81fc3a1

Please sign in to comment.