On Mon, 22 Feb 2010, Wolfram Sang wrote:

> Hello,
> 
> I have a semantic patch which basically works, but does not produce
> spaces/blank lines as I'd like them. The spatch:
> 
> ===
> 
> @ init @
> type T;
> identifier client, data;
> @@
>         T data = i2c_get_clientdata(client);
> 
> @ main @
> type init.T;
> identifier init.client, init.data;
> statement S,S1;
> @@
> 
>         ... when != S
> +       T data = i2c_get_clientdata(client);
> +       
>         S1
>         ...
> +       i2c_set_clientdata(client, NULL);
> +       kfree(data);
> -       kfree(i2c_get_clientdata(client));
> 
> ===
> 
> produces for the kernel-legacy-eeprom-driver (drivers/misc/eeprom):
> 
> ===
> 
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: eeprom.c
> diff = 
> --- eeprom.c  2010-02-21 02:12:36.000000000 +0100
> +++ /tmp/cocci-output-17399-5d204d-eeprom.c   2010-02-22 08:54:46.000000000 
> +0100
> @@ -208,8 +208,10 @@ exit:
>  
>  static int eeprom_remove(struct i2c_client *client)
>  {
> +     struct eeprom_data * data = i2c_get_clientdata(client);
>       sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
> -     kfree(i2c_get_clientdata(client));
> +     i2c_set_clientdata(client, NULL);
> +     kfree(data);
>  
>       return 0;
>  }
> 
> ===
> 
> Note the missing empty line after the first added line. Also, there is an
> unwanted space after the asterisk. How do I fix those issues?

I can try to fix the space after the * issue.

The missing blank line, however, is more problematic, because there is no 
representation for a blank line in the SmPL abstract syntax.  It might be 
possible to add that as well, though.

> (Side-question: I use V0.2.0. Couldn't I do something in the main-rule like
> 'extends init'? I just get parsing errors when I try to do it)

This is supposed to work.  I will see what happens.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to