Re: [Cocci] Checking the “display” of last two statements in code blocks

2019-04-12 Thread Julia Lawall


On Fri, 12 Apr 2019, Markus Elfring wrote:

> >> @@ -3015,11 +2859,6 @@ static int init_slave(struct gbe_priv *g
> >> }
> >>
> >> if (of_property_read_u32(node, "link-interface",
> >> ->link_interface)) {
> >> -   dev_warn(gbe_dev->dev,
> >> -"missing link-interface value defaulting to 1G 
> >> mac-phy link\n");
> >> -   slave->link_interface = SGMII_LINK_MAC_PHY;
> >> -   }
> >>
> >> slave->node = node;
> >> slave->open = false;
> >> …
> >>
> >>
> >> Now I wonder about the suggested change for the if statement here.
> >> Should any more software adjustments be considered so that it will be 
> >> avoided
> >> to delete only a questionable part from a function call within a condition 
> >> check?
> >
> > I don't understand the problem.
>
> I suggest to take another look at the details in this test result.
>
>
> > You put *s on the { } and two statements, and you get - on the lines
> > that contain the { } and the two statements.
>
> This is the general analysis approach.
>
>
> > Nothing is being deleted anyway.  The -s are just a concise way to
> > indicate the lines on which you requested a match with the *s.
>
> I am using the asterisk functionality of the semantic patch language
> as usual.
>
> These minus characters indicate lines for possible deletions according to
> the diff format, don't they?
>
>
> I doubt that such code can be still compiled after an incomplete
> removal of the shown block would be applied because of the generated
> update suggestion.

The asterisk functionality has no goal of making code that compiles.  It's
goal is to show you the lines of interest.  If you use emacs, you can use
emacs diff mode to jump to those lines in the affected files.

If you want to actually remove the lines, then use - instead of asterisk.
- and + have the goal of making code that compiles.  * does not.

julia___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] Checking the “display” of last two statements in code blocks

2019-04-12 Thread Markus Elfring
>> @@ -3015,11 +2859,6 @@ static int init_slave(struct gbe_priv *g
>> }
>>
>> if (of_property_read_u32(node, "link-interface",
>> ->link_interface)) {
>> -   dev_warn(gbe_dev->dev,
>> -"missing link-interface value defaulting to 1G 
>> mac-phy link\n");
>> -   slave->link_interface = SGMII_LINK_MAC_PHY;
>> -   }
>>
>> slave->node = node;
>> slave->open = false;
>> …
>>
>>
>> Now I wonder about the suggested change for the if statement here.
>> Should any more software adjustments be considered so that it will be avoided
>> to delete only a questionable part from a function call within a condition 
>> check?
>
> I don't understand the problem.

I suggest to take another look at the details in this test result.


> You put *s on the { } and two statements, and you get - on the lines
> that contain the { } and the two statements.

This is the general analysis approach.


> Nothing is being deleted anyway.  The -s are just a concise way to
> indicate the lines on which you requested a match with the *s.

I am using the asterisk functionality of the semantic patch language
as usual.

These minus characters indicate lines for possible deletions according to
the diff format, don't they?


I doubt that such code can be still compiled after an incomplete
removal of the shown block would be applied because of the generated
update suggestion.

Regards,
Markus
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] Checking the “display” of last two statements in code blocks

2019-04-12 Thread Julia Lawall


On Fri, 12 Apr 2019, Markus Elfring wrote:

> Hello,
>
> I have tried another small SmPL script out.
>
>
> @display@
> identifier work;
> statement s1, s2;
> type T;
> @@
>  T work(...)
>  {
>  ... when any
> *{
> ... when any
> *   s1
> *   s2
> *}
>  ... when any
>  }
>
>
> I have observed then that the following diff hunk was generated.
>
>
> elfring@Sonne:~/Projekte/Linux/next-patched> spatch 
> ~/Projekte/Coccinelle/janitor/show_last_two_statements_in_a_block.cocci 
> drivers/net/ethernet/ti/netcp_ethss.c|less
> …
> @@ -3015,11 +2859,6 @@ static int init_slave(struct gbe_priv *g
> }
>
> if (of_property_read_u32(node, "link-interface",
> ->link_interface)) {
> -   dev_warn(gbe_dev->dev,
> -"missing link-interface value defaulting to 1G 
> mac-phy link\n");
> -   slave->link_interface = SGMII_LINK_MAC_PHY;
> -   }
>
> slave->node = node;
> slave->open = false;
> …
>
>
> Now I wonder about the suggested change for the if statement here.
> Should any more software adjustments be considered so that it will be avoided
> to delete only a questionable part from a function call within a condition 
> check?

I don't understand the problem.  You put *s on the { } and two statements,
and you get - on the lines that contain the { } and the two statements.
Nothing is being deleted anyway.  The -s are just a concise way to
indicate the lines on which you requested a match with the *s.  If you
want something more fine grained, use position variables and implement the
display you want in python code.

julia

>
> Regards,
> Markus
> ___
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci