From aad75c86365b71d625a730a0d42c6537a9016feb Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Fri, 29 Jun 2018 09:33:23 -0700 Subject: Fix some issues identified by cppcheck --- dis.c | 1 + jagcpu_x86.c | 4 ++-- nuklear_ui/font_win.c | 1 + util.c | 5 +++-- zdis.c | 1 + zip.c | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dis.c b/dis.c index bdcf2a2..5c0dfba 100644 --- a/dis.c +++ b/dis.c @@ -206,6 +206,7 @@ int main(int argc, char ** argv) } } } + fclose(address_log); } } else { char *end; diff --git a/jagcpu_x86.c b/jagcpu_x86.c index c7a599d..322e6b4 100644 --- a/jagcpu_x86.c +++ b/jagcpu_x86.c @@ -102,7 +102,7 @@ void jag_check_resultwrite_singleread(jag_cpu options *opts, uint8_t reg) code_ptr no_delay = code-.cur + 1; jcc(code, CC_NZ, no_delay + 1); ccylces(code, 1); - *no_delay = code->cur - (no_delay = 1); + *no_delay = code->cur - (no_delay + 1); *no_result = code->cur - (no_result + 1); mov_rr(code, opts->resultreg, opts->writeback, SZ_B); } @@ -122,7 +122,7 @@ void translate_jag_quickimmed(jag_cpu_options *opts, uint32_t address, uint16_t uint16_t *translate_jag_inst(uint16_t *stream, jag_cpu_options *opts, uint32_t address) { - uint16_t inst = *stream + uint16_t inst = *stream; ++stream; uint16_t opcode = jag_opcode(inst, opts->is_gpu); check_cycles_int(&opts->gen, address); diff --git a/nuklear_ui/font_win.c b/nuklear_ui/font_win.c index b2c5d75..b47e8ae 100644 --- a/nuklear_ui/font_win.c +++ b/nuklear_ui/font_win.c @@ -136,6 +136,7 @@ uint8_t *default_font(uint32_t *size_out) free(path); } } + free(pref_prefix); free(fonts); free_dir_list(entries, num_entries); if (selected) { diff --git a/util.c b/util.c index 4feca66..7c7fd35 100644 --- a/util.c +++ b/util.c @@ -255,8 +255,8 @@ int utf8_codepoint(const char **text) if (initial < 0x80) { return initial; } - int base; - uint8_t extended_bytes; + int base = 0; + uint8_t extended_bytes = 0; if ((initial & 0xE0) == 0xC0) { base = 0x80; initial &= 0x1F; @@ -873,6 +873,7 @@ char *read_bundled_file(char *name, uint32_t *sizeret) } else { ret = NULL; } + fclose(f); return ret; } diff --git a/zdis.c b/zdis.c index 82455da..dbc3cbb 100644 --- a/zdis.c +++ b/zdis.c @@ -112,6 +112,7 @@ int main(int argc, char ** argv) } } } + fclose(address_log); break; case 's': opt++; diff --git a/zip.c b/zip.c index 5356c44..4b990aa 100644 --- a/zip.c +++ b/zip.c @@ -176,8 +176,8 @@ uint8_t *zip_read(zip_file *f, uint32_t index, size_t *out_size) } } break; -#endif } +#endif default: free(buf); return NULL; -- cgit v1.2.3