* [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
@ 2023-08-29 14:23 Andy Shevchenko
2023-08-29 17:50 ` kernel test robot
2023-08-29 19:55 ` kernel test robot
0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-08-29 14:23 UTC (permalink / raw)
To: alsa-devel, linux-kernel; +Cc: Jaroslav Kysela, Takashi Iwai, Andy Shevchenko
Instead of reiterating the list, use list_for_each_entry_safe()
that allows to continue without starting over.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
---
v2: fixed a typo (Jaroslav), added tag (Jaroslav)
sound/core/control_led.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index a78eb48927c7..43ea995c095a 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -297,16 +297,13 @@ static void snd_ctl_led_clean(struct snd_card *card)
{
unsigned int group;
struct snd_ctl_led *led;
- struct snd_ctl_led_ctl *lctl;
+ struct snd_ctl_led_ctl *lctl, _lctl;
for (group = 0; group < MAX_LED; group++) {
led = &snd_ctl_leds[group];
-repeat:
- list_for_each_entry(lctl, &led->controls, list)
- if (!card || lctl->card == card) {
+ list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
+ if (!card || lctl->card == card)
snd_ctl_led_ctl_destroy(lctl);
- goto repeat;
- }
}
}
@@ -314,7 +311,7 @@ static int snd_ctl_led_reset(int card_number, unsigned int group)
{
struct snd_card *card;
struct snd_ctl_led *led;
- struct snd_ctl_led_ctl *lctl;
+ struct snd_ctl_led_ctl *lctl, _lctl;
struct snd_kcontrol_volatile *vd;
bool change = false;
@@ -329,14 +326,12 @@ static int snd_ctl_led_reset(int card_number, unsigned int group)
return -ENXIO;
}
led = &snd_ctl_leds[group];
-repeat:
- list_for_each_entry(lctl, &led->controls, list)
+ list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
if (lctl->card == card) {
vd = &lctl->kctl->vd[lctl->index_offset];
vd->access &= ~group_to_access(group);
snd_ctl_led_ctl_destroy(lctl);
change = true;
- goto repeat;
}
mutex_unlock(&snd_ctl_led_mutex);
if (change)
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
2023-08-29 14:23 [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe() Andy Shevchenko
@ 2023-08-29 17:50 ` kernel test robot
2023-08-29 19:55 ` kernel test robot
1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2023-08-29 17:50 UTC (permalink / raw)
To: Andy Shevchenko, alsa-devel, linux-kernel
Cc: llvm, oe-kbuild-all, Jaroslav Kysela, Takashi Iwai, Andy Shevchenko
Hi Andy,
kernel test robot noticed the following build errors:
[auto build test ERROR on tiwai-sound/for-next]
[also build test ERROR on tiwai-sound/for-linus linus/master v6.5 next-20230829]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/ALSA-control-Use-list_for_each_entry_safe/20230829-222521
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link: https://lore.kernel.org/r/20230829142307.3916823-1-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
config: i386-buildonly-randconfig-001-20230829 (https://download.01.org/0day-ci/archive/20230830/202308300128.l96uIvcS-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230830/202308300128.l96uIvcS-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308300128.l96uIvcS-lkp@intel.com/
All errors (new ones prefixed by >>):
>> sound/core/control_led.c:304:3: error: assigning to 'struct snd_ctl_led_ctl' from incompatible type 'typeof (*(lctl)) *' (aka 'struct snd_ctl_led_ctl *'); dereference with *
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:777:5: note: expanded from macro 'list_for_each_entry_safe'
n = list_next_entry(pos, member); \
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/core/control_led.c:304:3: error: assigning to 'struct snd_ctl_led_ctl *' from incompatible type 'struct snd_ctl_led_ctl'; take the address with &
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^ ~~~~~
&
include/linux/list.h:779:11: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^ ~
>> sound/core/control_led.c:304:3: error: member reference type 'struct snd_ctl_led_ctl' is not a pointer; did you mean to use '.'?
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:18: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:520:15: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
include/linux/container_of.h:19:26: note: expanded from macro 'container_of'
void *__mptr = (void *)(ptr); \
^~~
>> sound/core/control_led.c:304:3: error: member reference type 'struct snd_ctl_led_ctl' is not a pointer; did you mean to use '.'?
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:18: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:520:15: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:338:63: note: expanded from macro '__same_type'
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
^
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
^~~~
>> sound/core/control_led.c:304:3: error: indirection requires pointer operand ('struct snd_ctl_led_ctl' invalid)
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:40: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
include/linux/list.h:520:20: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:338:74: note: expanded from macro '__same_type'
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
^
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
^~~~
>> sound/core/control_led.c:304:3: error: member reference type 'struct snd_ctl_led_ctl' is not a pointer; did you mean to use '.'?
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:18: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:520:15: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:338:63: note: expanded from macro '__same_type'
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
^
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
^~~~
>> sound/core/control_led.c:304:3: error: indirection requires pointer operand ('struct snd_ctl_led_ctl' invalid)
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:40: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
include/linux/list.h:520:20: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
include/linux/container_of.h:23:4: note: expanded from macro 'container_of'
((type *)(__mptr - offsetof(type, member))); })
^~~~
>> sound/core/control_led.c:304:3: error: indirection requires pointer operand ('struct snd_ctl_led_ctl' invalid)
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:40: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
include/linux/list.h:520:20: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
include/linux/container_of.h:23:30: note: expanded from macro 'container_of'
((type *)(__mptr - offsetof(type, member))); })
~~~~~~~~~^~~~~~~~~~~~~
include/linux/stddef.h:16:51: note: expanded from macro 'offsetof'
#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
^~~~
>> sound/core/control_led.c:304:3: error: assigning to 'struct snd_ctl_led_ctl' from incompatible type 'void'
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:18: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/control_led.c:329:2: error: assigning to 'struct snd_ctl_led_ctl' from incompatible type 'typeof (*(lctl)) *' (aka 'struct snd_ctl_led_ctl *'); dereference with *
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:777:5: note: expanded from macro 'list_for_each_entry_safe'
n = list_next_entry(pos, member); \
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/control_led.c:329:2: error: assigning to 'struct snd_ctl_led_ctl *' from incompatible type 'struct snd_ctl_led_ctl'; take the address with &
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^ ~~~~~
&
include/linux/list.h:779:11: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^ ~
sound/core/control_led.c:329:2: error: member reference type 'struct snd_ctl_led_ctl' is not a pointer; did you mean to use '.'?
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:18: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:520:15: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
include/linux/container_of.h:19:26: note: expanded from macro 'container_of'
void *__mptr = (void *)(ptr); \
^~~
sound/core/control_led.c:329:2: error: member reference type 'struct snd_ctl_led_ctl' is not a pointer; did you mean to use '.'?
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:18: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:520:15: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:338:63: note: expanded from macro '__same_type'
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
^
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
^~~~
sound/core/control_led.c:329:2: error: indirection requires pointer operand ('struct snd_ctl_led_ctl' invalid)
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:40: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
include/linux/list.h:520:20: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:338:74: note: expanded from macro '__same_type'
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
^
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
^~~~
sound/core/control_led.c:329:2: error: member reference type 'struct snd_ctl_led_ctl' is not a pointer; did you mean to use '.'?
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:779:20: note: expanded from macro 'list_for_each_entry_safe'
pos = n, n = list_next_entry(n, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:18: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:520:15: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:338:63: note: expanded from macro '__same_type'
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
^
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
^~~~
sound/core/control_led.c:329:2: error: indirection requires pointer operand ('struct snd_ctl_led_ctl' invalid)
vim +304 sound/core/control_led.c
295
296 static void snd_ctl_led_clean(struct snd_card *card)
297 {
298 unsigned int group;
299 struct snd_ctl_led *led;
300 struct snd_ctl_led_ctl *lctl, _lctl;
301
302 for (group = 0; group < MAX_LED; group++) {
303 led = &snd_ctl_leds[group];
> 304 list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
305 if (!card || lctl->card == card)
306 snd_ctl_led_ctl_destroy(lctl);
307 }
308 }
309
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
2023-08-29 14:23 [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe() Andy Shevchenko
2023-08-29 17:50 ` kernel test robot
@ 2023-08-29 19:55 ` kernel test robot
1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2023-08-29 19:55 UTC (permalink / raw)
To: Andy Shevchenko, alsa-devel, linux-kernel
Cc: oe-kbuild-all, Jaroslav Kysela, Takashi Iwai, Andy Shevchenko
Hi Andy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus linus/master v6.5 next-20230829]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/ALSA-control-Use-list_for_each_entry_safe/20230829-222521
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link: https://lore.kernel.org/r/20230829142307.3916823-1-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230830/202308300312.Uq5j7oU2-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230830/202308300312.Uq5j7oU2-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308300312.Uq5j7oU2-lkp@intel.com/
All warnings (new ones prefixed by >>):
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:304:17: note: in expansion of macro 'list_for_each_entry_safe'
304 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:25: error: invalid type argument of '->' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~
include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
include/linux/container_of.h:20:9: note: in expansion of macro 'static_assert'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~~~
include/linux/container_of.h:21:23: note: in expansion of macro '__same_type'
21 | __same_type(*(ptr), void), \
| ^~~~~~~~~~~
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:304:17: note: in expansion of macro 'list_for_each_entry_safe'
304 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:338:27: error: expression in static assertion is not an integer
338 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
include/linux/container_of.h:20:9: note: in expansion of macro 'static_assert'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~~~
include/linux/container_of.h:20:23: note: in expansion of macro '__same_type'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:304:17: note: in expansion of macro 'list_for_each_entry_safe'
304 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:47: error: invalid type argument of unary '*' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~
include/linux/container_of.h:23:11: note: in definition of macro 'container_of'
23 | ((type *)(__mptr - offsetof(type, member))); })
| ^~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:304:17: note: in expansion of macro 'list_for_each_entry_safe'
304 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/uapi/linux/posix_types.h:5,
from include/uapi/linux/types.h:14,
from include/linux/types.h:6,
from include/uapi/linux/sysinfo.h:5,
from include/uapi/linux/kernel.h:5,
from include/linux/cache.h:5,
from include/linux/slab.h:15:
include/linux/list.h:564:47: error: invalid type argument of unary '*' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~
include/linux/stddef.h:16:52: note: in definition of macro 'offsetof'
16 | #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
| ^~~~
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:304:17: note: in expansion of macro 'list_for_each_entry_safe'
304 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/list.h:779:21: warning: left-hand operand of comma expression has no effect [-Wunused-value]
779 | pos = n, n = list_next_entry(n, member))
| ^
sound/core/control_led.c:304:17: note: in expansion of macro 'list_for_each_entry_safe'
304 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
sound/core/control_led.c: In function 'snd_ctl_led_reset':
include/linux/container_of.h:18:41: error: incompatible types when assigning to type 'struct snd_ctl_led_ctl' from type 'struct snd_ctl_led_ctl *'
18 | #define container_of(ptr, type, member) ({ \
| ^
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:777:21: note: in expansion of macro 'list_next_entry'
777 | n = list_next_entry(pos, member); \
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
sound/core/control_led.c:329:40: error: incompatible types when assigning to type 'struct snd_ctl_led_ctl *' from type 'struct snd_ctl_led_ctl'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~
include/linux/list.h:779:20: note: in definition of macro 'list_for_each_entry_safe'
779 | pos = n, n = list_next_entry(n, member))
| ^
include/linux/list.h:564:25: error: invalid type argument of '->' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~
include/linux/container_of.h:19:33: note: in definition of macro 'container_of'
19 | void *__mptr = (void *)(ptr); \
| ^~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:25: error: invalid type argument of '->' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~
include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
include/linux/container_of.h:20:9: note: in expansion of macro 'static_assert'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~~~
include/linux/container_of.h:20:23: note: in expansion of macro '__same_type'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:47: error: invalid type argument of unary '*' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~
include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
include/linux/container_of.h:20:9: note: in expansion of macro 'static_assert'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~~~
include/linux/container_of.h:20:23: note: in expansion of macro '__same_type'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:25: error: invalid type argument of '->' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~
include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
include/linux/container_of.h:20:9: note: in expansion of macro 'static_assert'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~~~
include/linux/container_of.h:21:23: note: in expansion of macro '__same_type'
21 | __same_type(*(ptr), void), \
| ^~~~~~~~~~~
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:338:27: error: expression in static assertion is not an integer
338 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
include/linux/container_of.h:20:9: note: in expansion of macro 'static_assert'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~~~
include/linux/container_of.h:20:23: note: in expansion of macro '__same_type'
20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \
| ^~~~~~~~~~~
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:47: error: invalid type argument of unary '*' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~
include/linux/container_of.h:23:11: note: in definition of macro 'container_of'
23 | ((type *)(__mptr - offsetof(type, member))); })
| ^~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:564:47: error: invalid type argument of unary '*' (have 'struct snd_ctl_led_ctl')
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~
include/linux/stddef.h:16:52: note: in definition of macro 'offsetof'
16 | #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
| ^~~~
include/linux/list.h:520:9: note: in expansion of macro 'container_of'
520 | container_of(ptr, type, member)
| ^~~~~~~~~~~~
include/linux/list.h:564:9: note: in expansion of macro 'list_entry'
564 | list_entry((pos)->member.next, typeof(*(pos)), member)
| ^~~~~~~~~~
include/linux/list.h:779:27: note: in expansion of macro 'list_next_entry'
779 | pos = n, n = list_next_entry(n, member))
| ^~~~~~~~~~~~~~~
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/list.h:779:21: warning: left-hand operand of comma expression has no effect [-Wunused-value]
779 | pos = n, n = list_next_entry(n, member))
| ^
sound/core/control_led.c:329:9: note: in expansion of macro 'list_for_each_entry_safe'
329 | list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
| ^~~~~~~~~~~~~~~~~~~~~~~~
vim +779 include/linux/list.h
4d70c74659d974 Andy Shevchenko 2022-11-30 672
e130816164e244 Andy Shevchenko 2020-10-15 673 /**
e130816164e244 Andy Shevchenko 2020-10-15 674 * list_entry_is_head - test if the entry points to the head of the list
e130816164e244 Andy Shevchenko 2020-10-15 675 * @pos: the type * to cursor
e130816164e244 Andy Shevchenko 2020-10-15 676 * @head: the head for your list.
e130816164e244 Andy Shevchenko 2020-10-15 677 * @member: the name of the list_head within the struct.
e130816164e244 Andy Shevchenko 2020-10-15 678 */
e130816164e244 Andy Shevchenko 2020-10-15 679 #define list_entry_is_head(pos, head, member) \
e130816164e244 Andy Shevchenko 2020-10-15 680 (&pos->member == (head))
e130816164e244 Andy Shevchenko 2020-10-15 681
^1da177e4c3f41 Linus Torvalds 2005-04-16 682 /**
^1da177e4c3f41 Linus Torvalds 2005-04-16 683 * list_for_each_entry - iterate over list of given type
8e3a67a99231f9 Randy Dunlap 2006-06-25 684 * @pos: the type * to use as a loop cursor.
^1da177e4c3f41 Linus Torvalds 2005-04-16 685 * @head: the head for your list.
3943f42c11896c Andrey Utkin 2014-11-14 686 * @member: the name of the list_head within the struct.
^1da177e4c3f41 Linus Torvalds 2005-04-16 687 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 688 #define list_for_each_entry(pos, head, member) \
93be3c2eb3371f Oleg Nesterov 2013-11-12 689 for (pos = list_first_entry(head, typeof(*pos), member); \
e130816164e244 Andy Shevchenko 2020-10-15 690 !list_entry_is_head(pos, head, member); \
8120e2e5141a42 Oleg Nesterov 2013-11-12 691 pos = list_next_entry(pos, member))
^1da177e4c3f41 Linus Torvalds 2005-04-16 692
^1da177e4c3f41 Linus Torvalds 2005-04-16 693 /**
^1da177e4c3f41 Linus Torvalds 2005-04-16 694 * list_for_each_entry_reverse - iterate backwards over list of given type.
8e3a67a99231f9 Randy Dunlap 2006-06-25 695 * @pos: the type * to use as a loop cursor.
^1da177e4c3f41 Linus Torvalds 2005-04-16 696 * @head: the head for your list.
3943f42c11896c Andrey Utkin 2014-11-14 697 * @member: the name of the list_head within the struct.
^1da177e4c3f41 Linus Torvalds 2005-04-16 698 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 699 #define list_for_each_entry_reverse(pos, head, member) \
93be3c2eb3371f Oleg Nesterov 2013-11-12 700 for (pos = list_last_entry(head, typeof(*pos), member); \
e130816164e244 Andy Shevchenko 2020-10-15 701 !list_entry_is_head(pos, head, member); \
8120e2e5141a42 Oleg Nesterov 2013-11-12 702 pos = list_prev_entry(pos, member))
^1da177e4c3f41 Linus Torvalds 2005-04-16 703
^1da177e4c3f41 Linus Torvalds 2005-04-16 704 /**
72fd4a35a82433 Robert P. J. Day 2007-02-10 705 * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
^1da177e4c3f41 Linus Torvalds 2005-04-16 706 * @pos: the type * to use as a start point
^1da177e4c3f41 Linus Torvalds 2005-04-16 707 * @head: the head of the list
3943f42c11896c Andrey Utkin 2014-11-14 708 * @member: the name of the list_head within the struct.
fe96e57d77481c Randy Dunlap 2006-06-25 709 *
72fd4a35a82433 Robert P. J. Day 2007-02-10 710 * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
^1da177e4c3f41 Linus Torvalds 2005-04-16 711 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 712 #define list_prepare_entry(pos, head, member) \
^1da177e4c3f41 Linus Torvalds 2005-04-16 713 ((pos) ? : list_entry(head, typeof(*pos), member))
^1da177e4c3f41 Linus Torvalds 2005-04-16 714
^1da177e4c3f41 Linus Torvalds 2005-04-16 715 /**
fe96e57d77481c Randy Dunlap 2006-06-25 716 * list_for_each_entry_continue - continue iteration over list of given type
8e3a67a99231f9 Randy Dunlap 2006-06-25 717 * @pos: the type * to use as a loop cursor.
^1da177e4c3f41 Linus Torvalds 2005-04-16 718 * @head: the head for your list.
3943f42c11896c Andrey Utkin 2014-11-14 719 * @member: the name of the list_head within the struct.
fe96e57d77481c Randy Dunlap 2006-06-25 720 *
fe96e57d77481c Randy Dunlap 2006-06-25 721 * Continue to iterate over list of given type, continuing after
fe96e57d77481c Randy Dunlap 2006-06-25 722 * the current position.
^1da177e4c3f41 Linus Torvalds 2005-04-16 723 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 724 #define list_for_each_entry_continue(pos, head, member) \
8120e2e5141a42 Oleg Nesterov 2013-11-12 725 for (pos = list_next_entry(pos, member); \
e130816164e244 Andy Shevchenko 2020-10-15 726 !list_entry_is_head(pos, head, member); \
8120e2e5141a42 Oleg Nesterov 2013-11-12 727 pos = list_next_entry(pos, member))
^1da177e4c3f41 Linus Torvalds 2005-04-16 728
768f3591e2b1cc Pavel Emelyanov 2007-09-18 729 /**
768f3591e2b1cc Pavel Emelyanov 2007-09-18 730 * list_for_each_entry_continue_reverse - iterate backwards from the given point
768f3591e2b1cc Pavel Emelyanov 2007-09-18 731 * @pos: the type * to use as a loop cursor.
768f3591e2b1cc Pavel Emelyanov 2007-09-18 732 * @head: the head for your list.
3943f42c11896c Andrey Utkin 2014-11-14 733 * @member: the name of the list_head within the struct.
768f3591e2b1cc Pavel Emelyanov 2007-09-18 734 *
768f3591e2b1cc Pavel Emelyanov 2007-09-18 735 * Start to iterate over list of given type backwards, continuing after
768f3591e2b1cc Pavel Emelyanov 2007-09-18 736 * the current position.
768f3591e2b1cc Pavel Emelyanov 2007-09-18 737 */
768f3591e2b1cc Pavel Emelyanov 2007-09-18 738 #define list_for_each_entry_continue_reverse(pos, head, member) \
8120e2e5141a42 Oleg Nesterov 2013-11-12 739 for (pos = list_prev_entry(pos, member); \
e130816164e244 Andy Shevchenko 2020-10-15 740 !list_entry_is_head(pos, head, member); \
8120e2e5141a42 Oleg Nesterov 2013-11-12 741 pos = list_prev_entry(pos, member))
768f3591e2b1cc Pavel Emelyanov 2007-09-18 742
e229c2fb3370a0 Arnaldo Carvalho de Melo 2006-03-20 743 /**
fe96e57d77481c Randy Dunlap 2006-06-25 744 * list_for_each_entry_from - iterate over list of given type from the current point
8e3a67a99231f9 Randy Dunlap 2006-06-25 745 * @pos: the type * to use as a loop cursor.
e229c2fb3370a0 Arnaldo Carvalho de Melo 2006-03-20 746 * @head: the head for your list.
3943f42c11896c Andrey Utkin 2014-11-14 747 * @member: the name of the list_head within the struct.
fe96e57d77481c Randy Dunlap 2006-06-25 748 *
fe96e57d77481c Randy Dunlap 2006-06-25 749 * Iterate over list of given type, continuing from current position.
e229c2fb3370a0 Arnaldo Carvalho de Melo 2006-03-20 750 */
e229c2fb3370a0 Arnaldo Carvalho de Melo 2006-03-20 751 #define list_for_each_entry_from(pos, head, member) \
e130816164e244 Andy Shevchenko 2020-10-15 752 for (; !list_entry_is_head(pos, head, member); \
8120e2e5141a42 Oleg Nesterov 2013-11-12 753 pos = list_next_entry(pos, member))
e229c2fb3370a0 Arnaldo Carvalho de Melo 2006-03-20 754
b862815c3ee7b4 Jiri Pirko 2017-02-03 755 /**
b862815c3ee7b4 Jiri Pirko 2017-02-03 756 * list_for_each_entry_from_reverse - iterate backwards over list of given type
b862815c3ee7b4 Jiri Pirko 2017-02-03 757 * from the current point
b862815c3ee7b4 Jiri Pirko 2017-02-03 758 * @pos: the type * to use as a loop cursor.
b862815c3ee7b4 Jiri Pirko 2017-02-03 759 * @head: the head for your list.
b862815c3ee7b4 Jiri Pirko 2017-02-03 760 * @member: the name of the list_head within the struct.
b862815c3ee7b4 Jiri Pirko 2017-02-03 761 *
b862815c3ee7b4 Jiri Pirko 2017-02-03 762 * Iterate backwards over list of given type, continuing from current position.
b862815c3ee7b4 Jiri Pirko 2017-02-03 763 */
b862815c3ee7b4 Jiri Pirko 2017-02-03 764 #define list_for_each_entry_from_reverse(pos, head, member) \
e130816164e244 Andy Shevchenko 2020-10-15 765 for (; !list_entry_is_head(pos, head, member); \
b862815c3ee7b4 Jiri Pirko 2017-02-03 766 pos = list_prev_entry(pos, member))
b862815c3ee7b4 Jiri Pirko 2017-02-03 767
^1da177e4c3f41 Linus Torvalds 2005-04-16 768 /**
^1da177e4c3f41 Linus Torvalds 2005-04-16 769 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
8e3a67a99231f9 Randy Dunlap 2006-06-25 770 * @pos: the type * to use as a loop cursor.
^1da177e4c3f41 Linus Torvalds 2005-04-16 771 * @n: another type * to use as temporary storage
^1da177e4c3f41 Linus Torvalds 2005-04-16 772 * @head: the head for your list.
3943f42c11896c Andrey Utkin 2014-11-14 773 * @member: the name of the list_head within the struct.
^1da177e4c3f41 Linus Torvalds 2005-04-16 774 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 775 #define list_for_each_entry_safe(pos, n, head, member) \
93be3c2eb3371f Oleg Nesterov 2013-11-12 776 for (pos = list_first_entry(head, typeof(*pos), member), \
8120e2e5141a42 Oleg Nesterov 2013-11-12 777 n = list_next_entry(pos, member); \
e130816164e244 Andy Shevchenko 2020-10-15 778 !list_entry_is_head(pos, head, member); \
8120e2e5141a42 Oleg Nesterov 2013-11-12 @779 pos = n, n = list_next_entry(n, member))
^1da177e4c3f41 Linus Torvalds 2005-04-16 780
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
2024-04-24 7:24 ` Takashi Iwai
@ 2024-04-24 14:49 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-04-24 14:49 UTC (permalink / raw)
To: Takashi Iwai; +Cc: linux-sound, linux-kernel, Jaroslav Kysela, Takashi Iwai
On Wed, Apr 24, 2024 at 09:24:49AM +0200, Takashi Iwai wrote:
> On Tue, 23 Apr 2024 23:10:22 +0200,
> Andy Shevchenko wrote:
> >
> > Instead of reiterating the list, use list_for_each_entry_safe()
> > that allows to continue without starting over.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reviewed-by: Jaroslav Kysela <perex@perex.cz>
> > ---
> > v2: added tag (Jaroslav)
>
> We have a similar repeat in snd_ctl_led_reset().
> Wouldn't it be better to catch both?
Sure, v3 is on its way.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
2024-04-23 21:10 Andy Shevchenko
@ 2024-04-24 7:24 ` Takashi Iwai
2024-04-24 14:49 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2024-04-24 7:24 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Takashi Iwai, linux-sound, linux-kernel, Jaroslav Kysela, Takashi Iwai
On Tue, 23 Apr 2024 23:10:22 +0200,
Andy Shevchenko wrote:
>
> Instead of reiterating the list, use list_for_each_entry_safe()
> that allows to continue without starting over.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Jaroslav Kysela <perex@perex.cz>
> ---
> v2: added tag (Jaroslav)
We have a similar repeat in snd_ctl_led_reset().
Wouldn't it be better to catch both?
thanks,
Takashi
> sound/core/control_led.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/sound/core/control_led.c b/sound/core/control_led.c
> index 061a8ea23340..ea95405c76a4 100644
> --- a/sound/core/control_led.c
> +++ b/sound/core/control_led.c
> @@ -290,16 +290,13 @@ static void snd_ctl_led_clean(struct snd_card *card)
> {
> unsigned int group;
> struct snd_ctl_led *led;
> - struct snd_ctl_led_ctl *lctl;
> + struct snd_ctl_led_ctl *lctl, *_lctl;
>
> for (group = 0; group < MAX_LED; group++) {
> led = &snd_ctl_leds[group];
> -repeat:
> - list_for_each_entry(lctl, &led->controls, list)
> - if (!card || lctl->card == card) {
> + list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
> + if (!card || lctl->card == card)
> snd_ctl_led_ctl_destroy(lctl);
> - goto repeat;
> - }
> }
> }
>
> --
> 2.43.0.rc1.1336.g36b5255a03ac
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
@ 2024-04-23 21:10 Andy Shevchenko
2024-04-24 7:24 ` Takashi Iwai
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-04-23 21:10 UTC (permalink / raw)
To: Takashi Iwai, linux-sound, linux-kernel
Cc: Jaroslav Kysela, Takashi Iwai, Andy Shevchenko
Instead of reiterating the list, use list_for_each_entry_safe()
that allows to continue without starting over.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
---
v2: added tag (Jaroslav)
sound/core/control_led.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 061a8ea23340..ea95405c76a4 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -290,16 +290,13 @@ static void snd_ctl_led_clean(struct snd_card *card)
{
unsigned int group;
struct snd_ctl_led *led;
- struct snd_ctl_led_ctl *lctl;
+ struct snd_ctl_led_ctl *lctl, *_lctl;
for (group = 0; group < MAX_LED; group++) {
led = &snd_ctl_leds[group];
-repeat:
- list_for_each_entry(lctl, &led->controls, list)
- if (!card || lctl->card == card) {
+ list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
+ if (!card || lctl->card == card)
snd_ctl_led_ctl_destroy(lctl);
- goto repeat;
- }
}
}
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-24 14:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-29 14:23 [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe() Andy Shevchenko
2023-08-29 17:50 ` kernel test robot
2023-08-29 19:55 ` kernel test robot
2024-04-23 21:10 Andy Shevchenko
2024-04-24 7:24 ` Takashi Iwai
2024-04-24 14:49 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.