MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / assign23

Method assign23

test/testleakautovar.cpp:463–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461 }
462
463 void assign23() {
464 const Settings s = settingsBuilder().library("posix.cfg").checkLibrary().build();
465 check("void f() {\n"
466 " int n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14;\n"
467 " *&n1 = open(\"xx.log\", O_RDONLY);\n"
468 " *&(n2) = open(\"xx.log\", O_RDONLY);\n"
469 " *(&n3) = open(\"xx.log\", O_RDONLY);\n"
470 " *&*&n4 = open(\"xx.log\", O_RDONLY);\n"
471 " *&*&*&(n5) = open(\"xx.log\", O_RDONLY);\n"
472 " *&*&(*&n6) = open(\"xx.log\", O_RDONLY);\n"
473 " *&*(&*&n7) = open(\"xx.log\", O_RDONLY);\n"
474 " *(&*&n8) = open(\"xx.log\", O_RDONLY);\n"
475 " *&(*&*&(*&n9)) = open(\"xx.log\", O_RDONLY);\n"
476 " (n10) = open(\"xx.log\", O_RDONLY);\n"
477 " ((n11)) = open(\"xx.log\", O_RDONLY);\n"
478 " ((*&n12)) = open(\"xx.log\", O_RDONLY);\n"
479 " *(&(*&n13)) = open(\"xx.log\", O_RDONLY);\n"
480 " ((*&(*&n14))) = open(\"xx.log\", O_RDONLY);\n"
481 "}\n", dinit(CheckOptions, $.cpp = true, $.s = &s));
482 ASSERT_EQUALS("[test.cpp:17:1]: (error) Resource leak: n1 [resourceLeak]\n"
483 "[test.cpp:17:1]: (error) Resource leak: n2 [resourceLeak]\n"
484 "[test.cpp:17:1]: (error) Resource leak: n3 [resourceLeak]\n"
485 "[test.cpp:17:1]: (error) Resource leak: n4 [resourceLeak]\n"
486 "[test.cpp:17:1]: (error) Resource leak: n5 [resourceLeak]\n"
487 "[test.cpp:17:1]: (error) Resource leak: n6 [resourceLeak]\n"
488 "[test.cpp:17:1]: (error) Resource leak: n7 [resourceLeak]\n"
489 "[test.cpp:17:1]: (error) Resource leak: n8 [resourceLeak]\n"
490 "[test.cpp:17:1]: (error) Resource leak: n9 [resourceLeak]\n"
491 "[test.cpp:17:1]: (error) Resource leak: n10 [resourceLeak]\n"
492 "[test.cpp:17:1]: (error) Resource leak: n11 [resourceLeak]\n"
493 "[test.cpp:17:1]: (error) Resource leak: n12 [resourceLeak]\n"
494 "[test.cpp:17:1]: (error) Resource leak: n13 [resourceLeak]\n"
495 "[test.cpp:17:1]: (error) Resource leak: n14 [resourceLeak]\n",
496 errout_str());
497 }
498
499 void assign24() {
500 check("void f() {\n" // #7440

Callers

nothing calls this directly

Calls 3

buildMethod · 0.80
checkLibraryMethod · 0.80
libraryMethod · 0.80

Tested by

no test coverage detected