coccinelle: device_attr_show: simplify patch case
authorJulia Lawall <Julia.Lawall@inria.fr>
Sat, 20 Jan 2024 20:56:11 +0000 (21:56 +0100)
committerJulia Lawall <Julia.Lawall@inria.fr>
Sat, 20 Jan 2024 20:56:11 +0000 (21:56 +0100)
Replacing the final expression argument by ... allows the format
string to have multiple arguments.

It also has the advantage of allowing the change to be recognized as
a change in a single statement, thus avoiding adding unneeded braces.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
scripts/coccinelle/api/device_attr_show.cocci

index 634514937e634ff2482fe74087cb09afe1ab25d8..550d1d2fc02a9b95f453594268f4bf44045808e9 100644 (file)
@@ -34,15 +34,10 @@ expression BUF, SZ, FORMAT, STR;
 ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        <...
-(
        return
--              snprintf(BUF, SZ, FORMAT, STR);
-+              sysfs_emit(BUF, FORMAT, STR);
-|
-       return
--              snprintf(BUF, SZ, STR);
-+              sysfs_emit(BUF, STR);
-)
+-              snprintf(BUF, SZ, FORMAT
++              sysfs_emit(BUF, FORMAT
+                               ,...);
        ...>
 }