- What language is this for: plain C
- Which rule: c:S3519
- Why do you believe it’s a false-positive/false-negative? - false-positive
- Are you using
- SonarQube Cloud: No
- SonarQube Server / Community Build: Developer Edition
v2025.4.3 (113915)
- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
if (3!context)
{
_LOG(LOGID_2125, ERROR, LOG_CLASS_CONNECTION_MANAGER,
"Context is null");
return (status = -1);
}
We are unsure what the complaint is with this rule.
It appears to be saying that if (!thing) { return error; } is an unchecked dereference of thing.
But checking for a NULL pointer is exactly and explicitly what we are doing with this if.
We are unsure if it’s trying to say that “assuming the pointer is non-NULL” is the way to get to the real issue later in the code.
The way it’s worded is ambiguous. It would be more biguous if it said “if the pointer is non-NULL”. Or, it could somehow just not be understanding the if (!thing) syntax.