[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1c1c2888-be50-4578-8afd-bfbe4bd9cbae@baylibre.com>
Date: Thu, 12 Jun 2025 11:06:16 -0500
From: David Lechner <dlechner@...libre.com>
To: kernel test robot <lkp@...el.com>, Andrew Ijano <andrew.ijano@...il.com>,
jic23@...nel.org
Cc: oe-kbuild-all@...ts.linux.dev, andrew.lopes@...mni.usp.br,
gustavobastos@....br, nuno.sa@...log.com, andy@...nel.org,
jstephan@...libre.com, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 3/3] iio: accel: sca3000: use guard(mutex)() for
handling mutex lock
On 6/12/25 10:52 AM, kernel test robot wrote:
> Hi Andrew,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on jic23-iio/togreg]
> [also build test ERROR on linus/master v6.16-rc1 next-20250612]
> [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/Andrew-Ijano/iio-accel-sca3000-replace-error_ret-labels-by-simple-returns/20250612-034940
> base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
> patch link: https://lore.kernel.org/r/20250611194648.18133-4-andrew.lopes%40alumni.usp.br
> patch subject: [PATCH v5 3/3] iio: accel: sca3000: use guard(mutex)() for handling mutex lock
> config: nios2-randconfig-002-20250612 (https://download.01.org/0day-ci/archive/20250612/202506122309.FvJPaMhh-lkp@intel.com/config)
> compiler: nios2-linux-gcc (GCC) 8.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250612/202506122309.FvJPaMhh-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@...el.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202506122309.FvJPaMhh-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> In file included from include/linux/irqflags.h:17,
> from include/asm-generic/bitops.h:14,
> from ./arch/nios2/include/generated/asm/bitops.h:1,
> from include/linux/bitops.h:68,
> from include/linux/kernel.h:23,
> from include/linux/interrupt.h:6,
> from drivers/iio/accel/sca3000.c:10:
> drivers/iio/accel/sca3000.c: In function 'sca3000_read_raw':
>>> include/linux/cleanup.h:258:2: error: a label can only be part of a statement and a declaration is not a statement
> class_##_name##_t var __cleanup(class_##_name##_destructor) = \
> ^~~~~~
> include/linux/cleanup.h:319:2: note: in expansion of macro 'CLASS'
> CLASS(_name, __UNIQUE_ID(guard))
> ^~~~~
> drivers/iio/accel/sca3000.c:699:3: note: in expansion of macro 'guard'
> guard(mutex)(&st->lock);
> ^~~~~
>>> include/linux/cleanup.h:258:2: error: a label can only be part of a statement and a declaration is not a statement
> class_##_name##_t var __cleanup(class_##_name##_destructor) = \
> ^~~~~~
> include/linux/cleanup.h:319:2: note: in expansion of macro 'CLASS'
> CLASS(_name, __UNIQUE_ID(guard))
> ^~~~~
> drivers/iio/accel/sca3000.c:731:3: note: in expansion of macro 'guard'
> guard(mutex)(&st->lock);
> ^~~~~
>>> include/linux/cleanup.h:258:2: error: a label can only be part of a statement and a declaration is not a statement
> class_##_name##_t var __cleanup(class_##_name##_destructor) = \
> ^~~~~~
> include/linux/cleanup.h:319:2: note: in expansion of macro 'CLASS'
> CLASS(_name, __UNIQUE_ID(guard))
> ^~~~~
> drivers/iio/accel/sca3000.c:735:3: note: in expansion of macro 'guard'
> guard(mutex)(&st->lock);
> ^~~~~
> drivers/iio/accel/sca3000.c: In function 'sca3000_write_raw':
> drivers/iio/accel/sca3000.c:748:6: warning: unused variable 'ret' [-Wunused-variable]
> int ret;
> ^~~
> In file included from include/linux/irqflags.h:17,
> from include/asm-generic/bitops.h:14,
> from ./arch/nios2/include/generated/asm/bitops.h:1,
> from include/linux/bitops.h:68,
> from include/linux/kernel.h:23,
> from include/linux/interrupt.h:6,
> from drivers/iio/accel/sca3000.c:10:
> drivers/iio/accel/sca3000.c: In function 'sca3000_read_event_value':
>>> include/linux/cleanup.h:258:2: error: a label can only be part of a statement and a declaration is not a statement
> class_##_name##_t var __cleanup(class_##_name##_destructor) = \
> ^~~~~~
> include/linux/cleanup.h:319:2: note: in expansion of macro 'CLASS'
> CLASS(_name, __UNIQUE_ID(guard))
> ^~~~~
> drivers/iio/accel/sca3000.c:835:3: note: in expansion of macro 'guard'
> guard(mutex)(&st->lock);
> ^~~~~
> drivers/iio/accel/sca3000.c: In function 'sca3000_write_event_value':
> drivers/iio/accel/sca3000.c:881:6: warning: unused variable 'ret' [-Wunused-variable]
> int ret;
> ^~~
> drivers/iio/accel/sca3000.c: In function 'sca3000_write_event_config':
> drivers/iio/accel/sca3000.c:1188:6: warning: unused variable 'ret' [-Wunused-variable]
> int ret;
> ^~~
>
>
> vim +258 include/linux/cleanup.h
>
> 54da6a0924311c Peter Zijlstra 2023-05-26 256
> 54da6a0924311c Peter Zijlstra 2023-05-26 257 #define CLASS(_name, var) \
> 54da6a0924311c Peter Zijlstra 2023-05-26 @258 class_##_name##_t var __cleanup(class_##_name##_destructor) = \
> 54da6a0924311c Peter Zijlstra 2023-05-26 259 class_##_name##_constructor
> 54da6a0924311c Peter Zijlstra 2023-05-26 260
> 54da6a0924311c Peter Zijlstra 2023-05-26 261
>
These error messages aren't particularity helpful, but what I think
this is try to say is that you have to be careful with guard() in
switch statements.
The guard() macro is declaring a new local variable, which shouldn't
be done in a case: statement without enclosing it in a separate scope.
Some compilers complain and some don't so even if it worked for you
locally, we need to make it work for all supported compilers.
So the code needs to looks something like this:
case IIO_CHAN_INFO_SAMP_FREQ: {
guard(mutex)(&st->lock);
ret = sca3000_read_raw_samp_freq(st, val);
return ret ? ret : IIO_VAL_INT;
}
Powered by blists - more mailing lists