Buildfixes and more static code analysis warning fixes

This commit is contained in:
twinaphex 2019-01-10 22:24:43 +01:00
parent b9ff2e4de1
commit c98b2e2292
22 changed files with 134 additions and 88 deletions

View File

@ -1133,6 +1133,9 @@ static struct config_array_setting *populate_settings_array(settings_t *settings
unsigned count = 0;
struct config_array_setting *tmp = (struct config_array_setting*)calloc(1, (*size + 1) * sizeof(struct config_array_setting));
if (!tmp)
return NULL;
/* Arrays */
SETTING_ARRAY("playlist_names", settings->arrays.playlist_names, false, NULL, true);
SETTING_ARRAY("playlist_cores", settings->arrays.playlist_cores, false, NULL, true);
@ -1178,6 +1181,9 @@ static struct config_path_setting *populate_settings_path(settings_t *settings,
global_t *global = global_get_ptr();
struct config_path_setting *tmp = (struct config_path_setting*)calloc(1, (*size + 1) * sizeof(struct config_path_setting));
if (!tmp)
return NULL;
/* Paths */
#ifdef HAVE_XMB
SETTING_PATH("xmb_font", settings->paths.path_menu_xmb_font, false, NULL, true);
@ -1566,6 +1572,9 @@ static struct config_float_setting *populate_settings_float(settings_t *settings
unsigned count = 0;
struct config_float_setting *tmp = (struct config_float_setting*)calloc(1, (*size + 1) * sizeof(struct config_float_setting));
if (!tmp)
return NULL;
SETTING_FLOAT("video_aspect_ratio", &settings->floats.video_aspect_ratio, true, aspect_ratio, false);
SETTING_FLOAT("video_scale", &settings->floats.video_scale, false, 0.0f, false);
SETTING_FLOAT("crt_video_refresh_rate", &settings->floats.crt_video_refresh_rate, true, crt_refresh_rate, false);
@ -1602,6 +1611,9 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
unsigned count = 0;
struct config_uint_setting *tmp = (struct config_uint_setting*)malloc((*size + 1) * sizeof(struct config_uint_setting));
if (!tmp)
return NULL;
#ifdef HAVE_NETWORKING
SETTING_UINT("streaming_mode", &settings->uints.streaming_mode, true, STREAMING_MODE_TWITCH, false);
#endif
@ -1727,6 +1739,9 @@ static struct config_size_setting *populate_settings_size(settings_t *settings,
unsigned count = 0;
struct config_size_setting *tmp = (struct config_size_setting*)calloc((*size + 1), sizeof(struct config_size_setting));
if (!tmp)
return NULL;
SETTING_SIZE("rewind_buffer_size", &settings->sizes.rewind_buffer_size, true, rewind_buffer_size, false);
*size = count;
@ -1739,6 +1754,9 @@ static struct config_int_setting *populate_settings_int(settings_t *settings, in
unsigned count = 0;
struct config_int_setting *tmp = (struct config_int_setting*)calloc((*size + 1), sizeof(struct config_int_setting));
if (!tmp)
return NULL;
SETTING_INT("state_slot", &settings->ints.state_slot, false, 0 /* TODO */, false);
#ifdef HAVE_NETWORKING
SETTING_INT("netplay_check_frames", &settings->ints.netplay_check_frames, true, netplay_check_frames, false);
@ -2718,11 +2736,11 @@ static bool config_load_file(const char *path, bool set_defaults,
while (extra_path)
{
bool ret = config_append_file(conf, extra_path);
bool result = config_append_file(conf, extra_path);
RARCH_LOG("Config: appending config \"%s\"\n", extra_path);
if (!ret)
if (!result)
RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path);
extra_path = strtok_r(NULL, "|", &save);
}

View File

@ -201,7 +201,7 @@ static bool core_info_list_iterate(
if (!current_path)
return false;
info_path_base = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
info_path_base = (char*)malloc(info_path_base_size);
info_path_base[0] = '\0';
@ -230,17 +230,15 @@ static bool core_info_list_iterate(
static core_info_list_t *core_info_list_new(const char *path,
const char *libretro_info_dir,
const char *exts,
bool show_hidden_files)
bool dir_show_hidden_files)
{
size_t i;
core_info_t *core_info = NULL;
core_info_list_t *core_info_list = NULL;
const char *path_basedir = libretro_info_dir;
struct string_list *contents = string_list_new();
bool ok;
ok = dir_list_append(contents, path, exts,
false, show_hidden_files, false, false);
bool ok = dir_list_append(contents, path, exts,
false, dir_show_hidden_files, false, false);
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
/* UWP: browse the optional packages for additional cores */
@ -249,7 +247,7 @@ static core_info_list_t *core_info_list_new(const char *path,
for (i = 0; i < core_packages->size; i++)
{
dir_list_append(contents, core_packages->elems[i].data, exts,
false, show_hidden_files, false, false);
false, dir_show_hidden_files, false, false);
}
string_list_free(core_packages);
#else
@ -574,7 +572,11 @@ static bool core_info_list_update_missing_firmware_internal(
if (!info)
return false;
path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
path = (char*)malloc(path_size);
if (!path)
return false;
path[0] = '\0';
for (i = 0; i < info->firmware_count; i++)
@ -676,12 +678,12 @@ void core_info_deinit_list(void)
}
bool core_info_init_list(const char *path_info, const char *dir_cores,
const char *exts, bool show_hidden_files)
const char *exts, bool dir_show_hidden_files)
{
if (!(core_info_curr_list = core_info_list_new(dir_cores,
!string_is_empty(path_info) ? path_info : dir_cores,
exts,
show_hidden_files)))
dir_show_hidden_files)))
return false;
return true;
}
@ -797,13 +799,13 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
void core_info_get_name(const char *path, char *s, size_t len,
const char *path_info, const char *dir_cores,
const char *exts, bool show_hidden_files)
const char *exts, bool dir_show_hidden_files)
{
size_t i;
const char *path_basedir = !string_is_empty(path_info) ?
path_info : dir_cores;
struct string_list *contents = dir_list_new(
dir_cores, exts, false, show_hidden_files, false, false);
dir_cores, exts, false, dir_show_hidden_files, false, false);
if (!contents)
return;

View File

@ -1150,11 +1150,11 @@ bool win32_suppress_screensaver(void *data, bool enable)
{
#if _WIN32_WINNT >= 0x0601
/* Windows 7, 8, 10 codepath */
typedef HANDLE(WINAPI * PowerCreateRequestPtr)(REASON_CONTEXT *context);
typedef BOOL(WINAPI * PowerSetRequestPtr)(HANDLE PowerRequest,
POWER_REQUEST_TYPE RequestType);
PowerCreateRequestPtr powerCreateRequest;
PowerSetRequestPtr powerSetRequest;
typedef HANDLE (WINAPI * PowerCreateRequestPtr)(REASON_CONTEXT *context);
typedef BOOL (WINAPI * PowerSetRequestPtr)(HANDLE PowerRequest,
POWER_REQUEST_TYPE RequestType);
HMODULE kernel32 = GetModuleHandle("kernel32.dll");
if (kernel32)
@ -1165,25 +1165,25 @@ bool win32_suppress_screensaver(void *data, bool enable)
powerSetRequest =
(PowerSetRequestPtr)GetProcAddress(
kernel32, "PowerSetRequest");
}
if (powerCreateRequest && powerSetRequest)
{
POWER_REQUEST_CONTEXT RequestContext;
HANDLE Request;
if (powerCreateRequest && powerSetRequest)
{
POWER_REQUEST_CONTEXT RequestContext;
HANDLE Request;
RequestContext.Version =
POWER_REQUEST_CONTEXT_VERSION;
RequestContext.Flags =
POWER_REQUEST_CONTEXT_SIMPLE_STRING;
RequestContext.Reason.SimpleReasonString = (LPWSTR)
L"RetroArch running";
RequestContext.Version =
POWER_REQUEST_CONTEXT_VERSION;
RequestContext.Flags =
POWER_REQUEST_CONTEXT_SIMPLE_STRING;
RequestContext.Reason.SimpleReasonString = (LPWSTR)
L"RetroArch running";
Request =
powerCreateRequest(&RequestContext);
Request =
powerCreateRequest(&RequestContext);
powerSetRequest( Request, PowerRequestDisplayRequired);
return true;
powerSetRequest( Request, PowerRequestDisplayRequired);
return true;
}
}
#endif
}

View File

@ -1403,7 +1403,7 @@ static void video_thread_send_and_wait(thread_video_t *thr,
}
bool video_thread_font_init(const void **font_driver, void **font_handle,
void *data, const char *font_path, float font_size,
void *data, const char *font_path, float video_font_size,
enum font_driver_render_api api, custom_font_command_method_t func,
bool is_threaded)
{
@ -1419,7 +1419,7 @@ bool video_thread_font_init(const void **font_driver, void **font_handle,
pkt.data.font_init.font_handle = font_handle;
pkt.data.font_init.video_data = data;
pkt.data.font_init.font_path = font_path;
pkt.data.font_init.font_size = font_size;
pkt.data.font_init.font_size = video_font_size;
pkt.data.font_init.is_threaded = is_threaded;
pkt.data.font_init.api = api;

View File

@ -1406,7 +1406,7 @@ bool input_driver_init_command(void)
if (command_network_new(
input_driver_command,
input_stdin_cmd_enable && !grab_stdin,
network_cmd_enable,
input_network_cmd_enable,
settings->uints.network_cmd_port))
return true;

View File

@ -491,9 +491,9 @@ static INLINE bool input_joypad_pressed(
unsigned key)
{
/* Auto-binds are per joypad, not per user. */
uint64_t joykey = (binds[key].joykey != NO_BTN)
const uint64_t joykey = (binds[key].joykey != NO_BTN)
? binds[key].joykey : joypad_info.auto_binds[key].joykey;
uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE)
const uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE)
? binds[key].joyaxis : joypad_info.auto_binds[key].joyaxis;
if ((uint16_t)joykey != NO_BTN && drv->button(joypad_info.joy_idx, (uint16_t)joykey))

View File

@ -194,6 +194,7 @@ static bool nbio_stdio_iterate(void *data)
static void nbio_stdio_resize(void *data, size_t len)
{
void *new_data = NULL;
struct nbio_stdio_t *handle = (struct nbio_stdio_t*)data;
if (!handle)
return;
@ -209,10 +210,14 @@ static void nbio_stdio_resize(void *data, size_t len)
abort();
}
handle->len = len;
handle->data = realloc(handle->data, handle->len);
handle->op = -1;
handle->progress = handle->len;
handle->len = len;
handle->progress = len;
handle->op = -1;
new_data = realloc(handle->data, handle->len);
if (new_data)
handle->data = new_data;
}
static void *nbio_stdio_get_ptr(void *data, size_t* len)

View File

@ -82,6 +82,10 @@ char *string_replace_substring(const char *in,
outlen = strlen(in) - pattern_len*numhits + replacement_len*numhits;
out = (char *)malloc(outlen+1);
if (!out)
return NULL;
outat = out;
inat = in;
inprev = in;
@ -105,18 +109,17 @@ char *string_trim_whitespace_left(char *const s)
{
if(s && *s)
{
size_t len = strlen(s);
char *cur = s;
size_t len = strlen(s);
char *current = s;
while(*cur && isspace((unsigned char)*cur))
while(*current && isspace((unsigned char)*current))
{
++cur;
++current;
--len;
}
if(s != cur)
memmove(s, cur, len + 1);
if(s != current)
memmove(s, current, len + 1);
}
return s;
@ -127,16 +130,16 @@ char *string_trim_whitespace_right(char *const s)
{
if(s && *s)
{
size_t len = strlen(s);
char *cur = s + len - 1;
size_t len = strlen(s);
char *current = s + len - 1;
while(cur != s && isspace((unsigned char)*cur))
while(current != s && isspace((unsigned char)*current))
{
--cur;
--current;
--len;
}
cur[isspace((unsigned char)*cur) ? 0 : 1] = '\0';
current[isspace((unsigned char)*current) ? 0 : 1] = '\0';
}
return s;

View File

@ -2090,7 +2090,6 @@ static int materialui_list_push(void *data, void *userdata,
menu_displaylist_setting(&entry);
#else
{
settings_t *settings = config_get_ptr();
if (settings->bools.menu_show_online_updater)
{
entry.enum_idx = MENU_ENUM_LABEL_ONLINE_UPDATER;

View File

@ -1206,7 +1206,6 @@ static void rgui_render(void *data, bool is_idle)
if (rgui->mouse_show)
{
settings_t *settings = config_get_ptr();
bool cursor_visible = settings->bools.video_fullscreen ||
!video_driver_has_windowed();

View File

@ -495,9 +495,12 @@ static xmb_node_t *xmb_alloc_node(void)
{
xmb_node_t *node = (xmb_node_t*)malloc(sizeof(*node));
node->alpha = node->label_alpha = 0;
node->zoom = node->x = node->y = 0;
node->icon = node->content_icon = 0;
if (!node)
return NULL;
node->alpha = node->label_alpha = 0;
node->zoom = node->x = node->y = 0;
node->icon = node->content_icon = 0;
node->fullpath = NULL;
return node;
@ -546,6 +549,9 @@ static xmb_node_t *xmb_copy_node(const xmb_node_t *old_node)
{
xmb_node_t *new_node = (xmb_node_t*)malloc(sizeof(*new_node));
if (!new_node)
return NULL;
*new_node = *old_node;
new_node->fullpath = old_node->fullpath ? strdup(old_node->fullpath) : NULL;

View File

@ -45,14 +45,14 @@ static void* menu_display_d3d11_get_default_mvp(video_frame_info_t *video_info)
static void menu_display_d3d11_blend_begin(video_frame_info_t *video_info)
{
d3d11_video_t* d3d11 = video_info ? (d3d11_video_t*)video_info->userdata : NULL;
d3d11_video_t* d3d11 = (d3d11_video_t*)video_info->userdata;
D3D11SetBlendState(d3d11->context,
d3d11->blend_enable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
}
static void menu_display_d3d11_blend_end(video_frame_info_t *video_info)
{
d3d11_video_t* d3d11 = video_info ? (d3d11_video_t*)video_info->userdata : NULL;
d3d11_video_t* d3d11 = (d3d11_video_t*)video_info->userdata;
D3D11SetBlendState(d3d11->context,
d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK);
}

View File

@ -45,15 +45,15 @@ static void* menu_display_d3d12_get_default_mvp(video_frame_info_t *video_info)
static void menu_display_d3d12_blend_begin(video_frame_info_t *video_info)
{
d3d12_video_t* d3d12 = video_info ? (d3d12_video_t*)video_info->userdata : NULL;
d3d12_video_t* d3d12 = (d3d12_video_t*)video_info->userdata;
d3d12->sprites.pipe = d3d12->sprites.pipe_blend;
d3d12->sprites.pipe = d3d12->sprites.pipe_blend;
D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe);
}
static void menu_display_d3d12_blend_end(video_frame_info_t *video_info)
{
d3d12_video_t* d3d12 = video_info ? (d3d12_video_t*)video_info->userdata : NULL;
d3d12_video_t* d3d12 = (d3d12_video_t*)video_info->userdata;
d3d12->sprites.pipe = d3d12->sprites.pipe_noblend;
D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe);

View File

@ -137,12 +137,12 @@ static void menu_display_gdi_clear_color(
static bool menu_display_gdi_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
const char *font_path, float gdi_font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
if (!(*handle = font_driver_init_first(video_data,
font_path, font_size, true,
font_path, gdi_font_size, true,
is_threaded,
FONT_DRIVER_RENDER_GDI)))
return false;

View File

@ -349,21 +349,21 @@ static bool menu_display_vk_font_init_first(
static void menu_display_vk_scissor_begin(video_frame_info_t *video_info,
int x, int y, unsigned width, unsigned height)
{
vk_t *vk = video_info ? (vk_t*)video_info->userdata : NULL;
vk_t *vk = (vk_t*)video_info->userdata;
vk->tracker.use_scissor = true;
vk->tracker.scissor.offset.x = x;
vk->tracker.scissor.offset.y = y;
vk->tracker.scissor.extent.width = width;
vk->tracker.use_scissor = true;
vk->tracker.scissor.offset.x = x;
vk->tracker.scissor.offset.y = y;
vk->tracker.scissor.extent.width = width;
vk->tracker.scissor.extent.height = height;
vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT;
vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT;
}
static void menu_display_vk_scissor_end(video_frame_info_t *video_info)
{
vk_t *vk = video_info ? (vk_t*)video_info->userdata : NULL;
vk->tracker.use_scissor = false;
vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT;
vk_t *vk = (vk_t*)video_info->userdata;
vk->tracker.use_scissor = false;
vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT;
}
menu_display_ctx_driver_t menu_display_ctx_vulkan = {

View File

@ -451,7 +451,7 @@ void menu_display_font_free(font_data_t *font)
* to the menu driver */
font_data_t *menu_display_font(
enum application_special_type type,
float font_size,
float menu_font_size,
bool is_threaded)
{
char fontpath[PATH_MAX_LENGTH];
@ -464,10 +464,10 @@ font_data_t *menu_display_font(
fill_pathname_application_special(
fontpath, sizeof(fontpath), type);
return menu_display_font_file(fontpath, font_size, is_threaded);
return menu_display_font_file(fontpath, menu_font_size, is_threaded);
}
font_data_t *menu_display_font_file(char* fontpath, float font_size, bool is_threaded)
font_data_t *menu_display_font_file(char* fontpath, float menu_font_size, bool is_threaded)
{
font_data_t *font_data = NULL;
if (!menu_disp)
@ -475,7 +475,7 @@ font_data_t *menu_display_font_file(char* fontpath, float font_size, bool is_thr
if (!menu_disp->font_init_first((void**)&font_data,
video_driver_get_ptr(false),
fontpath, font_size, is_threaded))
fontpath, menu_font_size, is_threaded))
return NULL;
return font_data;

View File

@ -511,7 +511,6 @@ static bool playlist_read_file(
for (playlist->size = 0; playlist->size < playlist->cap; )
{
unsigned i;
struct playlist_entry *entry = NULL;
for (i = 0; i < PLAYLIST_ENTRIES; i++)
{

View File

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

View File

@ -60,9 +60,9 @@ static void *runahead_save_state_alloc(void)
return savestate;
}
static void runahead_save_state_free(void *state)
static void runahead_save_state_free(void *data)
{
retro_ctx_serialize_info_t *savestate = (retro_ctx_serialize_info_t*)state;
retro_ctx_serialize_info_t *savestate = (retro_ctx_serialize_info_t*)data;
if (!savestate)
return;
free(savestate->data);

View File

@ -52,17 +52,24 @@ void clear_controller_port_map(void);
static char *get_temp_directory_alloc(void)
{
settings_t *settings = config_get_ptr();
char *path = NULL;
char *path = NULL;
#ifdef _WIN32
#ifdef LEGACY_WIN32
DWORD pathLength = GetTempPath(0, NULL) + 1;
path = (char*)malloc(pathLength * sizeof(char));
DWORD pathLength = GetTempPath(0, NULL) + 1;
path = (char*)malloc(pathLength * sizeof(char));
path[pathLength - 1] = 0;
if (!path)
return NULL;
path[pathLength - 1] = 0;
GetTempPath(pathLength, path);
#else
DWORD pathLength = GetTempPathW(0, NULL) + 1;
wchar_t *wideStr = (wchar_t*)malloc(pathLength * sizeof(wchar_t));
if (!wideStr)
return NULL;
wideStr[pathLength - 1] = 0;
GetTempPathW(pathLength, wideStr);

View File

@ -1310,7 +1310,7 @@ bool task_push_dbscan(
const char *content_database,
const char *fullpath,
bool directory,
bool show_hidden_files,
bool db_dir_show_hidden_files,
retro_task_callback_t cb)
{
retro_task_t *t = (retro_task_t*)calloc(1, sizeof(*t));
@ -1324,7 +1324,7 @@ bool task_push_dbscan(
t->callback = cb;
t->title = strdup(msg_hash_to_str(MSG_PREPARING_FOR_CONTENT_SCAN));
db->show_hidden_files = show_hidden_files;
db->show_hidden_files = db_dir_show_hidden_files;
db->is_directory = directory;
db->playlist_directory = NULL;
db->fullpath = strdup(fullpath);

View File

@ -69,6 +69,14 @@ void task_push_get_powerstate(void)
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
powerstate_t *state = (powerstate_t*)calloc(1, sizeof(*state));
if (!task)
return;
if (!state)
{
free(task);
return;
}
task->type = TASK_TYPE_NONE;
task->state = state;
task->handler = task_powerstate_handler;