Solve some warnings pointed out by scan-build

This commit is contained in:
twinaphex 2016-09-25 05:55:55 +02:00
parent c790f452e7
commit 3f35e10014
8 changed files with 21 additions and 8 deletions

View File

@ -492,6 +492,7 @@ database_info_list_t *database_info_list_new(
if (!new_ptr) if (!new_ptr)
{ {
database_info_list_free(database_info_list); database_info_list_free(database_info_list);
free(database_info_list);
database_info_list = NULL; database_info_list = NULL;
goto end; goto end;
} }
@ -572,5 +573,4 @@ void database_info_list_free(database_info_list_t *database_info_list)
} }
free(database_info_list->list); free(database_info_list->list);
free(database_info_list);
} }

View File

@ -855,7 +855,6 @@ static void check_proc_acpi_sysfs_ac_adapter(const char * node, bool *have_ac)
static bool next_string(char **_ptr, char **_str) static bool next_string(char **_ptr, char **_str)
{ {
char *ptr = *_ptr; char *ptr = *_ptr;
char *str = *_str;
while (*ptr == ' ') /* skip any spaces... */ while (*ptr == ' ') /* skip any spaces... */
ptr++; ptr++;
@ -863,14 +862,12 @@ static bool next_string(char **_ptr, char **_str)
if (*ptr == '\0') if (*ptr == '\0')
return false; return false;
str = ptr;
while ((*ptr != ' ') && (*ptr != '\n') && (*ptr != '\0')) while ((*ptr != ' ') && (*ptr != '\n') && (*ptr != '\0'))
ptr++; ptr++;
if (*ptr != '\0') if (*ptr != '\0')
*(ptr++) = '\0'; *(ptr++) = '\0';
*_str = str;
*_ptr = ptr; *_ptr = ptr;
return true; return true;
} }

View File

@ -40,7 +40,6 @@ typedef struct linuxraw_input
static void *linuxraw_input_init(void) static void *linuxraw_input_init(void)
{ {
struct sigaction sa = {{0}};
linuxraw_input_t *linuxraw = NULL; linuxraw_input_t *linuxraw = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();

View File

@ -79,8 +79,6 @@ static void linuxraw_poll_pad(struct linuxraw_joypad *pad)
static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *pad) static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *pad)
{ {
settings_t *settings = config_get_ptr();
if (pad->fd >= 0) if (pad->fd >= 0)
return false; return false;
@ -92,8 +90,11 @@ static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
pad->fd = open(path, O_RDONLY | O_NONBLOCK); pad->fd = open(path, O_RDONLY | O_NONBLOCK);
*pad->ident = '\0'; *pad->ident = '\0';
if (pad->fd >= 0) if (pad->fd >= 0)
{ {
settings_t *settings = config_get_ptr();
if (ioctl(pad->fd, JSIOCGNAME(sizeof(settings->input.device_names[0])), pad->ident) >= 0) if (ioctl(pad->fd, JSIOCGNAME(sizeof(settings->input.device_names[0])), pad->ident) >= 0)
{ {
RARCH_LOG("[Device]: Found pad: %s on %s.\n", pad->ident, path); RARCH_LOG("[Device]: Found pad: %s on %s.\n", pad->ident, path);

View File

@ -118,7 +118,6 @@ static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad
int datadir = 1; /* read */ int datadir = 1; /* read */
bool set_control = false; bool set_control = false;
int mode = IEEE1284_MODE_BYTE; int mode = IEEE1284_MODE_BYTE;
settings_t *settings = config_get_ptr();
if (pad->fd >= 0) if (pad->fd >= 0)
return false; return false;
@ -131,6 +130,8 @@ static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad
if (pad->fd >= 0) if (pad->fd >= 0)
{ {
settings_t *settings = config_get_ptr();
RARCH_LOG("[Joypad]: Found parallel port: %s\n", path); RARCH_LOG("[Joypad]: Found parallel port: %s\n", path);
/* Parport driver does not log failures with RARCH_ERR because they could be /* Parport driver does not log failures with RARCH_ERR because they could be

View File

@ -260,6 +260,9 @@ static void retro_task_regular_retrieve(task_retriever_data_t *data)
tail = data->list; tail = data->list;
} }
} }
if (tail)
free(tail);
} }
static struct retro_task_impl impl_regular = { static struct retro_task_impl impl_regular = {

View File

@ -2002,12 +2002,16 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
playlist_free(playlist); playlist_free(playlist);
database_info_list_free(db_info); database_info_list_free(db_info);
free(db_info);
return 0; return 0;
error: error:
if (db_info) if (db_info)
{
database_info_list_free(db_info); database_info_list_free(db_info);
free(db_info);
}
playlist_free(playlist); playlist_free(playlist);
return -1; return -1;
@ -2034,6 +2038,7 @@ static int menu_database_parse_query(file_list_t *list, const char *path,
} }
database_info_list_free(db_list); database_info_list_free(db_list);
free(db_list);
#endif #endif
return 0; return 0;

View File

@ -243,7 +243,10 @@ static int database_info_list_iterate_new(database_state_handle_t *db_state,
(unsigned)db_state->list->size, new_database); (unsigned)db_state->list->size, new_database);
#endif #endif
if (db_state->info) if (db_state->info)
{
database_info_list_free(db_state->info); database_info_list_free(db_state->info);
free(db_state->info);
}
db_state->info = database_info_list_new(new_database, query); db_state->info = database_info_list_new(new_database, query);
return 0; return 0;
} }
@ -313,6 +316,7 @@ static int database_info_list_iterate_found_match(
playlist_free(playlist); playlist_free(playlist);
database_info_list_free(db_state->info); database_info_list_free(db_state->info);
free(db_state->info);
db_state->info = NULL; db_state->info = NULL;
db_state->crc = 0; db_state->crc = 0;
@ -330,6 +334,7 @@ static int database_info_list_iterate_next(
db_state->entry_index = 0; db_state->entry_index = 0;
database_info_list_free(db_state->info); database_info_list_free(db_state->info);
free(db_state->info);
db_state->info = NULL; db_state->info = NULL;
return 1; return 1;
@ -389,6 +394,7 @@ static int task_database_iterate_crc_lookup(
return 1; return 1;
database_info_list_free(db_state->info); database_info_list_free(db_state->info);
free(db_state->info);
return 0; return 0;
} }
@ -526,6 +532,7 @@ static int task_database_iterate_serial_lookup(
return 1; return 1;
database_info_list_free(db_state->info); database_info_list_free(db_state->info);
free(db_state->info);
return 0; return 0;
} }