]> granicus.if.org Git - gc/commitdiff
Workaround 'resource leak' error reported by cppcheck (tools, test)
authorIvan Maidanski <ivmai@mail.ru>
Thu, 13 Oct 2016 08:33:17 +0000 (11:33 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 13 Oct 2016 08:33:17 +0000 (11:33 +0300)
* 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.

tests/test.c
tools/if_not_there.c

index 1261e9c9e648f419d3d2002911419c25fce8827a..6a97200d951dfe66d4dd7c2a14cb43547bebdcfe 100644 (file)
@@ -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) );
 }
index c0f095d058cae804efd53997471a70d4a7dff63f..652126d44da5ab2cbfcd034f68a8f9c45cf7155d 100644 (file)
@@ -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);
     }