mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
Static code analysis cleanups
This commit is contained in:
parent
790bb0d0d6
commit
02a5d738fe
@ -465,7 +465,7 @@ static int rsnd_get_backend_info ( rsound_t *rd )
|
||||
rd->backend_info.chunk_size = MAX_CHUNK_SIZE;
|
||||
|
||||
/* Assumes a default buffer size should it cause problems of being too small */
|
||||
if ( rd->buffer_size <= 0 || rd->buffer_size < rd->backend_info.chunk_size * 2 )
|
||||
if ( rd->buffer_size == 0 || rd->buffer_size < rd->backend_info.chunk_size * 2 )
|
||||
rd->buffer_size = rd->backend_info.chunk_size * 32;
|
||||
|
||||
if ( rd->fifo_buffer != NULL )
|
||||
@ -1324,11 +1324,10 @@ size_t rsd_write( rsound_t *rsound, const void* buf, size_t size)
|
||||
|
||||
while ( written < size )
|
||||
{
|
||||
size_t result;
|
||||
size_t write_size = (size - written) > max_write ? max_write : (size - written);
|
||||
result = rsnd_fill_buffer(rsound, (const char*)buf + written, write_size);
|
||||
size_t result = rsnd_fill_buffer(rsound, (const char*)buf + written, write_size);
|
||||
|
||||
if ( result <= 0 )
|
||||
if (result == 0)
|
||||
{
|
||||
rsd_stop(rsound);
|
||||
return 0;
|
||||
@ -1347,10 +1346,7 @@ int rsd_start(rsound_t *rsound)
|
||||
assert(rsound->port != NULL);
|
||||
|
||||
if ( rsnd_create_connection(rsound) < 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -658,7 +658,9 @@ int read_compressed_file(const char * path, void **buf,
|
||||
/* We split the string in two, by putting a \0, where the hash was: */
|
||||
*archive_found = '\0';
|
||||
archive_found += 1;
|
||||
#if defined(HAVE_7ZIP) || defined(HAVE_ZLIB)
|
||||
file_ext = path_get_extension(archive_path);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_7ZIP
|
||||
if (strcasecmp(file_ext,"7z") == 0)
|
||||
@ -708,7 +710,9 @@ struct string_list *compressed_file_list_new(const char *path,
|
||||
const char* ext)
|
||||
{
|
||||
#ifdef HAVE_COMPRESSION
|
||||
#if defined(HAVE_7ZIP) || defined(HAVE_ZLIB)
|
||||
const char* file_ext = path_get_extension(path);
|
||||
#endif
|
||||
#ifdef HAVE_7ZIP
|
||||
if (strcasecmp(file_ext,"7z") == 0)
|
||||
return compressed_7zip_file_list_new(path,ext);
|
||||
@ -717,7 +721,6 @@ struct string_list *compressed_file_list_new(const char *path,
|
||||
if (strcasecmp(file_ext,"zip") == 0)
|
||||
return zlib_get_file_list(path, ext);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1517,7 +1517,6 @@ static void frontend_linux_get_env(int *argc,
|
||||
{
|
||||
#ifdef ANDROID
|
||||
int32_t major, minor, rel;
|
||||
int perms = 0;
|
||||
char device_model[PROP_VALUE_MAX] = {0};
|
||||
char device_id[PROP_VALUE_MAX] = {0};
|
||||
struct rarch_main_wrap *args = NULL;
|
||||
@ -1525,7 +1524,6 @@ static void frontend_linux_get_env(int *argc,
|
||||
jobject obj = NULL;
|
||||
jstring jstr = NULL;
|
||||
struct android_app *android_app = (struct android_app*)data;
|
||||
char buf[PATH_MAX_LENGTH] = {0};
|
||||
|
||||
if (!android_app)
|
||||
return;
|
||||
@ -1749,6 +1747,7 @@ static void frontend_linux_get_env(int *argc,
|
||||
|
||||
if (android_app->getStringExtra && jstr)
|
||||
{
|
||||
int perms = 0;
|
||||
const char *argv = (*env)->GetStringUTFChars(env, jstr, 0);
|
||||
|
||||
*app_dir = '\0';
|
||||
@ -1779,6 +1778,8 @@ static void frontend_linux_get_env(int *argc,
|
||||
RARCH_LOG("Application location: [%s].\n", app_dir);
|
||||
if (args && *app_dir)
|
||||
{
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
|
||||
fill_pathname_join(g_defaults.dir.assets, app_dir,
|
||||
"assets", sizeof(g_defaults.dir.assets));
|
||||
fill_pathname_join(g_defaults.dir.extraction, app_dir,
|
||||
|
@ -116,7 +116,6 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
|
||||
unsigned int get_attributes;
|
||||
CellGameContentSize size;
|
||||
char dirName[CELL_GAME_DIRNAME_SIZE] = {0};
|
||||
char contentInfoPath[PATH_MAX_LENGTH] = {0};
|
||||
|
||||
#ifdef HAVE_MULTIMAN
|
||||
/* not launched from external launcher, set default path */
|
||||
@ -169,6 +168,8 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
|
||||
}
|
||||
else
|
||||
{
|
||||
char content_info_path[PATH_MAX_LENGTH] = {0};
|
||||
|
||||
RARCH_LOG("cellGameBootCheck() OK.\n");
|
||||
RARCH_LOG("Directory name: [%s].\n", dirName);
|
||||
RARCH_LOG(" HDD Free Size (in KB) = [%d] Size (in KB) = [%d] System Size (in KB) = [%d].\n",
|
||||
@ -188,14 +189,14 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
|
||||
== CELL_GAME_ATTRIBUTE_APP_HOME)
|
||||
RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n");
|
||||
|
||||
ret = cellGameContentPermit(contentInfoPath, g_defaults.dir.port);
|
||||
ret = cellGameContentPermit(content_info_path, g_defaults.dir.port);
|
||||
|
||||
#ifdef HAVE_MULTIMAN
|
||||
if (multiman_detected)
|
||||
{
|
||||
fill_pathname_join(contentInfoPath, "/dev_hdd0/game/",
|
||||
EMULATOR_CONTENT_DIR, sizeof(contentInfoPath));
|
||||
fill_pathname_join(g_defaults.dir.port, contentInfoPath,
|
||||
fill_pathname_join(content_info_path, "/dev_hdd0/game/",
|
||||
EMULATOR_CONTENT_DIR, sizeof(content_info_path));
|
||||
fill_pathname_join(g_defaults.dir.port, content_info_path,
|
||||
"USRDIR", sizeof(g_defaults.dir.port));
|
||||
}
|
||||
#endif
|
||||
@ -205,7 +206,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
|
||||
else
|
||||
{
|
||||
RARCH_LOG("cellGameContentPermit() OK.\n");
|
||||
RARCH_LOG("contentInfoPath : [%s].\n", contentInfoPath);
|
||||
RARCH_LOG("content_info_path : [%s].\n", content_info_path);
|
||||
RARCH_LOG("usrDirPath : [%s].\n", g_defaults.dir.port);
|
||||
}
|
||||
|
||||
@ -357,11 +358,6 @@ static int frontend_ps3_exec_exitspawn(const char *path,
|
||||
|
||||
static void frontend_ps3_exec(const char *path, bool should_load_game)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
(void)should_load_game;
|
||||
(void)ret;
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
global_t *global = global_get_ptr();
|
||||
bool original_verbose = global->verbosity;
|
||||
@ -369,6 +365,8 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
|
||||
global->verbosity = true;
|
||||
#endif
|
||||
|
||||
(void)should_load_game;
|
||||
|
||||
RARCH_LOG("Attempt to load executable: [%s].\n", path);
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
@ -382,13 +380,13 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
|
||||
NULL
|
||||
};
|
||||
|
||||
ret = frontend_ps3_exec_exitspawn(path,
|
||||
frontend_ps3_exec_exitspawn(path,
|
||||
(const char** const)spawn_argv, NULL);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret = frontend_ps3_exec_exitspawn(path,
|
||||
frontend_ps3_exec_exitspawn(path,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,6 @@ static bool font_renderer_create_atlas(ft_font_renderer_t *handle)
|
||||
/* Blit our texture atlas. */
|
||||
for (i = 0; i < FT_ATLAS_SIZE; i++)
|
||||
{
|
||||
unsigned r, c;
|
||||
uint8_t *dst = NULL;
|
||||
unsigned offset_x = (i % FT_ATLAS_COLS) * max_width;
|
||||
unsigned offset_y = (i / FT_ATLAS_COLS) * max_height;
|
||||
@ -144,6 +143,7 @@ static bool font_renderer_create_atlas(ft_font_renderer_t *handle)
|
||||
|
||||
if (buffer[i])
|
||||
{
|
||||
unsigned r, c;
|
||||
const uint8_t *src = (const uint8_t*)buffer[i];
|
||||
|
||||
for (r = 0; r < handle->glyphs[i].height;
|
||||
|
@ -310,14 +310,14 @@ static bool parport_joypad_init(void *data)
|
||||
static void parport_joypad_destroy(void)
|
||||
{
|
||||
unsigned i;
|
||||
struct parport_joypad *pad = NULL;
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
pad = (struct parport_joypad*)&parport_pads[i];
|
||||
struct parport_joypad *pad = (struct parport_joypad*)&parport_pads[i];
|
||||
if (pad->fd >= 0)
|
||||
parport_free_pad(pad);
|
||||
}
|
||||
|
||||
memset(parport_pads, 0, sizeof(parport_pads));
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
parport_pads[i].fd = -1;
|
||||
|
@ -191,7 +191,6 @@ static bool input_autoconfigure_joypad_from_conf_dir(
|
||||
config_file_t *conf = NULL;
|
||||
struct string_list *list = NULL;
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
char msg[PATH_MAX_LENGTH] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
fill_pathname_join(path,settings->input.autoconfig_dir,
|
||||
@ -231,6 +230,8 @@ static bool input_autoconfigure_joypad_from_conf_dir(
|
||||
}
|
||||
else
|
||||
{
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
|
||||
RARCH_LOG("Autodetect: no profiles found for %s (%d/%d)", params->name, params->vid, params->pid);
|
||||
snprintf(msg, sizeof(msg), "%s (%ld/%ld) not configured", params->name, (long)params->vid, (long)params->pid);
|
||||
rarch_main_msg_queue_push(msg, 0, 60, false);
|
||||
|
@ -95,7 +95,6 @@ char *dylib_error(void)
|
||||
function_t dylib_proc(dylib_t lib, const char *proc)
|
||||
{
|
||||
function_t sym;
|
||||
void *ptr_sym = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
sym = (function_t)GetProcAddress(lib ?
|
||||
@ -107,6 +106,8 @@ function_t dylib_proc(dylib_t lib, const char *proc)
|
||||
}
|
||||
last_dyn_error[0] = 0;
|
||||
#else
|
||||
void *ptr_sym = NULL;
|
||||
|
||||
if (lib)
|
||||
ptr_sym = dlsym(lib, proc);
|
||||
else
|
||||
|
@ -194,8 +194,7 @@ error:
|
||||
if (conn->urlcopy)
|
||||
free(conn->urlcopy);
|
||||
conn->urlcopy = NULL;
|
||||
if (conn)
|
||||
free(conn);
|
||||
free(conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ static int create_db(lua_State *L)
|
||||
lua_error(L);
|
||||
}
|
||||
|
||||
rv = libretrodb_create(dst, &value_provider, L);
|
||||
libretrodb_create(dst, &value_provider, L);
|
||||
retro_fclose(dst);
|
||||
|
||||
return 0;
|
||||
@ -168,8 +168,6 @@ static int db_cursor_open(lua_State *L)
|
||||
|
||||
static int db_query(lua_State *L)
|
||||
{
|
||||
int rv;
|
||||
libretrodb_cursor_t *cursor = NULL;
|
||||
libretrodb_t *db = checkdb(L);
|
||||
const char *query = luaL_checkstring(L, -1);
|
||||
const char *error = NULL;
|
||||
@ -183,7 +181,9 @@ static int db_query(lua_State *L)
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor = lua_newuserdata(L, sizeof(libretrodb_t));
|
||||
int rv;
|
||||
libretrodb_cursor_t *cursor = lua_newuserdata(L, sizeof(libretrodb_t));
|
||||
|
||||
if ((rv = libretrodb_cursor_open(db, cursor, q)) == 0)
|
||||
{
|
||||
luaL_getmetatable(L, "RarchDB.Cursor");
|
||||
@ -229,6 +229,9 @@ static int cursor_read(lua_State *L)
|
||||
static int cursor_iter(lua_State *L)
|
||||
{
|
||||
libretrodb_cursor_t *cursor = checkcursor(L);
|
||||
|
||||
(void)cursor;
|
||||
|
||||
luaL_getmetafield(L, -1, "read");
|
||||
lua_pushvalue(L, -2);
|
||||
return 2;
|
||||
|
@ -32,6 +32,9 @@ static int action_select_default(const char *path, const char *label, unsigned t
|
||||
menu_entry_get(&entry, idx, NULL, false);
|
||||
|
||||
cbs = menu_list_get_actiondata_at_offset(menu_list->selection_buf, idx);
|
||||
|
||||
if (!cbs)
|
||||
return -1;
|
||||
|
||||
switch (menu_setting_get_type(cbs->setting))
|
||||
{
|
||||
@ -55,13 +58,13 @@ static int action_select_default(const char *path, const char *label, unsigned t
|
||||
|
||||
if (action == MENU_ACTION_NOOP)
|
||||
{
|
||||
if (cbs && cbs->action_ok)
|
||||
if (cbs->action_ok)
|
||||
action = MENU_ACTION_OK;
|
||||
else
|
||||
{
|
||||
if (cbs && cbs->action_start)
|
||||
if (cbs->action_start)
|
||||
action = MENU_ACTION_START;
|
||||
if (cbs && cbs->action_right)
|
||||
if (cbs->action_right)
|
||||
action = MENU_ACTION_RIGHT;
|
||||
}
|
||||
}
|
||||
|
@ -131,17 +131,12 @@ static int action_get_title_generic(char *s, size_t len, const char *path,
|
||||
const char *text)
|
||||
{
|
||||
char elem0_path[PATH_MAX_LENGTH] = {0};
|
||||
char elem1_path[PATH_MAX_LENGTH] = {0};
|
||||
struct string_list *list_path = string_split(path, "|");
|
||||
|
||||
if (list_path)
|
||||
{
|
||||
if (list_path->size > 0)
|
||||
{
|
||||
strlcpy(elem0_path, list_path->elems[0].data, sizeof(elem0_path));
|
||||
if (list_path->size > 1)
|
||||
strlcpy(elem1_path, list_path->elems[1].data, sizeof(elem1_path));
|
||||
}
|
||||
string_list_free(list_path);
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,6 @@ static void glui_draw_scrollbar(gl_t *gl, unsigned width, unsigned height, GRflo
|
||||
{
|
||||
unsigned header_height;
|
||||
float content_height, total_height, scrollbar_height, y;
|
||||
int scrollbar_width = 4;
|
||||
glui_handle_t *glui = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
@ -144,6 +143,9 @@ static void glui_draw_scrollbar(gl_t *gl, unsigned width, unsigned height, GRflo
|
||||
y = total_height * menu->scroll_y / content_height;
|
||||
|
||||
if (content_height >= total_height)
|
||||
{
|
||||
int scrollbar_width = 4;
|
||||
|
||||
glui_render_quad(gl,
|
||||
width - scrollbar_width,
|
||||
header_height + y,
|
||||
@ -151,6 +153,7 @@ static void glui_draw_scrollbar(gl_t *gl, unsigned width, unsigned height, GRflo
|
||||
scrollbar_height,
|
||||
width, height,
|
||||
coord_color);
|
||||
}
|
||||
}
|
||||
|
||||
static void glui_get_message(const char *message)
|
||||
|
@ -77,13 +77,14 @@ static void print_buf_lines(file_list_t *list, char *buf, int buf_size,
|
||||
type, 0, 0);
|
||||
if (type == MENU_FILE_DOWNLOAD_CORE)
|
||||
{
|
||||
char core_path[PATH_MAX_LENGTH];
|
||||
char display_name[PATH_MAX_LENGTH] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (settings)
|
||||
{
|
||||
char core_path[PATH_MAX_LENGTH];
|
||||
char display_name[PATH_MAX_LENGTH] = {0};
|
||||
char *last = NULL;
|
||||
|
||||
fill_pathname_join(core_path, settings->libretro_info_path,
|
||||
line_start, sizeof(core_path));
|
||||
|
||||
@ -1549,7 +1550,7 @@ static void menu_displaylist_realloc_settings(menu_entries_t *entries, unsigned
|
||||
|
||||
static int menu_setting_set_flags(rarch_setting_t *setting)
|
||||
{
|
||||
enum setting_type setting_type = menu_setting_get_type(setting);
|
||||
enum setting_type setting_type;
|
||||
uint64_t flags = menu_setting_get_flags(setting);
|
||||
if (!setting)
|
||||
return 0;
|
||||
@ -1557,6 +1558,8 @@ static int menu_setting_set_flags(rarch_setting_t *setting)
|
||||
if (flags & SD_FLAG_IS_DRIVER)
|
||||
return MENU_SETTING_DRIVER;
|
||||
|
||||
setting_type = menu_setting_get_type(setting);
|
||||
|
||||
switch (setting_type)
|
||||
{
|
||||
case ST_ACTION:
|
||||
@ -2791,7 +2794,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type)
|
||||
core_info_list_get_supported_cores(global->core_info.list,
|
||||
menu->deferred_path, &core_info, &list_size);
|
||||
|
||||
if (list_size <= 0)
|
||||
if (list_size == 0)
|
||||
{
|
||||
menu_list_push(info->list,
|
||||
menu_hash_to_str(MENU_LABEL_VALUE_NO_CORES_AVAILABLE),
|
||||
|
@ -35,7 +35,6 @@ void menu_shader_manager_init(menu_handle_t *menu)
|
||||
{
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
uint32_t ext_hash;
|
||||
char preset_path[PATH_MAX_LENGTH];
|
||||
const char *ext = NULL;
|
||||
struct video_shader *shader = NULL;
|
||||
config_file_t *conf = NULL;
|
||||
@ -99,6 +98,7 @@ void menu_shader_manager_init(menu_handle_t *menu)
|
||||
break;
|
||||
default:
|
||||
{
|
||||
char preset_path[PATH_MAX_LENGTH];
|
||||
const char *shader_dir = *settings->video.shader_dir ?
|
||||
settings->video.shader_dir : settings->system_directory;
|
||||
|
||||
|
@ -240,13 +240,13 @@ static void ffmpeg_audio_resolve_format(struct ff_audio_info *audio,
|
||||
static void ffmpeg_audio_resolve_sample_rate(ffmpeg_t *handle,
|
||||
const AVCodec *codec)
|
||||
{
|
||||
unsigned i;
|
||||
struct ff_config_param *params = &handle->config;
|
||||
struct ffemu_params *param = &handle->params;
|
||||
|
||||
/* We'll have to force resampling to some supported sampling rate. */
|
||||
if (codec->supported_samplerates && !params->sample_rate)
|
||||
{
|
||||
unsigned i;
|
||||
int input_rate = (int)param->samplerate;
|
||||
|
||||
/* Favor closest sampling rate, but always prefer ratio > 1.0. */
|
||||
@ -280,7 +280,6 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle)
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct ff_config_param *params = &handle->config;
|
||||
struct ff_audio_info *audio = &handle->audio;
|
||||
struct ff_video_info *video = &handle->video;
|
||||
struct ffemu_params *param = &handle->params;
|
||||
AVCodec *codec = avcodec_find_encoder_by_name(
|
||||
*params->acodec ? params->acodec : "flac");
|
||||
|
@ -601,8 +601,11 @@ do_poll:
|
||||
void rarch_main_data_db_init_msg_queue(void)
|
||||
{
|
||||
db_handle_t *db = (db_handle_t*)db_ptr;
|
||||
|
||||
if (!db)
|
||||
return;
|
||||
|
||||
if (!db || !db->msg_queue)
|
||||
if (!db->msg_queue)
|
||||
rarch_assert(db->msg_queue = msg_queue_new(8));
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,13 @@ static struct magic_entry MAGIC_NUMBERS[] = {
|
||||
|
||||
static ssize_t get_token(RFILE *fd, char *token, size_t max_len)
|
||||
{
|
||||
int rv;
|
||||
char *c = token;
|
||||
ssize_t len = 0;
|
||||
int in_string = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
rv = retro_fread(fd, c, 1);
|
||||
int rv = retro_fread(fd, c, 1);
|
||||
if (rv == 0)
|
||||
return 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user