All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] Does SmPL for functions with prototype disjunctions need to be complete?
@ 2022-03-07  1:55 Eric Wheeler
  2022-03-07 20:48 ` Julia Lawall
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Wheeler @ 2022-03-07  1:55 UTC (permalink / raw)
  To: cocci

This seems to work when the body of the funciton is defined in each disjunction:

	@ prefix_nec_arg @
	type T;
	identifier F, j;
	typedef nec_t;
	parameter list PL;
	@@
	( 
	T F(
	-void
	+nec_t *nec
	 )
	{
	... when exists
	    when any
	nec->j
	... when exists
	    when any
	}
	| 
	T F(
	+nec_t *nec
	 )
	{
	... when exists
	    when any
	nec->j
	... when exists
	    when any
	} 
	| 
	T F(
	+nec_t *nec,
	PL
	 )
	{
	... when exists
	    when any
	nec->j
	... when exists
	    when any
	}
	)

But placing the function body after the disjunction block did not, even 
though it is easier to read and does not duplicate content:

	@ prefix_nec_arg @
	type T;
	identifier F, j;
	typedef nec_t;
	parameter list PL;
	@@
	( 
	T F(
	-void
	+nec_t *nec
	 )
	| 
	T F(
	+nec_t *nec
	 )
	| 
	T F(
	+nec_t *nec,
	PL
	 )
	)
	{
	... when exists
	    when any
	nec->j
	... when exists
	    when any
	}

Is that expected?  

It means there must be a longer SmPL, which is ok, but for my own 
curiosity: is there a shorter form?


--
Eric Wheeler

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

* Re: [cocci] Does SmPL for functions with prototype disjunctions need to be complete?
  2022-03-07  1:55 [cocci] Does SmPL for functions with prototype disjunctions need to be complete? Eric Wheeler
@ 2022-03-07 20:48 ` Julia Lawall
  2022-03-07 21:10   ` Markus Elfring
  0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2022-03-07 20:48 UTC (permalink / raw)
  To: Eric Wheeler; +Cc: cocci



On Sun, 6 Mar 2022, Eric Wheeler wrote:

> This seems to work when the body of the funciton is defined in each disjunction:
>
> 	@ prefix_nec_arg @
> 	type T;
> 	identifier F, j;
> 	typedef nec_t;
> 	parameter list PL;
> 	@@
> 	(
> 	T F(
> 	-void
> 	+nec_t *nec
> 	 )
> 	{
> 	... when exists
> 	    when any
> 	nec->j
> 	... when exists
> 	    when any
> 	}
> 	|
> 	T F(
> 	+nec_t *nec
> 	 )
> 	{
> 	... when exists
> 	    when any
> 	nec->j
> 	... when exists
> 	    when any
> 	}
> 	|
> 	T F(
> 	+nec_t *nec,
> 	PL
> 	 )
> 	{
> 	... when exists
> 	    when any
> 	nec->j
> 	... when exists
> 	    when any
> 	}
> 	)
>
> But placing the function body after the disjunction block did not, even
> though it is easier to read and does not duplicate content:
>
> 	@ prefix_nec_arg @
> 	type T;
> 	identifier F, j;
> 	typedef nec_t;
> 	parameter list PL;
> 	@@
> 	(
> 	T F(
> 	-void
> 	+nec_t *nec
> 	 )
> 	|
> 	T F(
> 	+nec_t *nec
> 	 )
> 	|
> 	T F(
> 	+nec_t *nec,
> 	PL
> 	 )
> 	)
> 	{
> 	... when exists
> 	    when any
> 	nec->j
> 	... when exists
> 	    when any
> 	}
>
> Is that expected?
>
> It means there must be a longer SmPL, which is ok, but for my own
> curiosity: is there a shorter form?

It might be possible to put a disjunction around only the parameter list,
ie inside the parentheses.

julia

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

* Re: [cocci] Does SmPL for functions with prototype disjunctions need to be complete?
  2022-03-07 20:48 ` Julia Lawall
@ 2022-03-07 21:10   ` Markus Elfring
  2022-03-08  1:18     ` Eric Wheeler
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Elfring @ 2022-03-07 21:10 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Eric Wheeler, cocci


