All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] Bug with '*' to display a match on the subsequent rule.
@ 2022-03-19  1:26 Eric Wheeler
  2022-03-19  8:23 ` Julia Lawall
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Wheeler @ 2022-03-19  1:26 UTC (permalink / raw)
  To: cocci

Hello,

I may have found a bug:

	@ r1 @
	type T;
	identifier I;
	@@
	*T I;

	@ r2 @
	@@
	f()
	{
	}
	+void a(){}

which prints this error:

	init_defs_builtins: /usr/local/coccinelle-git/bin/lib/coccinelle/standard.h
	File "cocci/broken.cocci", line 12, column 0, charpos = 57
	  around = '+',
	  whole content = +void a(){}

but if I remove the '*' or turn it to a '-' then it works:

	@ r1 @
	type T;
	identifier I;
	@@
	-T I;

	@ r2 @
	@@
	f()
	{
	}
	+void a(){}

with the diff:

	--- t.c
	+++ /tmp/cocci-output-6974-08cd95-t.c
	@@ -5,11 +5,13 @@ typedef struct
		int w;
	 } A;
	 
	-A a, b;
	-
	 #define NOMATCH(s1, s2, member) printf(#s1  "." #member "!=" #s2 "." #member);
	 f()
	 {
	 }
	 
	+void a()
	+{
	+}
	+
	 // functions here


Here is the t.c file:

	typedef struct 
	{
		int x, y, z;
		int u, v;
		int w;
	} A;

	A a, b;

	#define NOMATCH(s1, s2, member) printf(#s1  "." #member "!=" #s2 "." #member);
	f()
	{
	}

	// functions here

--
Eric Wheeler

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

* Re: [cocci] Bug with '*' to display a match on the subsequent rule.
  2022-03-19  1:26 [cocci] Bug with '*' to display a match on the subsequent rule Eric Wheeler
@ 2022-03-19  8:23 ` Julia Lawall
  2022-03-19 10:31   ` Markus Elfring
  0 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2022-03-19  8:23 UTC (permalink / raw)
  To: Eric Wheeler; +Cc: cocci



On Fri, 18 Mar 2022, Eric Wheeler wrote:

> Hello,
>
> I may have found a bug:
>
> 	@ r1 @
> 	type T;
> 	identifier I;
> 	@@
> 	*T I;
>
> 	@ r2 @
> 	@@
> 	f()
> 	{
> 	}
> 	+void a(){}
>
> which prints this error:
>
> 	init_defs_builtins: /usr/local/coccinelle-git/bin/lib/coccinelle/standard.h
> 	File "cocci/broken.cocci", line 12, column 0, charpos = 57
> 	  around = '+',
> 	  whole content = +void a(){}

You can't mix * and + in a single semantic patch.  The patch you get would
be strange.  There would be a + for the code that you want to add and a -
for the code that you want to highlight.  If you want to make changes and
find out about some things, then you can use some python code to print out
whatever you wnt.

julia

>
> but if I remove the '*' or turn it to a '-' then it works:
>
> 	@ r1 @
> 	type T;
> 	identifier I;
> 	@@
> 	-T I;
>
> 	@ r2 @
> 	@@
> 	f()
> 	{
> 	}
> 	+void a(){}
>
> with the diff:
>
> 	--- t.c
> 	+++ /tmp/cocci-output-6974-08cd95-t.c
> 	@@ -5,11 +5,13 @@ typedef struct
> 		int w;
> 	 } A;
>
> 	-A a, b;
> 	-
> 	 #define NOMATCH(s1, s2, member) printf(#s1  "." #member "!=" #s2 "." #member);
> 	 f()
> 	 {
> 	 }
>
> 	+void a()
> 	+{
> 	+}
> 	+
> 	 // functions here
>
>
> Here is the t.c file:
>
> 	typedef struct
> 	{
> 		int x, y, z;
> 		int u, v;
> 		int w;
> 	} A;
>
> 	A a, b;
>
> 	#define NOMATCH(s1, s2, member) printf(#s1  "." #member "!=" #s2 "." #member);
> 	f()
> 	{
> 	}
>
> 	// functions here
>
> --
> Eric Wheeler
>

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

* Re: [cocci] Bug with '*' to display a match on the subsequent rule.
  2022-03-19  8:23 ` Julia Lawall
