mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC] Detecting unchecked return values (with SmPL)?
@ 2026-11-30 13:00 Markus Elfring
  2026-11-30 13:05 ` Julia Lawall
  2026-11-30 16:44 ` Markus Elfring
  0 siblings, 2 replies; 8+ 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] 8+ 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
  2026-11-30 16:44 ` Markus Elfring
  1 sibling, 2 replies; 8+ 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] 8+ 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; 8+ 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] 8+ 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; 8+ 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] 8+ 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
  2026-11-30 15:49     ` Julia Lawall
  1 sibling, 1 reply; 8+ 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] 8+ messages in thread

* Re: [cocci] [RFC] Detecting unchecked return values (with SmPL)?
  2026-11-30 14:00   ` Markus Elfring
@ 2026-11-30 15:49     ` Julia Lawall
  2026-11-30 15:58       ` Markus Elfring
  0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2026-11-30 15:49 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci, tools, kernel-janitors, LKML



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.
>
> 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?

*i(...);

seemed completely fine.  There is no need to consider the other contexts
in which a funcion call can occur.

julia

>
> Regards,
> Markus
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [cocci] [RFC] Detecting unchecked return values (with SmPL)?
  2026-11-30 15:49     ` Julia Lawall
@ 2026-11-30 15:58       ` Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2026-11-30 15:58 UTC (permalink / raw)
  To: Julia Lawall, cocci; +Cc: tools, kernel-janitors, LKML

>> 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?
> 
> *i(...);
> 
> seemed completely fine.  There is no need to consider the other contexts
> in which a funcion call can occur.
Will such information influence the incomplete software documentation any more?

Regards,
Markus

^ permalink raw reply	[flat|nested] 8+ 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 16:44 ` Markus Elfring
  1 sibling, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2026-11-30 16:44 UTC (permalink / raw)
  To: cocci, tools, kernel-janitors; +Cc: LKML

> CWE-252: Unchecked Return Value

How will development interests evolve further if it could be determined also
with the help of another script variant (like the following) for the semantic
patch language that the software “Linux next-20261127” contains eventually
423 unchecked function calls in 246 source files according to a single
selected identifier?

@display@
@@
*clk_prepare_enable(...);


Can any coccicheck script variations become more helpful here?

Regards,
Markus

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-30 16:44 UTC | newest]

Thread overview: 8+ 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
2026-11-30 15:49     ` Julia Lawall
2026-11-30 15:58       ` Markus Elfring
2026-11-30 16:44 ` 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®