LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Eugen Hristev <eugen.hristev@microchip.com>
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [iio:testing 26/30] drivers/iio/adc/at91-sama5d2_adc.c:722:11: warning: variable 'val' is used uninitialized whenever 'if' condition is false
Date: Tue, 31 Aug 2021 01:57:16 +0800	[thread overview]
Message-ID: <202108310110.gBzcBCjg-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3233 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing
head:   4fd351a1ce67ab1229d392047c3ef8e524dab3dd
commit: 29edec2b98fff8ce5145a8585dfc363564704d14 [26/30] iio: adc: at91-sama5d2_adc: convert to platform specific data structures
config: hexagon-buildonly-randconfig-r004-20210830 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b1fde8a2b681dad2ce0c082a5d6422caa06b0bc)
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
        # https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=29edec2b98fff8ce5145a8585dfc363564704d14
        git remote add iio https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
        git fetch --no-tags iio testing
        git checkout 29edec2b98fff8ce5145a8585dfc363564704d14
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=hexagon 

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

All warnings (new ones prefixed by >>):

>> drivers/iio/adc/at91-sama5d2_adc.c:722:11: warning: variable 'val' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           else if (reg == st->soc_info.platform->layout->YPOSR)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/adc/at91-sama5d2_adc.c:725:7: note: uninitialized use occurs here
           if (!val)
                ^~~
   drivers/iio/adc/at91-sama5d2_adc.c:722:7: note: remove the 'if' if its condition is always true
           else if (reg == st->soc_info.platform->layout->YPOSR)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/adc/at91-sama5d2_adc.c:711:9: note: initialize the variable 'val' to silence this warning
           u32 val;
                  ^
                   = 0
   1 warning generated.


vim +722 drivers/iio/adc/at91-sama5d2_adc.c

   708	
   709	static u16 at91_adc_touch_pos(struct at91_adc_state *st, int reg)
   710	{
   711		u32 val;
   712		u32 scale, result, pos;
   713	
   714		/*
   715		 * to obtain the actual position we must divide by scale
   716		 * and multiply with max, where
   717		 * max = 2^AT91_SAMA5D2_MAX_POS_BITS - 1
   718		 */
   719		/* first half of register is the x or y, second half is the scale */
   720		if (reg == st->soc_info.platform->layout->XPOSR)
   721			val = at91_adc_readl(st, XPOSR);
 > 722		else if (reg == st->soc_info.platform->layout->YPOSR)
   723			val = at91_adc_readl(st, YPOSR);
   724	
   725		if (!val)
   726			dev_dbg(&st->indio_dev->dev, "pos is 0\n");
   727	
   728		pos = val & AT91_SAMA5D2_XYZ_MASK;
   729		result = (pos << AT91_SAMA5D2_MAX_POS_BITS) - pos;
   730		scale = (val >> 16) & AT91_SAMA5D2_XYZ_MASK;
   731		if (scale == 0) {
   732			dev_err(&st->indio_dev->dev, "scale is 0\n");
   733			return 0;
   734		}
   735		result /= scale;
   736	
   737		return result;
   738	}
   739	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35549 bytes --]

                 reply	other threads:[~2021-08-30 17:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202108310110.gBzcBCjg-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=eugen.hristev@microchip.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --subject='Re: [iio:testing 26/30] drivers/iio/adc/at91-sama5d2_adc.c:722:11: warning: variable '\''val'\'' is used uninitialized whenever '\''if'\'' condition is false' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).