From 631da50dfa28a969730cbc963fbc24a684e17c67 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 28 Sep 2015 18:22:27 +0200 Subject: [PATCH] More static code analysis nits --- audio/audio_filters/iir.c | 1 + audio/drivers/alsa_qsa.c | 3 +-- audio/drivers/roar.c | 3 +-- cheats.c | 3 ++- command.c | 11 ++++++----- database_info.c | 2 -- gfx/drivers/exynos_gfx.c | 9 +++++++-- gfx/drivers/gl.c | 7 +++---- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/audio/audio_filters/iir.c b/audio/audio_filters/iir.c index d2ea7f7264..3bfbf52df5 100644 --- a/audio/audio_filters/iir.c +++ b/audio/audio_filters/iir.c @@ -302,6 +302,7 @@ static void iir_filter_init(struct iir_data *iir, a1pha = sn / (2.0 * 0.4845); A = exp(log(10.0) * -9.477 / 40.0); beta = sqrt(A + A); + (void)a1pha; case HSH: b0 = A * ((A + 1.0) + (A - 1.0) * cs + beta * sn); b1 = -2.0 * A * ((A - 1.0) + (A + 1.0) * cs); diff --git a/audio/drivers/alsa_qsa.c b/audio/drivers/alsa_qsa.c index a0aef4a1dd..99f0aea855 100644 --- a/audio/drivers/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -222,8 +222,7 @@ static int check_pcm_status(void *data, int channel_type) static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size) { - alsa_t *alsa = (alsa_t*)data; - snd_pcm_channel_status_t cstatus = {0}; + alsa_t *alsa = (alsa_t*)data; snd_pcm_sframes_t written = 0; while (size) diff --git a/audio/drivers/roar.c b/audio/drivers/roar.c index 02190232da..b66c090fce 100644 --- a/audio/drivers/roar.c +++ b/audio/drivers/roar.c @@ -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) { int err; - ssize_t rc; size_t written = 0; 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) { + ssize_t rc; size_t write_amt = size - written; 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) { - alsa_t *alsa = (alsa_t*)data; return false; } diff --git a/cheats.c b/cheats.c index 67adf333d6..6e4c85647d 100644 --- a/cheats.c +++ b/cheats.c @@ -268,12 +268,13 @@ bool cheat_manager_realloc(cheat_manager_t *handle, unsigned new_size) void cheat_manager_free(cheat_manager_t *handle) { - unsigned i; if (!handle) return; if (handle->cheats) { + unsigned i; + for (i = 0; i < handle->size; i++) { free(handle->cheats[i].desc); diff --git a/command.c b/command.c index 83fdbcba08..25c1279524 100644 --- a/command.c +++ b/command.c @@ -132,28 +132,29 @@ rarch_cmd_t *rarch_cmd_new(bool stdin_enable, if (!handle) return NULL; + (void)network_enable; + (void)port; + (void)stdin_enable; + #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) handle->net_fd = -1; if (network_enable && !cmd_init_network(handle, port)) goto error; -#else - (void)network_enable; - (void)port; #endif #ifdef HAVE_STDIN_CMD handle->stdin_enable = stdin_enable; if (stdin_enable && !cmd_init_stdin(handle)) goto error; -#else - (void)stdin_enable; #endif return handle; +#if (defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY)) || defined(HAVE_STDIN_CMD) error: rarch_cmd_free(handle); return NULL; +#endif } void rarch_cmd_free(rarch_cmd_t *handle) diff --git a/database_info.c b/database_info.c index 29fbb851c0..6546ff7006 100644 --- a/database_info.c +++ b/database_info.c @@ -370,9 +370,7 @@ static int database_cursor_open(libretrodb_t *db, error: if (q) libretrodb_query_free(q); - query = NULL; libretrodb_close(db); - db = NULL; return -1; } diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index b583d1f21e..3428769939 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -181,7 +181,6 @@ static INLINE unsigned align_common(unsigned i, unsigned j) /* Find the index of a compatible DRM device. */ static int exynos_get_device_index(void) { - int fd; drmVersionPtr ver; char buf[32] = {0}; int index = 0; @@ -189,6 +188,8 @@ static int exynos_get_device_index(void) while (!found) { + int fd; + snprintf(buf, sizeof(buf), "/dev/dri/card%d", index); 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) { struct exynos_bo *buf = pdata->buf[type]; - unsigned i; + + if (!buf) + return -1; if (size > buf->size) { + unsigned i; + #if (EXYNOS_GFX_DEBUG_LOG == 1) RARCH_LOG("[video_exynos]: reallocating %s buffer (%u -> %u bytes)\n", exynos_buffer_name(type), buf->size, size); diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index eb9c2397e8..9bf55d66f7 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1074,7 +1074,6 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, { unsigned width, height; const struct gfx_fbo_rect *prev_rect; - const struct gfx_fbo_rect *rect; struct gfx_tex_info *fbo_info; struct gfx_tex_info fbo_tex_info[GFX_MAX_SHADERS]; 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. */ 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]; - rect = &gl->fbo_rect[i]; fbo_info = &fbo_tex_info[i - 1]; 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)) { - bool ret = false; + bool ret = gl->shader->init(gl, NULL); RARCH_WARN("[GL]: Failed to set multipass shader. Falling back to stock.\n"); - ret = gl->shader->init(gl, NULL); if (!ret) gl->shader = NULL;