Re: [PATCH] iio: bmi323: mark bmi323_ext_reg_savestate as maybe unused

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024/10/12 17:11, Julia Lawall wrote:
On Sat, 12 Oct 2024, Su Hui wrote:

When running 'make CC=clang drivers/iio/imu/bmi323/bmi323_core.o', there
is a clang warning as follows:

drivers/iio/imu/bmi323/bmi323_core.c:133:27: error:
variable 'bmi323_ext_reg_savestate' is not needed and will not be emitted
[-Werror,-Wunneeded-internal-declaration]
   133 | static const unsigned int bmi323_ext_reg_savestate[] = {
       |                           ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Mark bmi323_ext_reg_savestate as __maybe_unused to silent this warning.
Why might it be unused?

We only use the size of 'bmi323_ext_reg_savestate[]' not it's value, as shown below :

$ git grep  bmi323_ext_reg_savest drivers/iio/imu/
drivers/iio/imu/bmi323/bmi323_core.c:static const unsigned int bmi323_ext_reg_savestate[] = { drivers/iio/imu/bmi323/bmi323_core.c:   unsigned int ext_reg_settings[ARRAY_SIZE(bmi323_ext_reg_savestate)]; drivers/iio/imu/bmi323/bmi323_core.c:   for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) { drivers/iio/imu/bmi323/bmi323_core.c:   for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) {

And I find some solutions use __maybe_unused to silent this warning. Like this one: 3034983db355 ("drm/amdgpu: Mark mmhub_v1_8_mmea_err_status_reg as __maybe_unused")

Mark this variable to __maybe_unused is  to eliminate clang's warning.
Perhaps it is also possible to mark it as _used:).

Su Hui







[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux