linux-stable/sound/soc/intel
Julia Lawall a383308e50
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 <Julia.Lawall@inria.fr>
Link: https://lore.kernel.org/r/1595761112-11003-2-git-send-email-Julia.Lawall@inria.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-30 22:38:39 +01:00
..
atom ASoC: Intel: drop unnecessary list_empty 2020-07-30 22:38:39 +01:00
baytrail ASoC: intel: use asoc_substream_to_rtd() 2020-07-27 14:00:23 +01:00
boards Merge series "ASoC: meson: tdm fixes" from Jerome Brunet <jbrunet@baylibre.com>: 2020-07-30 21:00:36 +01:00
common Merge series "ASoC: Intel: machine driver updates for 5.9" from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>: 2020-07-20 15:34:31 +01:00
haswell ASoC: intel: use asoc_substream_to_rtd() 2020-07-27 14:00:23 +01:00
keembay ASoC: Intel: KMB: Rework disable channel function 2020-07-30 20:13:41 +01:00
skylake ASoC: Intel: drop unnecessary list_empty 2020-07-30 22:38:39 +01:00
Kconfig ASoC: Intel: Add makefiles and kconfig changes for KeemBay 2020-06-15 19:45:35 +01:00
Makefile ASoC: Intel: Add makefiles and kconfig changes for KeemBay 2020-06-15 19:45:35 +01:00