cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] How to replace obsolete #ifdef's?
Date: Fri, 7 Jun 2019 20:59:47 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1906072059150.3300@hadrien> (raw)
In-Reply-To: <111faed6-ada9-63d8-b09c-2e6faf678351@web.de>

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



On Fri, 7 Jun 2019, Markus Elfring wrote:

> > Just wrapping the assignment into the macro call turned out to be easy.
>
> I am curious how your transformation approaches will evolve further.
>
>
> > But I haven't found a way to remove the now #ifdef :(
>
> The support for preprocessor functionality is limited by the semantic patch
> language so far.
> Would you like to try another SmPL script variant out?
>
> @replacement@
> constant text;
> expression value;
> identifier my_name;
> type driver_type;
> @@
>  static
>  driver_type
>  my_name = {
>            .driver = {
> -                    .name = text,
> -                    .of_match_table = value,
> -                    },
> +                    .name = text,
> +                    .of_match_table = of_match_ptr(value),

I guess that there is no guarantee that these are the only fields.

julia

> +                    },
>  ...
>            };
>
>
> Do you find the following test result acceptable finally?
>
>
> elfring@Sonne:~/Projekte/Linux/next-patched> spatch ~/Projekte/Coccinelle/Probe/Weigelt8.cocci sound/soc/codecs/pcm3060-i2c.c
> init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
> …
> @@ -45,9 +45,7 @@ MODULE_DEVICE_TABLE(of, pcm3060_of_match
>  static struct i2c_driver pcm3060_i2c_driver = {
>  	.driver = {
>  		.name = "pcm3060",
> -#ifdef CONFIG_OF
> -		.of_match_table = pcm3060_of_match,
> -#endif /* CONFIG_OF */
> +		.of_match_table = of_match_ptr(pcm3060_of_match),
>  	},
>  	.id_table = pcm3060_i2c_id,
>  	.probe = pcm3060_i2c_probe,
>
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

  reply	other threads:[~2019-06-07 19:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05 16:25 [Cocci] how to replace obsolete #ifdef's Enrico Weigelt, metux IT consult
2019-06-05 19:51 ` [Cocci] How to replace obsolete #ifdef's? Markus Elfring
2019-06-05 20:52 ` [Cocci] how to replace obsolete #ifdef's Julia Lawall
2019-06-05 21:42   ` Enrico Weigelt, metux IT consult
2019-06-06  5:46     ` Julia Lawall
2019-06-06  9:30       ` [Cocci] How to replace obsolete #ifdef's? Markus Elfring
2019-06-06 10:34         ` Julia Lawall
2019-06-06 14:20           ` Markus Elfring
2019-06-06 15:34             ` David Young
2019-06-07 12:01           ` Enrico Weigelt, metux IT consult
2019-06-07 12:30             ` Julia Lawall
2019-06-06  9:15     ` Markus Elfring
2019-06-06  9:39       ` Julia Lawall
2019-06-07 12:05         ` Enrico Weigelt, metux IT consult
2019-06-07 12:32           ` Julia Lawall
2019-06-07 13:40             ` Markus Elfring
2019-06-07 16:33               ` Julia Lawall
2019-06-07 17:26                 ` Markus Elfring
2019-06-07 17:36                 ` Markus Elfring
2019-06-07 18:48 ` Markus Elfring
2019-06-07 18:59   ` Julia Lawall [this message]
2019-06-08  7:49   ` [Cocci] Handling of designated initialisers by SmPL? Markus Elfring

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.21.1906072059150.3300@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=Markus.Elfring@web.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).