More static code analysis nits

This commit is contained in:
twinaphex 2015-09-28 18:22:27 +02:00
parent 4ca5d31f9b
commit 631da50dfa
8 changed files with 21 additions and 18 deletions

View File

@ -302,6 +302,7 @@ static void iir_filter_init(struct iir_data *iir,
a1pha = sn / (2.0 * 0.4845); a1pha = sn / (2.0 * 0.4845);
A = exp(log(10.0) * -9.477 / 40.0); A = exp(log(10.0) * -9.477 / 40.0);
beta = sqrt(A + A); beta = sqrt(A + A);
(void)a1pha;
case HSH: case HSH:
b0 = A * ((A + 1.0) + (A - 1.0) * cs + beta * sn); b0 = A * ((A + 1.0) + (A - 1.0) * cs + beta * sn);
b1 = -2.0 * A * ((A - 1.0) + (A + 1.0) * cs); b1 = -2.0 * A * ((A - 1.0) + (A + 1.0) * cs);

View File

@ -223,7 +223,6 @@ static int check_pcm_status(void *data, int channel_type)
static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size) static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size)
{ {
alsa_t *alsa = (alsa_t*)data; alsa_t *alsa = (alsa_t*)data;
snd_pcm_channel_status_t cstatus = {0};
snd_pcm_sframes_t written = 0; snd_pcm_sframes_t written = 0;
while (size) while (size)

View File

@ -58,7 +58,6 @@ static void *ra_init(const char *device, unsigned rate, unsigned latency)
static ssize_t ra_write(void *data, const void *buf, size_t size) static ssize_t ra_write(void *data, const void *buf, size_t size)
{ {
int err; int err;
ssize_t rc;
size_t written = 0; size_t written = 0;
roar_t *roar = (roar_t*)data; roar_t *roar = (roar_t*)data;
@ -67,6 +66,7 @@ static ssize_t ra_write(void *data, const void *buf, size_t size)
while (written < size) while (written < size)
{ {
ssize_t rc;
size_t write_amt = size - written; size_t write_amt = size - written;
if ((rc = roar_vs_write(roar->vss, (const char*)buf + written, write_amt, &err)) < (ssize_t)write_amt) if ((rc = roar_vs_write(roar->vss, (const char*)buf + written, write_amt, &err)) < (ssize_t)write_amt)
@ -123,7 +123,6 @@ static void ra_free(void *data)
static bool ra_use_float(void *data) static bool ra_use_float(void *data)
{ {
alsa_t *alsa = (alsa_t*)data;
return false; return false;
} }

View File

@ -268,12 +268,13 @@ bool cheat_manager_realloc(cheat_manager_t *handle, unsigned new_size)
void cheat_manager_free(cheat_manager_t *handle) void cheat_manager_free(cheat_manager_t *handle)
{ {
unsigned i;
if (!handle) if (!handle)
return; return;
if (handle->cheats) if (handle->cheats)
{ {
unsigned i;
for (i = 0; i < handle->size; i++) for (i = 0; i < handle->size; i++)
{ {
free(handle->cheats[i].desc); free(handle->cheats[i].desc);

View File

@ -132,28 +132,29 @@ rarch_cmd_t *rarch_cmd_new(bool stdin_enable,
if (!handle) if (!handle)
return NULL; return NULL;
(void)network_enable;
(void)port;
(void)stdin_enable;
#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY)
handle->net_fd = -1; handle->net_fd = -1;
if (network_enable && !cmd_init_network(handle, port)) if (network_enable && !cmd_init_network(handle, port))
goto error; goto error;
#else
(void)network_enable;
(void)port;
#endif #endif
#ifdef HAVE_STDIN_CMD #ifdef HAVE_STDIN_CMD
handle->stdin_enable = stdin_enable; handle->stdin_enable = stdin_enable;
if (stdin_enable && !cmd_init_stdin(handle)) if (stdin_enable && !cmd_init_stdin(handle))
goto error; goto error;
#else
(void)stdin_enable;
#endif #endif
return handle; return handle;
#if (defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY)) || defined(HAVE_STDIN_CMD)
error: error:
rarch_cmd_free(handle); rarch_cmd_free(handle);
return NULL; return NULL;
#endif
} }
void rarch_cmd_free(rarch_cmd_t *handle) void rarch_cmd_free(rarch_cmd_t *handle)

View File

@ -370,9 +370,7 @@ static int database_cursor_open(libretrodb_t *db,
error: error:
if (q) if (q)
libretrodb_query_free(q); libretrodb_query_free(q);
query = NULL;
libretrodb_close(db); libretrodb_close(db);
db = NULL;
return -1; return -1;
} }

View File

@ -181,7 +181,6 @@ static INLINE unsigned align_common(unsigned i, unsigned j)
/* Find the index of a compatible DRM device. */ /* Find the index of a compatible DRM device. */
static int exynos_get_device_index(void) static int exynos_get_device_index(void)
{ {
int fd;
drmVersionPtr ver; drmVersionPtr ver;
char buf[32] = {0}; char buf[32] = {0};
int index = 0; int index = 0;
@ -189,6 +188,8 @@ static int exynos_get_device_index(void)
while (!found) while (!found)
{ {
int fd;
snprintf(buf, sizeof(buf), "/dev/dri/card%d", index); snprintf(buf, sizeof(buf), "/dev/dri/card%d", index);
fd = open(buf, O_RDWR); fd = open(buf, O_RDWR);
@ -370,10 +371,14 @@ static int exynos_realloc_buffer(struct exynos_data *pdata,
enum exynos_buffer_type type, unsigned size) enum exynos_buffer_type type, unsigned size)
{ {
struct exynos_bo *buf = pdata->buf[type]; struct exynos_bo *buf = pdata->buf[type];
unsigned i;
if (!buf)
return -1;
if (size > buf->size) if (size > buf->size)
{ {
unsigned i;
#if (EXYNOS_GFX_DEBUG_LOG == 1) #if (EXYNOS_GFX_DEBUG_LOG == 1)
RARCH_LOG("[video_exynos]: reallocating %s buffer (%u -> %u bytes)\n", RARCH_LOG("[video_exynos]: reallocating %s buffer (%u -> %u bytes)\n",
exynos_buffer_name(type), buf->size, size); exynos_buffer_name(type), buf->size, size);

View File

@ -1074,7 +1074,6 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
{ {
unsigned width, height; unsigned width, height;
const struct gfx_fbo_rect *prev_rect; const struct gfx_fbo_rect *prev_rect;
const struct gfx_fbo_rect *rect;
struct gfx_tex_info *fbo_info; struct gfx_tex_info *fbo_info;
struct gfx_tex_info fbo_tex_info[GFX_MAX_SHADERS]; struct gfx_tex_info fbo_tex_info[GFX_MAX_SHADERS];
int i; int i;
@ -1091,8 +1090,9 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
* and render all passes from FBOs, to another FBO. */ * and render all passes from FBOs, to another FBO. */
for (i = 1; i < gl->fbo_pass; i++) for (i = 1; i < gl->fbo_pass; i++)
{ {
const struct gfx_fbo_rect *rect = &gl->fbo_rect[i];
prev_rect = &gl->fbo_rect[i - 1]; prev_rect = &gl->fbo_rect[i - 1];
rect = &gl->fbo_rect[i];
fbo_info = &fbo_tex_info[i - 1]; fbo_info = &fbo_tex_info[i - 1];
xamt = (GLfloat)prev_rect->img_width / prev_rect->width; xamt = (GLfloat)prev_rect->img_width / prev_rect->width;
@ -2775,10 +2775,9 @@ static bool gl_set_shader(void *data,
if (!gl->shader->init(gl, path)) if (!gl->shader->init(gl, path))
{ {
bool ret = false; bool ret = gl->shader->init(gl, NULL);
RARCH_WARN("[GL]: Failed to set multipass shader. Falling back to stock.\n"); RARCH_WARN("[GL]: Failed to set multipass shader. Falling back to stock.\n");
ret = gl->shader->init(gl, NULL);
if (!ret) if (!ret)
gl->shader = NULL; gl->shader = NULL;