@ 2022-03-19 10:31   ` Markus Elfring
  2022-03-19 17:00     ` Eric Wheeler
  0 siblings, 1 reply; 9+ messages in thread
From: Markus Elfring @ 2022-03-19 10:31 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Eric Wheeler, cocci


> You can't mix * and + in a single semantic patch.  The patch you get would
> be strange.  There would be a + for the code that you want to add and a -
> for the code that you want to highlight.


How do you think to provide a better error message from the Coccinelle software
for a questionable mixture of SmPL data processing indicators?

Regards,
Markus


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

* Re: [cocci] Bug with '*' to display a match on the subsequent rule.
  2022-03-19 10:31   ` Markus Elfring
@ 2022-03-19 17:00     ` Eric Wheeler
  2022-03-19 20:12       ` Julia Lawall
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Wheeler @ 2022-03-19 17:00 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Julia Lawall, cocci

On Sat, 19 Mar 2022, Markus Elfring wrote: 
> > You can't mix * and + in a single semantic patch.  The patch you get would
> > be strange.  There would be a + for the code that you want to add and a -
> > for the code that you want to highlight.
> 
> 
> How do you think to provide a better error message from the Coccinelle software
> for a questionable mixture of SmPL data processing indicators?

Its true, that would be nice.  I spent 20 minutes trying to figure out 
what I had wrong with my SmPL.  I had added the * for debugging and forgot 
about it.  After reducing it down to nothing it became clear that '*' was 
the issue.

A friendly error like "You can't mix * and + in a single semantic patch.  
The patch you get would be strange" would be useful ;)

--
Eric Wheeler



> 
> Regards,
> Markus
> 
> 

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

* Re: [cocci] Bug with '*' to display a match on the subsequent rule.
  2022-03-19 17:00     ` Eric Wheeler
@ 2022-03-19 20:12       ` Julia Lawall
  2022-03-20  7:48         ` [cocci] Improved error handling for mixed SmPL data processing indicators Markus Elfring
  0 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2022-03-19 20:12 UTC (permalink / raw)
  To: Eric Wheeler; +Cc: Markus Elfring, cocci



On Sat, 19 Mar 2022, Eric Wheeler wrote:

> On Sat, 19 Mar 2022, Markus Elfring wrote:
> > > You can't mix * and + in a single semantic patch.  The patch you get would
> > > be strange.  There would be a + for the code that you want to add and a -
> > > for the code that you want to highlight.
> >
> >
> > How do you think to provide a better error message from the Coccinelle software
> > for a questionable mixture of SmPL data processing indicators?
>
> Its true, that would be nice.  I spent 20 minutes trying to figure out
> what I had wrong with my SmPL.  I had added the * for debugging and forgot
> about it.  After reducing it down to nothing it became clear that '*' was
> the issue.
>
> A friendly error like "You can't mix * and + in a single semantic patch.
> The patch you get would be strange" would be useful ;)

This has been fixed.  It resulted from a well intentioned but incorrect
attempt to provide file names and line numbers for this kind of problem,
which resulted in discarding the actual error message.

julia

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

* Re: [cocci] Improved error handling for mixed SmPL data processing indicators
  2022-03-19 20:12       ` Julia Lawall
@ 2022-03-20  7:48         ` Markus Elfring
  2022-03-20  8:50           ` Julia Lawall
  0 siblings, 1 reply; 9+ messages in thread
From: Markus Elfring @ 2022-03-20  7:48 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci, Eric Wheeler

>> A friendly error like "You can't mix * and + in a single semantic patch.
>> The patch you get would be strange" would be useful ;)
> This has been fixed.  It resulted from a well intentioned but incorrect
> attempt to provide file names and line numbers for this kind of problem,
> which resulted in discarding the actual error message.


Does the commit “don't throw away the message for a lexical parse error”
belong to corresponding software adjustments?
https://gitlab.inria.fr/coccinelle/coccinelle/-/commit/43f8e0e3c195870cb43548e5bd350aaa720f2561

How do you think about to add a test case for this issue?

Would you like to achieve any improvements for the software documentation?

* https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/20fdb67f4b20a242f222337e13091115884cf6bb/docs/manual/cocci_syntax.tex#L1207
  https://github.com/coccinelle/coccinelle/blob/ae337fce1512ff15aabc3ad5b6d2e537f97ab62a/docs/manual/cocci_syntax.tex#L1207

* https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/20fdb67f4b20a242f222337e13091115884cf6bb/docs/manual/cocci_syntax.tex#L1095
  https://github.com/coccinelle/coccinelle/blob/ae337fce1512ff15aabc3ad5b6d2e537f97ab62a/docs/manual/cocci_syntax.tex#L1095

Regards,
Markus


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

* Re: [cocci] Improved error handling for mixed SmPL data processing indicators
  2022-03-20  7:48         ` [cocci] Improved error handling for mixed SmPL data processing indicators Markus Elfring
