[nomadik:ux500-janice-v5.10-rc1 38/51] drivers/iio/magnetometer/yamaha-yas530.c:286:2: warning: variable 'coef' is used uninitialized whenever switch default is taken

kernel test robot lkp at intel.com
Sat Dec 12 14:31:58 EST 2020


tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git ux500-janice-v5.10-rc1
head:   e2561a704fc03cbda012da31198333381b72386d
commit: 757460dad8873d91c4b243b47fbf39514b86b92a [38/51] iio: magnetometer: Add driver for Yamaha YAS530
config: powerpc64-randconfig-r024-20201213 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 84c09ab44599ece409e4e19761288ddf796fceec)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc64 cross compiling tool for clang build
        # apt-get install binutils-powerpc64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git/commit/?id=757460dad8873d91c4b243b47fbf39514b86b92a
        git remote add nomadik https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git
        git fetch --no-tags nomadik ux500-janice-v5.10-rc1
        git checkout 757460dad8873d91c4b243b47fbf39514b86b92a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>

All warnings (new ones prefixed by >>):

>> drivers/iio/magnetometer/yamaha-yas530.c:286:2: warning: variable 'coef' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
           default:
           ^~~~~~~
   drivers/iio/magnetometer/yamaha-yas530.c:299:47: note: uninitialized use occurs here
                   (yas5xx->hard_offsets[axis] - c->r[axis]) * coef;
                                                               ^~~~
   drivers/iio/magnetometer/yamaha-yas530.c:269:10: note: initialize the variable 'coef' to silence this warning
           s32 coef;
                   ^
                    = 0
>> drivers/iio/magnetometer/yamaha-yas530.c:674:6: warning: no previous prototype for function 'yas5xx_dump_calibration' [-Wmissing-prototypes]
   void yas5xx_dump_calibration(struct yas5xx *yas5xx)
        ^
   drivers/iio/magnetometer/yamaha-yas530.c:674:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void yas5xx_dump_calibration(struct yas5xx *yas5xx)
   ^
   static 
   2 warnings generated.

vim +/coef +286 drivers/iio/magnetometer/yamaha-yas530.c

   260	
   261	static s32 yas5xx_linearize(struct yas5xx *yas5xx, u16 val, int axis)
   262	{
   263		struct yas5xx_calibration *c = &yas5xx->calibration;
   264		static const s32 yas532ac_coef[] = {
   265			YAS532_VERSION_AC_COEF_X,
   266			YAS532_VERSION_AC_COEF_Y1,
   267			YAS532_VERSION_AC_COEF_Y2,
   268		};
   269		s32 coef;
   270	
   271		/* Select coefficients */
   272		switch (yas5xx->devid) {
   273		case YAS530_DEVICE_ID:
   274			if (yas5xx->version == YAS530_VERSION_A)
   275				coef = YAS530_VERSION_A_COEF;
   276			else
   277				coef = YAS530_VERSION_B_COEF;
   278			break;
   279		case YAS532_DEVICE_ID:
   280			if (yas5xx->version == YAS532_VERSION_AB)
   281				coef = YAS532_VERSION_AB_COEF;
   282			else
   283				/* Elaborate coefficients */
   284				coef = yas532ac_coef[axis];
   285			break;
 > 286		default:
   287			dev_err(yas5xx->dev, "unknown device type\n");
   288			break;
   289		}
   290		/*
   291		 * Linearization formula:
   292		 *
   293		 * x' = x - (3721 + 50 * f) + (xoffset - r) * c
   294		 *
   295		 * Where f and r are calibration values, c is a per-device
   296		 * and sometimes per-axis coefficient.
   297		 */
   298		return val - (3721 + 50 * c->f[axis]) +
 > 299			(yas5xx->hard_offsets[axis] - c->r[axis]) * coef;
   300	}
   301	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 37694 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20201213/80bac95f/attachment-0001.gz>


More information about the linux-arm-kernel mailing list