Define RCUTILS_FAULT_INJECTION_MAYBE_RETURN_ERROR

Define Documentation

RCUTILS_FAULT_INJECTION_MAYBE_RETURN_ERROR(return_value_on_error)

This macro checks and decrements a static global variable atomic counter and returns return_value_on_error if 0.

This macro is not a function itself, so when this macro returns it will cause the calling function to return with the return value.

Set the counter with RCUTILS_FAULT_INJECTION_SET_COUNT. If the count is less than 0, then RCUTILS_FAULT_INJECTION_MAYBE_RETURN_ERROR will not cause an early return.

This macro is thread-safe, and ensures that at most one invocation results in a failure for each time the fault injection counter is set with RCUTILS_FAULT_INJECTION_SET_COUNT

Parameters:
  • return_value_on_error – the value to return in the case of fault injected failure.