Running a project through Clang's scan-build produces countless
warnings like
build/test/mocks/mock_handleTroubleEvents.c:321:5: warning: Value stored to 'call_instance' is never read
call_instance = CMOCK_GUTS_NONE;
^ ~~~~~~~~~~~~~~~
scan-build correctly determines that in the following snippet
UNITY_CLR_DETAILS();
if (Mock.checkForActiveTroubleAfterDebounce_CallbackFunctionPointer != NULL)
call_instance = CMOCK_GUTS_NONE;
call_instance = Mock.startStopTimer_CallInstance;
as generated by Ceedling / CMock, the first assignment to
call_instance is completely unused.
The sheer amount of warnings makes it very hard to impossible to
spot real problems in one's code, and creates huge code analysis
reports that just distract from actual problems in one's code.
Without being too invasive, we can instruct scan-build to ignore
this dead store using
https://clang-analyzer.llvm.org/faq.html#dead_store
Signed-off-by: André Draszik <git@andred.net>
callback has a later priority than expect, so setting call_instance
to CMOCK_GUTS_NONE at this point has no effect. This mock_verify()
has probably been obsolete for a long time.
StubWithCallback can currently be configured to run the callback
function either before or after argument+ordering checks, based on
:callback_after_arg_check. Currently, however, you can't use both
behaviors in the same test suite; you have to pick one.
This change makes both behaviors available under two new names:
- IgnoreWithCallback, as if :callback_after_arg_check = false
- CheckWithCallback, as if :callback_after_arg_check = true
StubWithCallback simply becomes an alias (#define) for either
IgnoreWithCallback or CheckWithCallback, depending on config.
create_mock_destroy_function() in cmock_generator.rb already clears
the entire mock to 0 (using memset) before call the plugin's
mock_destroy() function. So mock_destroy() in the callback plugin
is doing work that was already done.
In typical unit tests, this doesn't matter since the Verify functions
are called only from the end of the test. However, in longer integration
tests, where a sequence of function calls is to be tested, it's handy
to be able to verify the Expects halfway through the test. This change
is a first step in making that possible.
1. Update treat_as table to include pointer-to-constant types.
2. Remove unnecessary casts in assignments and return statements.
3. Improve logic for adding "const" to types of function arguments.
4. It's no longer necessary to prepend "const" to function return type.
- Fixed ignore-when-ignoring-args-only
- Fixed error in memory comparisons when pointers used
- Fixed system testing of CMock(!)
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@167 bf332499-1b4d-0410-844d-d2d48d5cc64c