public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
* [cocci] Checking SmPL support for two special expressions
@ 2025-11-11 18:23 Markus Elfring
  2025-11-11 18:29 ` Julia Lawall
  0 siblings, 1 reply; 10+ messages in thread
From: Markus Elfring @ 2025-11-11 18:23 UTC (permalink / raw)
  To: cocci

Hello,

I constructed another SmPL script variant. It exported some data from
selected function implementations which were found in header files.
Data processing difficulties were detected then.

See also:
https://elixir.bootlin.com/linux/v6.18-rc5/source/include/drm/drm_crtc.h#L48-L55

It seems that contents can usually be handled from such a file.

Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> /usr/bin/spatch --parse-c include/drm/drm_crtc.h
…
nb good = 1344,  nb bad = 0 =========> 100.00% good or passed


Two SmPL rules were generated accordingly.
Unfortunately, I am wondering about the following information.
Questionable test results (according to the software combination “Coccinelle 1.3.0”):

A)
@r26@
expression val;
@@
-( uint64_t ) * ( ( uint64_t * ) & val )
+I642U64(val)

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch --parse-cocci drm_crtc-I642U64-20251111.cocci
…
minus: parse error: 
  File "drm_crtc-I642U64-20251111.cocci", line 4, column 31, charpos = 56
  around = ')',
  whole content = -( uint64_t ) * ( ( uint64_t * ) & val )

B)
@r27@
expression val;
@@
-( int64_t ) * ( ( int64_t * ) & val )
+U642I64(val)

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch --parse-cocci drm_crtc-U642I64-20251111.cocci
…
minus: parse error: 
  File "drm_crtc-U642I64-20251111.cocci", line 4, column 29, charpos = 54
  around = ')',
  whole content = -( int64_t ) * ( ( int64_t * ) & val )


Under which circumstances will such data processing become better supported?

Regards,
Markus

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

* Re: [cocci] Checking SmPL support for two special expressions
  2025-11-11 18:23 [cocci] Checking SmPL support for two special expressions Markus Elfring
@ 2025-11-11 18:29 ` Julia Lawall
  2025-11-11 19:43   ` Markus Elfring
  2025-11-13  7:05   ` [cocci] Improving support for casts in SmPL code? Markus Elfring
  0 siblings, 2 replies; 10+ messages in thread
From: Julia Lawall @ 2025-11-11 18:29 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 1758 bytes --]



On Tue, 11 Nov 2025, Markus Elfring wrote:

> Hello,
>
> I constructed another SmPL script variant. It exported some data from
> selected function implementations which were found in header files.
> Data processing difficulties were detected then.
>
> See also:
> https://elixir.bootlin.com/linux/v6.18-rc5/source/include/drm/drm_crtc.h#L48-L55
>
> It seems that contents can usually be handled from such a file.
>
> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> /usr/bin/spatch --parse-c include/drm/drm_crtc.h
> …
> nb good = 1344,  nb bad = 0 =========> 100.00% good or passed
>
>
> Two SmPL rules were generated accordingly.
> Unfortunately, I am wondering about the following information.
> Questionable test results (according to the software combination “Coccinelle 1.3.0”):
>
> A)
> @r26@
> expression val;
> @@
> -( uint64_t ) * ( ( uint64_t * ) & val )
> +I642U64(val)
>
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch --parse-cocci drm_crtc-I642U64-20251111.cocci
> …
> minus: parse error:
>   File "drm_crtc-I642U64-20251111.cocci", line 4, column 31, charpos = 56
>   around = ')',
>   whole content = -( uint64_t ) * ( ( uint64_t * ) & val )
>
> B)
> @r27@
> expression val;
> @@
> -( int64_t ) * ( ( int64_t * ) & val )
> +U642I64(val)
>
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch --parse-cocci drm_crtc-U642I64-20251111.cocci
> …
> minus: parse error:
>   File "drm_crtc-U642I64-20251111.cocci", line 4, column 29, charpos = 54
>   around = ')',
>   whole content = -( int64_t ) * ( ( int64_t * ) & val )
>
>
> Under which circumstances will such data processing become better supported?

Coccinelle doesn't know these types.  You have to declare them with
typedef.

julia

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

* Re: [cocci] Checking SmPL support for two special expressions
  2025-11-11 18:29 ` Julia Lawall
@ 2025-11-11 19:43   ` Markus Elfring
  2025-11-11 20:41     ` Julia Lawall
  2025-11-13  7:05   ` [cocci] Improving support for casts in SmPL code? Markus Elfring
  1 sibling, 1 reply; 10+ messages in thread
From: Markus Elfring @ 2025-11-11 19:43 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

…>> -( uint64_t ) * ( ( uint64_t * ) & val )
>> +I642U64(val)
…>> -( int64_t ) * ( ( int64_t * ) & val )
>> +U642I64(val)
…> Coccinelle doesn't know these types.  You have to declare them with typedef.

Are type definitions really required for the handling of casts?

Regards,
Markus

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

