All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com
Subject: drivers/regulator/mt6357-regulator.c:142:16: warning: shift by negative count ('-1')
Date: Mon, 6 Feb 2023 07:56:57 +0800	[thread overview]
Message-ID: <202302060736.SWiuqZSq-lkp@intel.com> (raw)

:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check warning: drivers/regulator/mt6357-regulator.c:142:16: warning: shift by negative count ('-1') [-Wanalyzer-shift-count-negative]"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Fabien Parent <fparent@baylibre.com>
CC: Mark Brown <broonie@kernel.org>
CC: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
CC: Alexandre Mergnat <amergnat@baylibre.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   4ec5183ec48656cec489c49f989c508b68b518e3
commit: dafc7cde23dca239987d3cd000b11cdccc3728ea regulator: add mt6357 regulator
date:   9 weeks ago
:::::: branch date: 3 hours ago
:::::: commit date: 9 weeks ago
config: arm-randconfig-c002-20230205 (https://download.01.org/0day-ci/archive/20230206/202302060736.SWiuqZSq-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
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/torvalds/linux.git/commit/?id=dafc7cde23dca239987d3cd000b11cdccc3728ea
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout dafc7cde23dca239987d3cd000b11cdccc3728ea
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error'  olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error' 

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

gcc_analyzer warnings: (new ones prefixed by >>)
   drivers/regulator/mt6357-regulator.c: In function 'mt6357_get_buck_voltage_sel':
   drivers/regulator/mt6357-regulator.c:130:18: warning: use of uninitialized value '<unknown>' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
     130 |         int ret, regval;
         |                  ^~~~~~
     'mt6357_get_buck_voltage_sel': event 1
       |
       |  130 |         int ret, regval;
       |      |                  ^~~~~~
       |      |                  |
       |      |                  (1) use of uninitialized value '<unknown>' here
       |
>> drivers/regulator/mt6357-regulator.c:142:16: warning: shift by negative count ('-1') [-Wanalyzer-shift-count-negative]
     142 |         regval >>= ffs(info->da_vsel_mask) - 1;
         |                ^~~
     'mt6357_get_buck_voltage_sel': events 1-4
       |
       |  128 | static int mt6357_get_buck_voltage_sel(struct regulator_dev *rdev)
       |      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |            |
       |      |            (1) entry to 'mt6357_get_buck_voltage_sel'
       |......
       |  134 |         if (ret != 0) {
       |      |            ~
       |      |            |
       |      |            (2) following 'false' branch (when 'ret == 0')...
       |......
       |  141 |         regval &= info->da_vsel_mask;
       |      |         ~~~~~~
       |      |         |
       |      |         (3) ...to here
       |  142 |         regval >>= ffs(info->da_vsel_mask) - 1;
       |      |                    ~~~~~~~~~~~~~~~~~~~~~~~
       |      |                    |
       |      |                    (4) calling 'ffs' from 'mt6357_get_buck_voltage_sel'
       |
       +--> 'ffs': events 5-6
              |
              |include/asm-generic/bitops/ffs.h:13:19:
              |   13 | static inline int ffs(int x)
              |      |                   ^~~
              |      |                   |
              |      |                   (5) entry to 'ffs'
              |......
              |   17 |         if (!x)
              |      |            ~       
              |      |            |
              |      |            (6) following 'true' branch (when 'x == 0')...
              |
            'ffs': event 7
              |
              |cc1:
              | (7): ...to here
              |
       <------+
       |
     'mt6357_get_buck_voltage_sel': events 8-9
       |
       |drivers/regulator/mt6357-regulator.c:142:20:
       |  142 |         regval >>= ffs(info->da_vsel_mask) - 1;
       |      |                ~~~ ^~~~~~~~~~~~~~~~~~~~~~~
       |      |                |   |
       |      |                |   (8) returning to 'mt6357_get_buck_voltage_sel' from 'ffs'
       |      |                (9) shift by negative amount here ('-1')
       |

vim +142 drivers/regulator/mt6357-regulator.c

dafc7cde23dca2 Fabien Parent 2022-11-29  118  
dafc7cde23dca2 Fabien Parent 2022-11-29  119  /**
dafc7cde23dca2 Fabien Parent 2022-11-29  120   * mt6357_get_buck_voltage_sel - get_voltage_sel for regmap users
dafc7cde23dca2 Fabien Parent 2022-11-29  121   *
dafc7cde23dca2 Fabien Parent 2022-11-29  122   * @rdev: regulator to operate on
dafc7cde23dca2 Fabien Parent 2022-11-29  123   *
dafc7cde23dca2 Fabien Parent 2022-11-29  124   * Regulators that use regmap for their register I/O can set the
dafc7cde23dca2 Fabien Parent 2022-11-29  125   * da_vsel_reg and da_vsel_mask fields in the info structure and
dafc7cde23dca2 Fabien Parent 2022-11-29  126   * then use this as their get_voltage_vsel operation.
dafc7cde23dca2 Fabien Parent 2022-11-29  127   */
dafc7cde23dca2 Fabien Parent 2022-11-29  128  static int mt6357_get_buck_voltage_sel(struct regulator_dev *rdev)
dafc7cde23dca2 Fabien Parent 2022-11-29  129  {
dafc7cde23dca2 Fabien Parent 2022-11-29  130  	int ret, regval;
dafc7cde23dca2 Fabien Parent 2022-11-29  131  	struct mt6357_regulator_info *info = rdev_get_drvdata(rdev);
dafc7cde23dca2 Fabien Parent 2022-11-29  132  
dafc7cde23dca2 Fabien Parent 2022-11-29  133  	ret = regmap_read(rdev->regmap, info->da_vsel_reg, &regval);
dafc7cde23dca2 Fabien Parent 2022-11-29  134  	if (ret != 0) {
dafc7cde23dca2 Fabien Parent 2022-11-29  135  		dev_err(&rdev->dev,
dafc7cde23dca2 Fabien Parent 2022-11-29  136  			"Failed to get mt6357 Buck %s vsel reg: %d\n",
dafc7cde23dca2 Fabien Parent 2022-11-29  137  			info->desc.name, ret);
dafc7cde23dca2 Fabien Parent 2022-11-29  138  		return ret;
dafc7cde23dca2 Fabien Parent 2022-11-29  139  	}
dafc7cde23dca2 Fabien Parent 2022-11-29  140  
dafc7cde23dca2 Fabien Parent 2022-11-29  141  	regval &= info->da_vsel_mask;
dafc7cde23dca2 Fabien Parent 2022-11-29 @142  	regval >>= ffs(info->da_vsel_mask) - 1;
dafc7cde23dca2 Fabien Parent 2022-11-29  143  
dafc7cde23dca2 Fabien Parent 2022-11-29  144  	return regval;
dafc7cde23dca2 Fabien Parent 2022-11-29  145  }
dafc7cde23dca2 Fabien Parent 2022-11-29  146  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

             reply	other threads:[~2023-02-05 23:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-05 23:56 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-02-07 17:04 drivers/regulator/mt6357-regulator.c:142:16: warning: shift by negative count ('-1') kernel test robot

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=202302060736.SWiuqZSq-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=oe-kbuild@lists.linux.dev \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.