OK, thanks. Thats is not too surprising, but indeed a bug. Comments and
blank lines are treated differently, because comments should be indented
with the code, while blank lines should not. But the code after the blank
line should have gotten back its normal indentation...
julia
On Mon, 8 Mar 2010, Wolfram Sang wrote:
> > > * Ability to add blank lines using +
> >
> > ACK.
>
> Looks like I was too fast with this one. Using just blank lines, the line
> following the blank line gets modified. I use this spatch:
>
> @ init @
> type T;
> identifier client, data;
> @@
> T data = i2c_get_clientdata(client);
>
> @ main extends init @
> statement S,S1;
> @@
>
> ... when != S
> + T data = i2c_get_clientdata(client);
> +
> S1
> ...
> + i2c_set_clientdata(client, NULL);
> + kfree(data);
> - kfree(i2c_get_clientdata(client));
>
> and the result for
>
> ===
>
> w...@katana:~/Kernel/linux-2.6$ spatch -sp_file /tmp/kfree_clientdata.cocci
> drivers/misc/eeprom/eeprom.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: drivers/misc/eeprom/eeprom.c
> diff =
> --- drivers/misc/eeprom/eeprom.c 2010-03-03 14:53:28.000000000 +0100
> +++ /tmp/cocci-output-28888-6919fe-eeprom.c 2010-03-08 02:36:39.000000000
> +0100
> @@ -208,8 +208,11 @@ exit:
>
> static int eeprom_remove(struct i2c_client *client)
> {
> - sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
> - kfree(i2c_get_clientdata(client));
> + struct eeprom_data *data = i2c_get_clientdata(client);
> +
> +sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
> + i2c_set_clientdata(client, NULL);
> + kfree(data);
>
> return 0;
> }
>
> ===
>
> Note the modifiaction of sysfs_remove_bin_file()-lines. Using just a comment
> works (I just replaced the empty line with a comment in the above spatch):
>
> ===
>
> w...@katana:~/Kernel/linux-2.6$ spatch -sp_file /tmp/kfree_clientdata.cocci
> drivers/misc/eeprom/eeprom.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: drivers/misc/eeprom/eeprom.c
> diff =
> --- drivers/misc/eeprom/eeprom.c 2010-03-03 14:53:28.000000000 +0100
> +++ /tmp/cocci-output-29793-fc1af3-eeprom.c 2010-03-08 02:38:19.000000000
> +0100
> @@ -208,8 +208,11 @@ exit:
>
> static int eeprom_remove(struct i2c_client *client)
> {
> + struct eeprom_data *data = i2c_get_clientdata(client);
> + /* fix blank line */
> sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
> - kfree(i2c_get_clientdata(client));
> + i2c_set_clientdata(client, NULL);
> + kfree(data);
>
> return 0;
> }
>
> ===
>
> Regards,
>
> Wolfram
>
> --
> Pengutronix e.K. | Wolfram Sang |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
>
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)