All of lore.kernel.org
 help / color / mirror / Atom feed
From: joe@perches.com (Joe Perches)
To: cocci@systeme.lip6.fr
Subject: [Cocci] cocci script to add static to const declarations ?
Date: Wed, 30 Aug 2017 03:49:05 -0700	[thread overview]
Message-ID: <1504090145.2786.16.camel@perches.com> (raw)

Any idea on how to write a cocci script that
looks for const array declarations and adds
static to them only when all the initializers
of the array are constants?

For instance:

    int foo(int bar)
    {
    	    const int baz[] = {1, 2, 3};
    }

could be converted to

    int foo(int bar)
    {
    	    static const int baz[] = {1, 2, 3};
    }

but

    int foo(int bar)
    {
    	    const int baz[] = {1, 2, 3, bar};
    }

would not be converted?

             reply	other threads:[~2017-08-30 10:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 10:49 Joe Perches [this message]
2017-08-30 11:12 ` [Cocci] cocci script to add static to const declarations ? SF Markus Elfring
2017-08-30 11:41 ` Julia Lawall
2017-08-30 11:55   ` Joe Perches
2017-08-30 20:48     ` Julia Lawall
2017-08-30 21:41     ` Julia Lawall
2017-08-30 22:33       ` Joe Perches
2017-08-31  5:04         ` Julia Lawall
2017-08-31 14:22         ` Julia Lawall
2017-08-31 18:11           ` Joe Perches
2017-08-31 19:25             ` Julia Lawall
2017-08-31 20:06               ` Joe Perches
2017-08-30 12:38   ` Joe Perches
2017-08-30 13:02     ` 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=1504090145.2786.16.camel@perches.com \
    --to=joe@perches.com \
    --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.