* Re: [cocci] Checking SmPL support for two special expressions
  2025-11-11 19:43   ` Markus Elfring
@ 2025-11-11 20:41     ` Julia Lawall
  2025-11-12  6:12       ` Markus Elfring
  0 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2025-11-11 20:41 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]



On Tue, 11 Nov 2025, Markus Elfring wrote:

> …>> -( uint64_t ) * ( ( uint64_t * ) & val )
> >> +I642U64(val)
> …>> -( int64_t ) * ( ( int64_t * ) & val )
> >> +U642I64(val)
> …> Coccinelle doesn't know these types.  You have to declare them with typedef.
>
> Are type definitions really required for the handling of casts?

Yes.  There is a potential parsing ambiguity otherwise, I believe.

julia

>
> Regards,
> Markus
>

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

* Re: [cocci] Checking SmPL support for two special expressions
  2025-11-11 20:41     ` Julia Lawall
@ 2025-11-12  6:12       ` Markus Elfring
  2025-11-12 13:10         ` Julia Lawall
  0 siblings, 1 reply; 10+ messages in thread
From: Markus Elfring @ 2025-11-12  6:12 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

>>> Coccinelle doesn't know these types.  You have to declare them with typedef.
>>
>> Are type definitions really required for the handling of casts?
> 
> Yes.  There is a potential parsing ambiguity otherwise, I believe.

How interesting is it that I can recognise casts also without extra type definitions?

Regards,
Markus

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

* Re: [cocci] Checking SmPL support for two special expressions
  2025-11-12  6:12       ` Markus Elfring
@ 2025-11-12 13:10         ` Julia Lawall
  2025-11-12 13:15           ` Markus Elfring
  0 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2025-11-12 13:10 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci



On Wed, 12 Nov 2025, Markus Elfring wrote:

> >>> Coccinelle doesn't know these types.  You have to declare them with typedef.
> >>
> >> Are type definitions really required for the handling of casts?
> >
> > Yes.  There is a potential parsing ambiguity otherwise, I believe.
>
> How interesting is it that I can recognise casts also without extra type definitions?

Not interesting.  Sometimes it can infer them.

julia


>
> Regards,
> Markus
>

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

* Re: [cocci] Checking SmPL support for two special expressions
  2025-11-12 13:10         ` Julia Lawall
@ 2025-11-12 13:15           ` Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2025-11-12 13:15 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

>> How interesting is it that I can recognise casts also without extra type definitions?
> 
> Not interesting.

Can development interests grow accordingly?


>                   Sometimes it can infer them.

Will the pattern recognition be improved anyhow for affected source code?

Regards,
Markus

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

* Re: [cocci] Improving support for casts in SmPL code?
  2025-11-11 18:29 ` Julia Lawall
  2025-11-11 19:43   ` Markus Elfring
@ 2025-11-13  7:05   ` Markus Elfring
  2025-11-14  0:59     ` Julia Lawall
  1 sibling, 1 reply; 10+ messages in thread
From: Markus Elfring @ 2025-11-13  7:05 UTC (permalink / raw)
  To: Julia Lawall, cocci

> Coccinelle doesn't know these types.  You have to declare them with typedef.

A description approach is available in the SmPL manual.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/e6f8731b851f5d76d2731a9d546dc4f0b181526e/docs/manual/cocci_syntax.tex#L456-466

I find this information source unclear in the way for pointing a possible property
out for metavariables of the kind “type definition”.
Do they refer to a fixed type name?

Regards,
Markus

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

* Re: [cocci] Improving support for casts in SmPL code?
  2025-11-13  7:05   ` [cocci] Improving support for casts in SmPL code? Markus Elfring
@ 2025-11-14  0:59     ` Julia Lawall
  2025-11-14  8:30       ` Markus Elfring
  0 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2025-11-14  0:59 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 563 bytes --]



On Thu, 13 Nov 2025, Markus Elfring wrote:

> > Coccinelle doesn't know these types.  You have to declare them with typedef.
>
> A description approach is available in the SmPL manual.
> https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/e6f8731b851f5d76d2731a9d546dc4f0b181526e/docs/manual/cocci_syntax.tex#L456-466
>
> I find this information source unclear in the way for pointing a possible property
> out for metavariables of the kind “type definition”.
> Do they refer to a fixed type name?

typedef is for declaring that a name is a typedef.

julia

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

* Re: [cocci] Improving support for casts in SmPL code?
  2025-11-14  0:59     ` Julia Lawall
@ 2025-11-14  8:30       ` Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2025-11-14  8:30 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

>> https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/e6f8731b851f5d76d2731a9d546dc4f0b181526e/docs/manual/cocci_syntax.tex#L456-466
>>
>> I find this information source unclear in the way for pointing a possible property
>> out for metavariables of the kind “type definition”.
>> Do they refer to a fixed type name?
> 
> typedef is for declaring that a name is a typedef.

Some metavariables tend to represent the concept that that they may refer to
variable items.
There are also metavariable kinds that contain a “name”.
Are these ones fixed finally?

Regards,
Markus

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

end of thread, other threads:[~2025-11-14  8:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11 18:23 [cocci] Checking SmPL support for two special expressions Markus Elfring
2025-11-11 18:29 ` Julia Lawall
2025-11-11 19:43   ` Markus Elfring
2025-11-11 20:41     ` Julia Lawall
2025-11-12  6:12       ` Markus Elfring
2025-11-12 13:10         ` Julia Lawall
2025-11-12 13:15           ` Markus Elfring
2025-11-13  7:05   ` [cocci] Improving support for casts in SmPL code? Markus Elfring
2025-11-14  0:59     ` Julia Lawall
2025-11-14  8:30       ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox