[RFC] Detecting unchecked return values (with SmPL)?

From: Markus Elfring

Date: Mon Nov 30 2026 - 08:00:32 EST


Hello,

Macro and function calls for which a return value is not assigned to a variable
can be found also by a script (like the following) for the semantic patch language.

@display@
identifier i;
statement s;
@@
(
*i(...);
&s
)


Some developers and software reviewers care for a corresponding topic.

CWE-252: Unchecked Return Value
https://cwe.mitre.org/data/definitions/252.html


Thus I suggest to refine case distinctions accordingly.

1. Identifiers can eventually be excluded if they would denote items
with the return type “void”.

2. Identifiers can eventually be restricted to names that would denote items
according to non-void return types.


Which structures would you choose for such data processing purposes?

Regards,
Markus