C: return in macro doesn't seem to be considered
Hi,
I am running Parasoft for MISRA.
Following a simplified code example:
define RC(func) \
do { \
rc_t rc_ = func; \
if is_error(rc_) return rc_;
} while (0)
struct info_t {
rc_t (*handler)();
};
rc_t caller() {
struct info_t info = {0};
RC(called_function(&info));
// From this point, info is well initialized by the called function
return info.handler();
}
MISRA considers that handler may be NULL when invoked and reports DIR_4_1-b-2 issue. When looking at the scenario leading to this issue in the report, the called function returns an error, the RC macro returns this error as well but then MISRA assumes that the code continues to the handler invocation.
I tried to suppress this warning by adding a _Pragma in the macro itself without success.
What can I do?
Thanks
Answers
-
@JackDanielZ ,
We will need additional details to reproduce and explain why the violation was reported. Our support team will contact you directly regarding this.0