On Fri, 9 Mar 2012, Artem Bityutskiy wrote:
[CCing the ML this time]
Hi,
just FYI, spatch does not seem to cope with a ? b : c when wrapping
lines. I've just made the following semantic patch to clean-up some MTD
stuff in the linux kernel:
@@
expression mtd, types, parser_data, parts, nr_parts;
@@
(
-mtd_device_parse_register(mtd, 0, parser_data, parts, nr_parts)
+mtd_device_parse_register(mtd, NULL, parser_data, parts, nr_parts)
|
-mtd_device_parse_register(mtd, types, 0, parts, nr_parts)
+mtd_device_parse_register(mtd, types, NULL, parts, nr_parts)
|
-mtd_device_parse_register(mtd, types, parser_data, 0, nr_parts)
+mtd_device_parse_register(mtd, types, parser_data, NULL, nr_parts)
)
to fix gcc complaints about passing plain 0 instead of NULL.
And I got the following result for one of the drivers:
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index 4a018d0..daf08bd 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -940,13 +940,9 @@ static int __init fsmc_nand_probe(struct platform_device
*pdev)
* Check for partition info passed
*/
host->mtd.name = "nand";
- ret = mtd_device_parse_register(&host->mtd, NULL, 0,
- host->mtd.size <= 0x04000000 ?
- partition_info_16KB_blk :
- partition_info_128KB_blk,
- host->mtd.size <= 0x04000000 ?
- ARRAY_SIZE(partition_info_16KB_blk) :
- ARRAY_SIZE(partition_info_128KB_blk));
+ ret = mtd_device_parse_register(&host->mtd, NULL, NULL,
+ host->mtd.size <= 0x04000000 ?
partition_info_16KB_blk : partition_info_128KB_blk,
+ host->mtd.size <= 0x04000000 ?
ARRAY_SIZE(partition_info_16KB_blk) : ARRAY_SIZE(partition_info_128KB_blk));
if (ret)
goto err_probe;
and checkpatch.pl now complains:
WARNING:LONG_LINE: line over 80 characters
#422: FILE: drivers/mtd/nand/fsmc_nand.c:717:
+ host->mtd.size <= 0x04000000 ?
partition_info_16KB_blk : partition_info_128KB_blk,
This goes beyond the current level of ambition of the pretty printer. It
tries to do something for toplevel arguments, but doesn't try to look
inside. In general, it is safer to avoid reprinting things. You only
want to change 0 to NULL, so you could do the following:
mtd_device_parse_register(mtd,
- 0
+ NULL
, parser_data, parts, nr_parts)
Now all the original spacing will be preserved. There is only a slight
danger because NULL is longer than 0, so that might go past 80 charaters,
and now it won't help you, because the pretty printer doesn't really see
unchanged function calls.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)