Skip to content

CheckLeakAutoVar: --check-library accepts <use> functions - #8953

Open
pduchi wants to merge 1 commit into
cppcheck-opensource:mainfrom
pduchi:checkleakautovar-use-silences-check-library
Open

pduchi wants to merge 1 commit into
cppcheck-opensource:mainfrom
pduchi:checkleakautovar-use-silences-check-library

Conversation

@pduchi

@pduchi pduchi commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

I don't have a Trac account, so there is no ticket for this; the details are below. Feel free to create one and I'll add it to the title.

Passing an allocated pointer to a function configured as <use> still gives a --check-library message:

use.cfg:

<memory>
  <alloc>myalloc</alloc>
  <use>set_data</use>
  <dealloc>myfree</dealloc>
</memory>
<function name="myalloc"><noreturn>false</noreturn><arg nr="1"/></function>
<function name="set_data"><noreturn>false</noreturn><arg nr="1"/></function>

use.c:

void f(void)
{
    char *p = myalloc(10);
    set_data(p);
}

$ cppcheck --check-library --library=use.cfg use.c
use.c:5:1: warning: --check-library: Function set_data() should have <use>/<leak-ignore> configuration [checkLibraryUseIgnore]

The cfg reference says <use> exists to silence exactly this message, but CheckLeakAutoVarImpl::configurationInfo() only took <leak-ignore/> into account. It now skips functions that have <use> as well. The leak analysis itself is unchanged.

Test: TestLeakAutoVar::configurationUse; it fails without the change.

Passing an allocated pointer to a function configured as <use> still gave
  --check-library: Function f() should have <use>/<leak-ignore> configuration
The reference says <use> is there to silence exactly that message, so do
not report functions that have it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant