diff options
author | Julia Lawall <[email protected]> | 2020-07-26 12:58:26 +0200 |
---|---|---|
committer | Mark Brown <[email protected]> | 2020-07-30 22:38:39 +0100 |
commit | a383308e50244a28fe927b9c1acbe0a963bf186b (patch) | |
tree | 69075a2fd3d1ab94299e828cc91fc253a7ad70e8 /scripts/gdb/linux/modules.py | |
parent | 39473c2cbd6e915abe4dac439f18b770d6ed1c2c (diff) |
ASoC: Intel: drop unnecessary list_empty
list_for_each_entry_safe is able to handle an empty list.
The only effect of avoiding the loop is not initializing the
index variable.
Drop list_empty tests in cases where these variables are not
used.
Note that list_for_each_entry_safe is defined in terms of
list_first_entry, which indicates that it should not be used on an
empty list. But in list_for_each_entry_safe, the element obtained by
list_first_entry is not really accessed, only the address of its
list_head field is compared to the address of the list head, so the
list_first_entry is safe.
The semantic patch that makes this change is as follows (with another
variant for the no brace case): (http://coccinelle.lip6.fr/)
<smpl>
@@
expression x,e;
iterator name list_for_each_entry_safe;
statement S;
identifier i,j;
@@
-if (!(list_empty(x))) {
list_for_each_entry_safe(i,j,x,...) S
- }
... when != i
when != j
(
i = e;
|
? j = e;
)
</smpl>
Signed-off-by: Julia Lawall <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
Diffstat (limited to 'scripts/gdb/linux/modules.py')
0 files changed, 0 insertions, 0 deletions