>> It means there must be a longer SmPL, which is ok, but for my own
>> curiosity: is there a shorter form?
> It might be possible to put a disjunction around only the parameter list,
> ie inside the parentheses.


How useful would such an SmPL code variant be here actually?

Regards,
Markus


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

* Re: [cocci] Does SmPL for functions with prototype disjunctions need to be complete?
  2022-03-07 21:10   ` Markus Elfring
@ 2022-03-08  1:18     ` Eric Wheeler
  2022-03-08  6:26       ` Julia Lawall
  2022-03-08 18:16       ` Markus Elfring
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Wheeler @ 2022-03-08  1:18 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Julia Lawall, cocci

On Mon, 7 Mar 2022, Markus Elfring wrote:

> 
> >> It means there must be a longer SmPL, which is ok, but for my own
> >> curiosity: is there a shorter form?

> > It might be possible to put a disjunction around only the parameter list,
> > ie inside the parentheses.

Thanks Julia, that is a great hint!

> How useful would such an SmPL code variant be here actually?

It just makes it more readable.  I always try to avoid duplicate code no 
matter what language I'm writing for.

--
Eric Wheeler


> 
> Regards,
> Markus
> 
> 
> 

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

* Re: [cocci] Does SmPL for functions with prototype disjunctions need to be complete?
  2022-03-08  1:18     ` Eric Wheeler
@ 2022-03-08  6:26       ` Julia Lawall
  2022-03-08 18:16       ` Markus Elfring
  1 sibling, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2022-03-08  6:26 UTC (permalink / raw)
  To: Eric Wheeler; +Cc: Markus Elfring, cocci



On Mon, 7 Mar 2022, Eric Wheeler wrote:

> On Mon, 7 Mar 2022, Markus Elfring wrote:
>
> >
> > >> It means there must be a longer SmPL, which is ok, but for my own
> > >> curiosity: is there a shorter form?
>
> > > It might be possible to put a disjunction around only the parameter list,
> > > ie inside the parentheses.
>
> Thanks Julia, that is a great hint!
>
> > How useful would such an SmPL code variant be here actually?
>
> It just makes it more readable.  I always try to avoid duplicate code no
> matter what language I'm writing for.

There is some value to rules that are readable, rather than minimal.

julia

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

* Re: [cocci] Does SmPL for functions with prototype disjunctions need to be complete?
  2022-03-08  1:18     ` Eric Wheeler
  2022-03-08  6:26       ` Julia Lawall
@ 2022-03-08 18:16       ` Markus Elfring
  2022-03-08 21:25         ` Eric Wheeler
  1 sibling, 1 reply; 7+ messages in thread
From: Markus Elfring @ 2022-03-08 18:16 UTC (permalink / raw)
  To: Eric Wheeler; +Cc: Julia Lawall, cocci


> It just makes it more readable.  I always try to avoid duplicate code no
> matter what language I'm writing for.


How do you think about “code” which you would not need to specify at all?

Regards,
Markus


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

* Re: [cocci] Does SmPL for functions with prototype disjunctions need to be complete?
  2022-03-08 18:16       ` Markus Elfring
@ 2022-03-08 21:25         ` Eric Wheeler
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Wheeler @ 2022-03-08 21:25 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

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

On Tue, 8 Mar 2022, Markus Elfring wrote: 
> > It just makes it more readable.  I always try to avoid duplicate code no
> > matter what language I'm writing for.
> 
> 
> How do you think about “code” which you would not need to specify at all?

At the moment my needs are met, but if you think an SmPL notation for this 
would benefit others then of course that would be great.

--
Eric Wheeler



> 
> Regards,
> Markus
> 
> 
> 

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

end of thread, other threads:[~2022-03-08 21:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07  1:55 [cocci] Does SmPL for functions with prototype disjunctions need to be complete? Eric Wheeler
2022-03-07 20:48 ` Julia Lawall
2022-03-07 21:10   ` Markus Elfring
2022-03-08  1:18     ` Eric Wheeler
2022-03-08  6:26       ` Julia Lawall
2022-03-08 18:16       ` Markus Elfring
2022-03-08 21:25         ` Eric Wheeler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.