From: Ivan Maidanski Date: Thu, 13 Oct 2016 08:33:17 +0000 (+0300) Subject: Workaround 'resource leak' error reported by cppcheck (tools, test) X-Git-Tag: v7.4.6~235 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ac6d680822e3bd6b10a32884f1d344213a56d72;p=gc Workaround 'resource leak' error reported by cppcheck (tools, test) * tests/test.c [GC_GCJ_SUPPORT && TEST_WITH_SYSTEM_MALLOC] (reverse): Call GC_noop1 for malloc() result. * tools/if_not_there.c (main): Move "f" local variable assignments outside conditional expression. --- diff --git a/tests/test.c b/tests/test.c index e00ffd19..49c13374 100644 --- a/tests/test.c +++ b/tests/test.c @@ -360,7 +360,7 @@ sexpr reverse1(sexpr x, sexpr y) sexpr reverse(sexpr x) { # ifdef TEST_WITH_SYSTEM_MALLOC - malloc(100000); + GC_noop1(GC_HIDE_POINTER(malloc(100000))); # endif return( reverse1(x, nil) ); } diff --git a/tools/if_not_there.c b/tools/if_not_there.c index c0f095d0..652126d4 100644 --- a/tools/if_not_there.c +++ b/tools/if_not_there.c @@ -16,8 +16,14 @@ int main(int argc, char **argv) DIR * d; #endif /* __DJGPP__ */ if (argc < 3) goto Usage; - if ((f = fopen(argv[1], "rb")) != 0 - || (f = fopen(argv[1], "r")) != 0) { + + f = fopen(argv[1], "rb"); + if (f != NULL) { + fclose(f); + return(0); + } + f = fopen(argv[1], "r"); + if (f != NULL) { fclose(f); return(0); }