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

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

> > 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
> becauseof 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.

Yes, it's all pretty sad :).  One conclusion is that it is better not to
remove code and then add it back.  When you add it back, Coccinelle takes
over the pretty printing, and Coccinelle is not super smart about pretty
printing binary operators.  It does try to do a good job for function
arguments, though.

But you probably noticed that it was changing things that didn't have
parentheses at all, which may be what you mean by false positives.  This is
because of the idea of an isomorphism.  Coccinelle considers that sometimes
people put parentheses and sometimes they don't.  And it is rather tiresome
to have to specify all of the possibilities by hand.  So if you put an
expression with parentheses that is either all annotated with - or that is
all unannotated, then it will consider the possibility that the parentheses
are not there as well.  You can see all of the patterns it is really trying
with spatch --parse-cocci foo.cocci.  But the way you wrote the rules, the
- was only on the (), so it considers that the parentheses are important,
so there is no problem.

julia

      reply	other threads:[~2017-02-21 20:04 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
2017-02-21 20:04     ` Julia Lawall [this message]

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=alpine.DEB.2.20.1702212059430.2117@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=gs051095@gmail.com \
    --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.