From f5f17997b2a6e539fc411c22d68cbae4bda54fa7 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 30 Nov 2016 14:45:21 -0800 Subject: [PATCH] Fix cppcheck warnings --- src/mpsp.c | 8 ++++++-- src/opencl.c | 11 ++++++++++- src/status.c | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/mpsp.c b/src/mpsp.c index f8650a685..bfdf4a2f2 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -551,10 +551,14 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, { event_log_error (hashcat_ctx, "%s: Custom charset file is too large", buf); + fclose (fp); + return -1; } - - fclose (fp); + else + { + fclose (fp); + } if (nread == 0) { diff --git a/src/opencl.c b/src/opencl.c index 9b4fda09e..56e34f0e8 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -62,7 +62,16 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) u32 vendor = 0; - if (fscanf (fd_drm, "0x%x", &vendor) != 1) return 0; + if (fscanf (fd_drm, "0x%x", &vendor) != 1) + { + fclose (fd_drm); + + return 0; + } + else + { + fclose (fd_drm); + } if (vendor != 4098) return 0; diff --git a/src/status.c b/src/status.c index 0874520de..486f6743b 100644 --- a/src/status.c +++ b/src/status.c @@ -1637,7 +1637,7 @@ char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_i } else { - output_len = snprintf (output_buf, HCBUFSIZ_TINY - 1, "N/A"); + snprintf (output_buf, HCBUFSIZ_TINY - 1, "N/A"); } hc_thread_mutex_unlock (status_ctx->mux_hwmon);