All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gargi Sharma <gs051095@gmail.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] Coccinelle Challenge Problem 2
Date: Wed, 22 Feb 2017 00:13:31 +0530	[thread overview]
Message-ID: <CAOCi2DGCD8KvJ6qPyNHh5g1oNKWW+z8dov2dnT1XRO-4Z0y5bQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1702211850270.3448@hadrien>

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

On Tue, Feb 21, 2017 at 11:24 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>
> On Tue, 21 Feb 2017, Gargi Sharma wrote:
>
> > Hi,
> >
> > Here's my coccinelle script to parentheses around the right hand side
of an
> > assignment.
> >
> > @@ expression e, e1, e2; @@
> > e =
> > -(
> >         e1 + e2
> > -)
> >
> > @@ expression e, e1, e2; @@
> > e =
> > -(
> >         e1 - e2
> > -)
> >
> > @@ expression e, e1;
> > contant c; @@
> > e =
> > -(
> >         e1 << c
> > -)
> >
> > @@ expression e, e1;
> > constant c; @@
> > e =
> > -(
> >         e1 >> c
> > -)
>
> It looks reasonable.  I don't think you need to restrict the right side of
> >> and << to constants, though.
>
> Also, the whole thing can actually be much shorter, because there is a
> "binary operator" metavariable type.  So you could say:
>


> @@
> binary operator bop = {+,-,>>,<<};
> expression e, e1, e2;
> @@

Awesome! This makes the patch so much more concise.

>
> e =
> - (
>   e1 bop e2
> - )
>
> Although, your version is probably more readable, because "bop" doesn't
> really look like a binary operator.
>
> Did you try, eg
>
> e =
> - (e1 + e2)
> + e1 + e2
>
> ?  This is not a good solution, but it could be good to think about why.

I tried this after reading this mail :). I think it's not a good solution
because
of the false positives that it will give. Also for the cases where there's
no
space around '+' will be replaced as well which is not the intended use case
for the patch. And all the cases where we have shifted the operands to avoid
the 80 character limit, will all be moved on the same line.

gargi
>
> julia
>
> > thanks,
> > gargi
> >
> > --
> > You received this message because you are subscribed to the Google
Groups
> > "outreachy-kernel" group.
> > To unsubscribe from this group and stop receiving emails from it, send
an
> > email to outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visithttps://groups.google.com
/d/msgid/outreachy-kernel/CAOCi2DHM%2BX0ksQZ2ZBXPk
> > bJu5uv5kerHRpaJaFEG8C36CA72jA%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/ms
gid/outreachy-kernel/alpine.DEB.2.20.1702211850270.3448%40hadrien.
> For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 4533 bytes --]

  reply	other threads:[~2017-02-21 18:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 17:44 Coccinelle Challenge Problem 2 Gargi Sharma
2017-02-21 17:54 ` [Outreachy kernel] " Julia Lawall
2017-02-21 18:43   ` Gargi Sharma [this message]
2017-02-21 20:04     ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOCi2DGCD8KvJ6qPyNHh5g1oNKWW+z8dov2dnT1XRO-4Z0y5bQ@mail.gmail.com \
    --to=gs051095@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.