All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/clk/clk-milbeaut.c:297:13: warning: shift by negative count ('-1')
@ 2023-03-17  7:30 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-03-17  7:30 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check first_new_problem: drivers/clk/clk-milbeaut.c:297:13: 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: Arnd Bergmann <arnd@arndb.de>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   38e04b3e4240a6d8fb43129ebad41608db64bc6f
commit: 09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8 ARM: dove: multiplatform support
date:   12 months ago
:::::: branch date: 9 hours ago
:::::: commit date: 12 months ago
config: arm-randconfig-c002-20230316 (https://download.01.org/0day-ci/archive/20230317/202303171533.0nxXg1HO-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=09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8
        # 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>
| Link: https://lore.kernel.org/r/202303171533.0nxXg1HO-lkp@intel.com/

gcc_analyzer warnings: (new ones prefixed by >>)
   drivers/clk/clk-milbeaut.c: In function 'm10v_mux_set_parent':
>> drivers/clk/clk-milbeaut.c:297:13: warning: shift by negative count ('-1') [-Wanalyzer-shift-count-negative]
     297 |         u32 write_en = BIT(fls(mux->mask) - 1);
         |             ^~~~~~~~
     'm10v_mux_set_parent': event 1
       |
       |include/asm-generic/bitops/builtin-fls.h:14:53:
       |   14 |         return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
       |      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
       |      |                                                     |
       |      |                                                     (1) following 'false' branch...
       |
     'm10v_mux_set_parent': event 2
       |
       |drivers/clk/clk-milbeaut.c:297:43:
       |  297 |         u32 write_en = BIT(fls(mux->mask) - 1);
   include/vdso/bits.h:7:44: note: in definition of macro 'BIT'
       |    7 | #define BIT(nr)                 (UL(1) << (nr))
       |      |                                            ^~
       |
     'm10v_mux_set_parent': event 3
       |
       |drivers/clk/clk-milbeaut.c:297:13:
       |  297 |         u32 write_en = BIT(fls(mux->mask) - 1);
       |      |             ^~~~~~~~
       |      |             |
       |      |             (3) shift by negative amount here ('-1')
       |

vim +297 drivers/clk/clk-milbeaut.c

6a6ba5b55a728d Sugaya Taichi 2019-04-25  290  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  291  static int m10v_mux_set_parent(struct clk_hw *hw, u8 index)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  292  {
6a6ba5b55a728d Sugaya Taichi 2019-04-25  293  	struct clk_mux *mux = to_clk_mux(hw);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  294  	u32 val = clk_mux_index_to_val(mux->table, mux->flags, index);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  295  	unsigned long flags = 0;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  296  	u32 reg;
6a6ba5b55a728d Sugaya Taichi 2019-04-25 @297  	u32 write_en = BIT(fls(mux->mask) - 1);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  298  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  299  	if (mux->lock)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  300  		spin_lock_irqsave(mux->lock, flags);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  301  	else
6a6ba5b55a728d Sugaya Taichi 2019-04-25  302  		__acquire(mux->lock);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  303  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  304  	reg = readl(mux->reg);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  305  	reg &= ~(mux->mask << mux->shift);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  306  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  307  	val = (val | write_en) << mux->shift;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  308  	reg |= val;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  309  	writel(reg, mux->reg);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  310  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  311  	if (mux->lock)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  312  		spin_unlock_irqrestore(mux->lock, flags);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  313  	else
6a6ba5b55a728d Sugaya Taichi 2019-04-25  314  		__release(mux->lock);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  315  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  316  	return 0;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  317  }
6a6ba5b55a728d Sugaya Taichi 2019-04-25  318  

:::::: The code at line 297 was first introduced by commit
:::::: 6a6ba5b55a728d819bad598ef5299fa740538dcf clock: milbeaut: Add Milbeaut M10V clock controller

:::::: TO: Sugaya Taichi <sugaya.taichi@socionext.com>
:::::: CC: Stephen Boyd <sboyd@kernel.org>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* drivers/clk/clk-milbeaut.c:297:13: warning: shift by negative count ('-1')
@ 2023-01-20 13:18 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-01-20 13:18 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check first_new_problem: drivers/clk/clk-milbeaut.c:297:13: 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: Arnd Bergmann <arnd@arndb.de>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d368967cb1039b5c4cccb62b5a4b9468c50cd143
commit: 09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8 ARM: dove: multiplatform support
date:   10 months ago
:::::: branch date: 17 hours ago
:::::: commit date: 10 months ago
config: arm-randconfig-c002-20230119 (https://download.01.org/0day-ci/archive/20230120/202301202157.ukmDhYZC-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=09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8
        # 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/clk/clk-milbeaut.c: In function 'm10v_mux_set_parent':
>> drivers/clk/clk-milbeaut.c:297:13: warning: shift by negative count ('-1') [-Wanalyzer-shift-count-negative]
     297 |         u32 write_en = BIT(fls(mux->mask) - 1);
         |             ^~~~~~~~
     'm10v_mux_set_parent': event 1
       |
       |include/asm-generic/bitops/builtin-fls.h:14:53:
       |   14 |         return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
       |      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
       |      |                                                     |
       |      |                                                     (1) following 'false' branch...
       |
     'm10v_mux_set_parent': event 2
       |
       |drivers/clk/clk-milbeaut.c:297:43:
       |  297 |         u32 write_en = BIT(fls(mux->mask) - 1);
   include/vdso/bits.h:7:44: note: in definition of macro 'BIT'
       |    7 | #define BIT(nr)                 (UL(1) << (nr))
       |      |                                            ^~
       |
     'm10v_mux_set_parent': event 3
       |
       |drivers/clk/clk-milbeaut.c:297:13:
       |  297 |         u32 write_en = BIT(fls(mux->mask) - 1);
       |      |             ^~~~~~~~
       |      |             |
       |      |             (3) shift by negative amount here ('-1')
       |
--
     'ap_cpu_clock_probe': events 1-3
       |
       |  230 | static int ap_cpu_clock_probe(struct platform_device *pdev)
       |      |            ^~~~~~~~~~~~~~~~~~
       |      |            |
       |      |            (1) entry to 'ap_cpu_clock_probe'
       |......
       |  240 |         if (IS_ERR(regmap)) {
       |      |            ~
       |      |            |
       |      |            (2) following 'false' branch...
       |......
       |  254 |         nclusters = 1;
       |      |         ~~~~~~~~~
       |      |         |
       |      |         (3) ...to here
       |
     'ap_cpu_clock_probe': event 4
       |
       |include/linux/device.h:224:16:
       |  224 |         return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
       |      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                |
       |      |                (4) calling 'devm_kmalloc_array' from 'ap_cpu_clock_probe'
       |
       +--> 'devm_kmalloc_array': events 5-7
              |
              |  211 | static inline void *devm_kmalloc_array(struct device *dev,
              |      |                     ^~~~~~~~~~~~~~~~~~
              |      |                     |
              |      |                     (5) entry to 'devm_kmalloc_array'
              |......
              |  216 |         if (unlikely(check_mul_overflow(n, size, &bytes)))
              |      |            ~         
              |      |            |
              |      |            (6) following 'false' branch (when '______r == 0')...
              |......
              |  219 |         return devm_kmalloc(dev, bytes, flags);
              |      |         ~~~~~~       
              |      |         |
              |      |         (7) ...to here
              |
       <------+
       |
     'ap_cpu_clock_probe': event 8
       |
       |  224 |         return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
       |      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                |
       |      |                (8) returning to 'ap_cpu_clock_probe' from 'devm_kmalloc_array'
       |
     'ap_cpu_clock_probe': events 9-11
       |
       |drivers/clk/mvebu/ap-cpu-clk.c:277:12:
       |  277 |         if (!ap_cpu_clk)
       |      |            ^
       |      |            |
       |      |            (9) following 'false' branch...
       |......
       |  280 |         ap_cpu_data = devm_kzalloc(dev, struct_size(ap_cpu_data, hws,
       |      |         ~~~~~~~~~~~
       |      |         |
       |      |         (10) ...to here
       |......
       |  283 |         if (!ap_cpu_data)
       |      |            ~
       |      |            |
       |      |            (11) following 'false' branch...
       |
     'ap_cpu_clock_probe': event 12
       |
       |include/linux/of.h:1365:9:
       | 1365 |         for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
       |      |         ^~~
       |      |         |
       |      |         (12) ...to here
   drivers/clk/mvebu/ap-cpu-clk.c:286:9: note: in expansion of macro 'for_each_of_cpu_node'
       |  286 |         for_each_of_cpu_node(dn) {
       |      |         ^~~~~~~~~~~~~~~~~~~~
       |
     'ap_cpu_clock_probe': event 13
       |
       |include/linux/of.h:1365:52:
       | 1365 |         for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
   drivers/clk/mvebu/ap-cpu-clk.c:286:9: note: in expansion of macro 'for_each_of_cpu_node'
       |  286 |         for_each_of_cpu_node(dn) {
       |      |         ^~~~~~~~~~~~~~~~~~~~
       |
     'ap_cpu_clock_probe': events 14-15
       |
       |  287 |                 char *clk_name = "cpu-cluster-0";
       |      |                 ^~~~
       |      |                 |
       |      |                 (14) ...to here
       |......
       |  291 |                 int cpu, err;
       |      |                     ~~~
       |      |                     |
       |      |                     (15) use of uninitialized value '<unknown>' here
       |
>> drivers/clk/mvebu/ap-cpu-clk.c:313:30: warning: write to string literal [-Wanalyzer-write-to-string-literal]
     313 |                 clk_name[12] += cluster_index;
         |                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
     'ap_cpu_clock_probe': events 1-3
       |
       |  230 | static int ap_cpu_clock_probe(struct platform_device *pdev)
       |      |            ^~~~~~~~~~~~~~~~~~
       |      |            |
       |      |            (1) entry to 'ap_cpu_clock_probe'
       |......
       |  240 |         if (IS_ERR(regmap)) {
       |      |            ~
       |      |            |
       |      |            (2) following 'false' branch...
       |......
       |  254 |         nclusters = 1;
       |      |         ~~~~~~~~~
       |      |         |
       |      |         (3) ...to here
       |
     'ap_cpu_clock_probe': event 4
       |
       |include/linux/device.h:224:16:
       |  224 |         return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
       |      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                |
       |      |                (4) calling 'devm_kmalloc_array' from 'ap_cpu_clock_probe'
       |
       +--> 'devm_kmalloc_array': events 5-7
              |
              |  211 | static inline void *devm_kmalloc_array(struct device *dev,
              |      |                     ^~~~~~~~~~~~~~~~~~
              |      |                     |
              |      |                     (5) entry to 'devm_kmalloc_array'
              |......
              |  216 |         if (unlikely(check_mul_overflow(n, size, &bytes)))
              |      |            ~         
              |      |            |
              |      |            (6) following 'false' branch (when '______r == 0')...
              |......
              |  219 |         return devm_kmalloc(dev, bytes, flags);
              |      |         ~~~~~~       
              |      |         |
              |      |         (7) ...to here
              |
       <------+
       |
     'ap_cpu_clock_probe': event 8
       |
       |  224 |         return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
       |      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                |
       |      |                (8) returning to 'ap_cpu_clock_probe' from 'devm_kmalloc_array'
       |
     'ap_cpu_clock_probe': events 9-11
       |
       |drivers/clk/mvebu/ap-cpu-clk.c:277:12:
       |  277 |         if (!ap_cpu_clk)
       |      |            ^
       |      |            |
       |      |            (9) following 'false' branch...
       |......
       |  280 |         ap_cpu_data = devm_kzalloc(dev, struct_size(ap_cpu_data, hws,
       |      |         ~~~~~~~~~~~
       |      |         |
       |      |         (10) ...to here
       |......
       |  283 |         if (!ap_cpu_data)
       |      |            ~
       |      |            |
       |      |            (11) following 'false' branch...
       |
     'ap_cpu_clock_probe': event 12
       |
       |include/linux/of.h:1365:9:
       | 1365 |         for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
       |      |         ^~~
       |      |         |
       |      |         (12) ...to here
   drivers/clk/mvebu/ap-cpu-clk.c:286:9: note: in expansion of macro 'for_each_of_cpu_node'
       |  286 |         for_each_of_cpu_node(dn) {
       |      |         ^~~~~~~~~~~~~~~~~~~~
       |
     'ap_cpu_clock_probe': event 13
       |
       |include/linux/of.h:1365:52:
       | 1365 |         for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
   drivers/clk/mvebu/ap-cpu-clk.c:286:9: note: in expansion of macro 'for_each_of_cpu_node'
       |  286 |         for_each_of_cpu_node(dn) {
       |      |         ^~~~~~~~~~~~~~~~~~~~
       |
     'ap_cpu_clock_probe': events 14-21
       |
       |  287 |                 char *clk_name = "cpu-cluster-0";
       |      |                 ^~~~
       |      |                 |
       |      |                 (14) ...to here
       |......
       |  294 |                 if (WARN_ON(err)) {
       |      |                    ~
       |      |                    |

vim +297 drivers/clk/clk-milbeaut.c

6a6ba5b55a728d Sugaya Taichi 2019-04-25  290  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  291  static int m10v_mux_set_parent(struct clk_hw *hw, u8 index)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  292  {
6a6ba5b55a728d Sugaya Taichi 2019-04-25  293  	struct clk_mux *mux = to_clk_mux(hw);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  294  	u32 val = clk_mux_index_to_val(mux->table, mux->flags, index);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  295  	unsigned long flags = 0;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  296  	u32 reg;
6a6ba5b55a728d Sugaya Taichi 2019-04-25 @297  	u32 write_en = BIT(fls(mux->mask) - 1);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  298  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  299  	if (mux->lock)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  300  		spin_lock_irqsave(mux->lock, flags);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  301  	else
6a6ba5b55a728d Sugaya Taichi 2019-04-25  302  		__acquire(mux->lock);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  303  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  304  	reg = readl(mux->reg);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  305  	reg &= ~(mux->mask << mux->shift);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  306  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  307  	val = (val | write_en) << mux->shift;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  308  	reg |= val;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  309  	writel(reg, mux->reg);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  310  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  311  	if (mux->lock)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  312  		spin_unlock_irqrestore(mux->lock, flags);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  313  	else
6a6ba5b55a728d Sugaya Taichi 2019-04-25  314  		__release(mux->lock);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  315  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  316  	return 0;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  317  }
6a6ba5b55a728d Sugaya Taichi 2019-04-25  318  

:::::: The code at line 297 was first introduced by commit
:::::: 6a6ba5b55a728d819bad598ef5299fa740538dcf clock: milbeaut: Add Milbeaut M10V clock controller

:::::: TO: Sugaya Taichi <sugaya.taichi@socionext.com>
:::::: CC: Stephen Boyd <sboyd@kernel.org>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* drivers/clk/clk-milbeaut.c:297:13: warning: shift by negative count ('-1')
@ 2023-01-20  6:22 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-01-20  6:22 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check first_new_problem: drivers/clk/clk-milbeaut.c:297:13: 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: Arnd Bergmann <arnd@arndb.de>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d368967cb1039b5c4cccb62b5a4b9468c50cd143
commit: 09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8 ARM: dove: multiplatform support
date:   10 months ago
:::::: branch date: 10 hours ago
:::::: commit date: 10 months ago
config: arm-randconfig-c002-20230119 (https://download.01.org/0day-ci/archive/20230120/202301201449.53BB4W41-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=09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 09f6b27d5ddd9ad0ec096d1b0f8decdacc70f0f8
        # 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/clk/clk-milbeaut.c: In function 'm10v_mux_set_parent':
>> drivers/clk/clk-milbeaut.c:297:13: warning: shift by negative count ('-1') [-Wanalyzer-shift-count-negative]
     297 |         u32 write_en = BIT(fls(mux->mask) - 1);
         |             ^~~~~~~~
     'm10v_mux_set_parent': event 1
       |
       |include/asm-generic/bitops/builtin-fls.h:14:53:
       |   14 |         return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
       |      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
       |      |                                                     |
       |      |                                                     (1) following 'false' branch...
       |
     'm10v_mux_set_parent': event 2
       |
       |drivers/clk/clk-milbeaut.c:297:43:
       |  297 |         u32 write_en = BIT(fls(mux->mask) - 1);
   include/vdso/bits.h:7:44: note: in definition of macro 'BIT'
       |    7 | #define BIT(nr)                 (UL(1) << (nr))
       |      |                                            ^~
       |
     'm10v_mux_set_parent': event 3
       |
       |drivers/clk/clk-milbeaut.c:297:13:
       |  297 |         u32 write_en = BIT(fls(mux->mask) - 1);
       |      |             ^~~~~~~~
       |      |             |
       |      |             (3) shift by negative amount here ('-1')
       |

vim +297 drivers/clk/clk-milbeaut.c

6a6ba5b55a728d Sugaya Taichi 2019-04-25  290  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  291  static int m10v_mux_set_parent(struct clk_hw *hw, u8 index)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  292  {
6a6ba5b55a728d Sugaya Taichi 2019-04-25  293  	struct clk_mux *mux = to_clk_mux(hw);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  294  	u32 val = clk_mux_index_to_val(mux->table, mux->flags, index);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  295  	unsigned long flags = 0;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  296  	u32 reg;
6a6ba5b55a728d Sugaya Taichi 2019-04-25 @297  	u32 write_en = BIT(fls(mux->mask) - 1);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  298  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  299  	if (mux->lock)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  300  		spin_lock_irqsave(mux->lock, flags);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  301  	else
6a6ba5b55a728d Sugaya Taichi 2019-04-25  302  		__acquire(mux->lock);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  303  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  304  	reg = readl(mux->reg);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  305  	reg &= ~(mux->mask << mux->shift);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  306  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  307  	val = (val | write_en) << mux->shift;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  308  	reg |= val;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  309  	writel(reg, mux->reg);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  310  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  311  	if (mux->lock)
6a6ba5b55a728d Sugaya Taichi 2019-04-25  312  		spin_unlock_irqrestore(mux->lock, flags);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  313  	else
6a6ba5b55a728d Sugaya Taichi 2019-04-25  314  		__release(mux->lock);
6a6ba5b55a728d Sugaya Taichi 2019-04-25  315  
6a6ba5b55a728d Sugaya Taichi 2019-04-25  316  	return 0;
6a6ba5b55a728d Sugaya Taichi 2019-04-25  317  }
6a6ba5b55a728d Sugaya Taichi 2019-04-25  318  

:::::: The code at line 297 was first introduced by commit
:::::: 6a6ba5b55a728d819bad598ef5299fa740538dcf clock: milbeaut: Add Milbeaut M10V clock controller

:::::: TO: Sugaya Taichi <sugaya.taichi@socionext.com>
:::::: CC: Stephen Boyd <sboyd@kernel.org>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-17  7:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17  7:30 drivers/clk/clk-milbeaut.c:297:13: warning: shift by negative count ('-1') kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2023-01-20 13:18 kernel test robot
2023-01-20  6:22 kernel test robot

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.