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: v8.0.0~1113 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88990a302569d211c718f33411d51c7e638f5abf;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 1261e9c9..6a97200d 100644 --- a/tests/test.c +++ b/tests/test.c @@ -361,7 +361,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); }