All of lore.kernel.org
 help / color / mirror / Atom feed
From: lars@metafoo.de (Lars-Peter Clausen)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Unwanted space added at end of line
Date: Sat, 22 Sep 2012 16:43:22 +0200	[thread overview]
Message-ID: <505DCE8A.9050403@metafoo.de> (raw)
In-Reply-To: <1348302555.11590.8.camel@ice-age.regit.org>

On 09/22/2012 10:29 AM, Eric Leblond wrote:
> Hello,
> 
> I've just wrote a really simple SMPL (attached to the mail). It makes a
> modification on the code which is the following:
> 
> - if (x == NULL) S1
> + if (unlikely(x == NULL)) S1
> 
> The result is semantically correct but there is spaces at end of line as
> shown in the example below:
> 
> @@ -173,8 +173,8 @@ DefragContextNew(void)
>      DefragContext *dc;
>  
>      dc = SCCalloc(1, sizeof(*dc));
> -    if (dc == NULL)
> -        return NULL;<- no space
> +    if (unlikely(dc == NULL))
> +        return NULL;   <- 4 space here 
> 
> I've tried to look at coccinelle code but I'm unable to find a way to a
> solution.

A simple solution is to take the statment out of the diff. It is generally a
good idea to try to minimize the parts which are removed in one line but added
back in the next line since everything in the plus part of the diff will be
send through the pretty printer which may cause the code to be re-formatted

E.g. in your case a minimized cocci patch could look like this:

if (
+unlikely(
 x == NULL
+)
 ) S1

- Lars

  reply	other threads:[~2012-09-22 14:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-22  8:29 [Cocci] Unwanted space added at end of line Eric Leblond
2012-09-22 14:43 ` Lars-Peter Clausen [this message]
2012-09-22 17:08 ` Julia Lawall
2012-09-22 22:27   ` Eric Leblond
2012-09-23  5:47     ` Julia Lawall
2012-09-23  9:24     ` Julia Lawall
2012-09-23 15:07       ` Eric Leblond
2012-09-23 15:14         ` Julia Lawall
2012-09-23 20:55           ` [Cocci] Clarification of work flows with content management systems SF Markus Elfring
2012-09-23 22:09             ` Jesper Louis Andersen

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=505DCE8A.9050403@metafoo.de \
    --to=lars@metafoo.de \
    --cc=cocci@systeme.lip6.fr \
    /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.