@ 2022-03-20  8:50           ` Julia Lawall
  2022-03-20  9:07             ` Markus Elfring
  2022-03-20 15:30             ` [cocci] Improving descriptions for SmPL data processing indicators? Markus Elfring
  0 siblings, 2 replies; 9+ messages in thread
From: Julia Lawall @ 2022-03-20  8:50 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci, Eric Wheeler

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



On Sun, 20 Mar 2022, Markus Elfring wrote:

> >> A friendly error like "You can't mix * and + in a single semantic patch.
> >> The patch you get would be strange" would be useful ;)
> > This has been fixed.  It resulted from a well intentioned but incorrect
> > attempt to provide file names and line numbers for this kind of problem,
> > which resulted in discarding the actual error message.
>
>
> Does the commit “don't throw away the message for a lexical parse error”
> belong to corresponding software adjustments?
> https://gitlab.inria.fr/coccinelle/coccinelle/-/commit/43f8e0e3c195870cb43548e5bd350aaa720f2561
>
> How do you think about to add a test case for this issue?
>
> Would you like to achieve any improvements for the software documentation?

Th documentation already says that * cannot be mixed with - and +.  What
more do you want?

julia

>
> * https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/20fdb67f4b20a242f222337e13091115884cf6bb/docs/manual/cocci_syntax.tex#L1207
>   https://github.com/coccinelle/coccinelle/blob/ae337fce1512ff15aabc3ad5b6d2e537f97ab62a/docs/manual/cocci_syntax.tex#L1207
>
> * https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/20fdb67f4b20a242f222337e13091115884cf6bb/docs/manual/cocci_syntax.tex#L1095
>   https://github.com/coccinelle/coccinelle/blob/ae337fce1512ff15aabc3ad5b6d2e537f97ab62a/docs/manual/cocci_syntax.tex#L1095
>
> Regards,
> Markus
>
>

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

* Re: [cocci] Improved error handling for mixed SmPL data processing indicators
  2022-03-20  8:50           ` Julia Lawall
@ 2022-03-20  9:07             ` Markus Elfring
  2022-03-20 15:30             ` [cocci] Improving descriptions for SmPL data processing indicators? Markus Elfring
  1 sibling, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2022-03-20  9:07 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci, Eric Wheeler

>> Would you like to achieve any improvements for the software documentation?
> Th documentation already says that * cannot be mixed with - and +.


This information is available.



> What more do you want?


I imagine that tweaks for text formatting and layout adjustments can help
to read corresponding data better.

Regards,
Markus


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

* Re: [cocci] Improving descriptions for SmPL data processing indicators?
  2022-03-20  8:50           ` Julia Lawall
  2022-03-20  9:07             ` Markus Elfring
@ 2022-03-20 15:30             ` Markus Elfring
  1 sibling, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2022-03-20 15:30 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci, Eric Wheeler

>> What more do you want?


I propose to explain SmPL data processing indicators/annotations better by
a corresponding taxonomy.
Will such a documentation approach trigger a different visual representation?

Regards,
Markus


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

end of thread, other threads:[~2022-03-20 15:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-19  1:26 [cocci] Bug with '*' to display a match on the subsequent rule Eric Wheeler
2022-03-19  8:23 ` Julia Lawall
2022-03-19 10:31   ` Markus Elfring
2022-03-19 17:00     ` Eric Wheeler
2022-03-19 20:12       ` Julia Lawall
2022-03-20  7:48         ` [cocci] Improved error handling for mixed SmPL data processing indicators Markus Elfring
2022-03-20  8:50           ` Julia Lawall
2022-03-20  9:07             ` Markus Elfring
2022-03-20 15:30             ` [cocci] Improving descriptions for SmPL data processing indicators? Markus Elfring

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.