* [RFC] Detecting unchecked return values (with SmPL)?
@ 2026-11-30 13:00 Markus Elfring
2026-11-30 13:05 ` Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2026-11-30 13:00 UTC (permalink / raw)
To: cocci, tools, kernel-janitors; +Cc: LKML
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Detecting unchecked return values (with SmPL)?
2026-11-30 13:00 [RFC] Detecting unchecked return values (with SmPL)? Markus Elfring
@ 2026-11-30 13:05 ` Julia Lawall
2026-11-30 13:25 ` [cocci] " Markus Elfring
2026-11-30 14:00 ` Markus Elfring
0 siblings, 2 replies; 5+ messages in thread
From: Julia Lawall @ 2026-11-30 13:05 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci, tools, kernel-janitors, LKML
[-- Attachment #1: Type: text/plain, Size: 896 bytes --]
On Mon, 30 Nov 2026, Markus Elfring wrote:
> 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
&s seems totally unnecessary.
julia
> )
>
>
> 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
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cocci] [RFC] Detecting unchecked return values (with SmPL)?
2026-11-30 13:05 ` Julia Lawall
@ 2026-11-30 13:25 ` Markus Elfring
2026-11-30 13:52 ` Julia Lawall
2026-11-30 14:00 ` Markus Elfring
1 sibling, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2026-11-30 13:25 UTC (permalink / raw)
To: Julia Lawall, cocci; +Cc: kernel-janitors, linux-kernel, tools
> > 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
>
> &s seems totally unnecessary.
Can the code for the SmPL asterisk alone represent also a source code search
for a call where a variable assignment would be attempted?
Or:
Do you expect to specify the variable assignment exclusion in any other ways?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cocci] [RFC] Detecting unchecked return values (with SmPL)?
2026-11-30 13:25 ` [cocci] " Markus Elfring
@ 2026-11-30 13:52 ` Julia Lawall
0 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2026-11-30 13:52 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci, kernel-janitors, linux-kernel, tools
On Mon, 30 Nov 2026, Markus Elfring wrote:
> > > 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
> >
> > &s seems totally unnecessary.
>
> Can the code for the SmPL asterisk alone represent also a source code search
> for a call where a variable assignment would be attempted?
No. Not with the ;. Coccinelle parses the code. It doesn't search for
substrings.
julia
>
> Or:
> Do you expect to specify the variable assignment exclusion in any other ways?
>
> Regards,
> Markus
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cocci] [RFC] Detecting unchecked return values (with SmPL)?
2026-11-30 13:05 ` Julia Lawall
2026-11-30 13:25 ` [cocci] " Markus Elfring
@ 2026-11-30 14:00 ` Markus Elfring
1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2026-11-30 14:00 UTC (permalink / raw)
To: Julia Lawall, cocci; +Cc: tools, kernel-janitors, LKML
>> 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
> &s seems totally unnecessary.
Would you find the following SmPL script variant more appropriate for
efficient source code searches?
@display2@
expression e;
identifier i;
@@
(e = i(...)
|
*i(...)
);
Would you be looking for more advanced data constraints here?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-30 14:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 13:00 [RFC] Detecting unchecked return values (with SmPL)? Markus Elfring
2026-11-30 13:05 ` Julia Lawall
2026-11-30 13:25 ` [cocci] " Markus Elfring
2026-11-30 13:52 ` Julia Lawall
2026-11-30 14:00 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®