Skip to content

Commit

Permalink
coccinelle: device_attr_show: simplify patch case
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julia Lawall authored and Julia Lawall committed Jan 20, 2024
1 parent 68ea60a commit ff82e84
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions scripts/coccinelle/api/device_attr_show.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -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
,...);
...>
}

Expand Down

0 comments on commit ff82e84

Please sign in to comment.