linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used
@ 2021-04-28  0:10 kernel test robot
  2021-04-28  8:43 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2021-04-28  0:10 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: kbuild-all, clang-built-linux, linux-kernel

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e359bce39d9085ab24eaa0bb0778bb5f6894144a
commit: 10c857f063fc63902160755a6e23fa594290c6d3 pinctrl: cherryview: Switch to use intel_pinctrl_get_soc_data()
date:   8 months ago
config: x86_64-randconfig-a005-20210426 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 87fc97169e7901dfe56ca0da0d92da0c02d2ef48)
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 x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10c857f063fc63902160755a6e23fa594290c6d3
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 10c857f063fc63902160755a6e23fa594290c6d3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 

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/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
           const char *dummy;
                       ^
   1 warning generated.


vim +/dummy +1663 drivers/pinctrl/intel/pinctrl-intel.c

a0a5f7661e1c49 Chris Chiu      2019-04-15  1656  
7101e022523bfb Andy Shevchenko 2019-10-22  1657  static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c,
7101e022523bfb Andy Shevchenko 2019-10-22  1658  				  void __iomem *base, unsigned int gpp, u32 saved)
7101e022523bfb Andy Shevchenko 2019-10-22  1659  {
7101e022523bfb Andy Shevchenko 2019-10-22  1660  	const struct intel_community *community = &pctrl->communities[c];
7101e022523bfb Andy Shevchenko 2019-10-22  1661  	const struct intel_padgroup *padgrp = &community->gpps[gpp];
7101e022523bfb Andy Shevchenko 2019-10-22  1662  	struct device *dev = pctrl->dev;
d1bfd0229ec4de Andy Shevchenko 2020-06-10 @1663  	const char *dummy;
d1bfd0229ec4de Andy Shevchenko 2020-06-10  1664  	u32 requested = 0;
d1bfd0229ec4de Andy Shevchenko 2020-06-10  1665  	unsigned int i;
7101e022523bfb Andy Shevchenko 2019-10-22  1666  
e5a4ab6a55e230 Andy Shevchenko 2020-04-13  1667  	if (padgrp->gpio_base == INTEL_GPIO_BASE_NOMAP)
7101e022523bfb Andy Shevchenko 2019-10-22  1668  		return;
7101e022523bfb Andy Shevchenko 2019-10-22  1669  
d1bfd0229ec4de Andy Shevchenko 2020-06-10  1670  	for_each_requested_gpio_in_range(&pctrl->chip, i, padgrp->gpio_base, padgrp->size, dummy)
d1bfd0229ec4de Andy Shevchenko 2020-06-10  1671  		requested |= BIT(i);
d1bfd0229ec4de Andy Shevchenko 2020-06-10  1672  
942c5ea49ffbe2 Andy Shevchenko 2019-10-22  1673  	if (!intel_gpio_update_reg(base + gpp * 4, requested, saved))
7101e022523bfb Andy Shevchenko 2019-10-22  1674  		return;
7101e022523bfb Andy Shevchenko 2019-10-22  1675  
764cfe33517f7c Andy Shevchenko 2019-10-22  1676  	dev_dbg(dev, "restored hostown %u/%u %#08x\n", c, gpp, readl(base + gpp * 4));
7101e022523bfb Andy Shevchenko 2019-10-22  1677  }
7101e022523bfb Andy Shevchenko 2019-10-22  1678  

:::::: The code at line 1663 was first introduced by commit
:::::: d1bfd0229ec4deb53e61f95c050b524152fd0d9e pinctrl: intel: Make use of for_each_requested_gpio_in_range()

:::::: TO: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
:::::: CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

---
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: 32675 bytes --]

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

* Re: drivers/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used
  2021-04-28  0:10 drivers/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used kernel test robot
@ 2021-04-28  8:43 ` Andy Shevchenko
  2021-04-28  8:47   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-04-28  8:43 UTC (permalink / raw)
  To: kernel test robot, Arnd Bergmann, Nick Desaulniers
  Cc: kbuild-all, clang-built-linux, linux-kernel

+Cc: Arnd and Nick

(Seems like a clang bug)

On Wed, Apr 28, 2021 at 08:10:34AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   e359bce39d9085ab24eaa0bb0778bb5f6894144a
> commit: 10c857f063fc63902160755a6e23fa594290c6d3 pinctrl: cherryview: Switch to use intel_pinctrl_get_soc_data()
> date:   8 months ago
> config: x86_64-randconfig-a005-20210426 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 87fc97169e7901dfe56ca0da0d92da0c02d2ef48)
> 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 x86_64 cross compiling tool for clang build
>         # apt-get install binutils-x86-64-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10c857f063fc63902160755a6e23fa594290c6d3
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 10c857f063fc63902160755a6e23fa594290c6d3
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 
> 
> 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/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
>            const char *dummy;
>                        ^
>    1 warning generated.

Seems to me a bug in clang. The variable is used to check if the body of the
loop should be executed or not.

> vim +/dummy +1663 drivers/pinctrl/intel/pinctrl-intel.c
> 
> a0a5f7661e1c49 Chris Chiu      2019-04-15  1656  
> 7101e022523bfb Andy Shevchenko 2019-10-22  1657  static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c,
> 7101e022523bfb Andy Shevchenko 2019-10-22  1658  				  void __iomem *base, unsigned int gpp, u32 saved)
> 7101e022523bfb Andy Shevchenko 2019-10-22  1659  {
> 7101e022523bfb Andy Shevchenko 2019-10-22  1660  	const struct intel_community *community = &pctrl->communities[c];
> 7101e022523bfb Andy Shevchenko 2019-10-22  1661  	const struct intel_padgroup *padgrp = &community->gpps[gpp];
> 7101e022523bfb Andy Shevchenko 2019-10-22  1662  	struct device *dev = pctrl->dev;
> d1bfd0229ec4de Andy Shevchenko 2020-06-10 @1663  	const char *dummy;
> d1bfd0229ec4de Andy Shevchenko 2020-06-10  1664  	u32 requested = 0;
> d1bfd0229ec4de Andy Shevchenko 2020-06-10  1665  	unsigned int i;
> 7101e022523bfb Andy Shevchenko 2019-10-22  1666  
> e5a4ab6a55e230 Andy Shevchenko 2020-04-13  1667  	if (padgrp->gpio_base == INTEL_GPIO_BASE_NOMAP)
> 7101e022523bfb Andy Shevchenko 2019-10-22  1668  		return;
> 7101e022523bfb Andy Shevchenko 2019-10-22  1669  
> d1bfd0229ec4de Andy Shevchenko 2020-06-10  1670  	for_each_requested_gpio_in_range(&pctrl->chip, i, padgrp->gpio_base, padgrp->size, dummy)
> d1bfd0229ec4de Andy Shevchenko 2020-06-10  1671  		requested |= BIT(i);
> d1bfd0229ec4de Andy Shevchenko 2020-06-10  1672  
> 942c5ea49ffbe2 Andy Shevchenko 2019-10-22  1673  	if (!intel_gpio_update_reg(base + gpp * 4, requested, saved))
> 7101e022523bfb Andy Shevchenko 2019-10-22  1674  		return;
> 7101e022523bfb Andy Shevchenko 2019-10-22  1675  
> 764cfe33517f7c Andy Shevchenko 2019-10-22  1676  	dev_dbg(dev, "restored hostown %u/%u %#08x\n", c, gpp, readl(base + gpp * 4));
> 7101e022523bfb Andy Shevchenko 2019-10-22  1677  }
> 7101e022523bfb Andy Shevchenko 2019-10-22  1678  
> 
> :::::: The code at line 1663 was first introduced by commit
> :::::: d1bfd0229ec4deb53e61f95c050b524152fd0d9e pinctrl: intel: Make use of for_each_requested_gpio_in_range()
> 
> :::::: TO: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> :::::: CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org



-- 
With Best Regards,
Andy Shevchenko



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

* Re: drivers/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used
  2021-04-28  8:43 ` Andy Shevchenko
@ 2021-04-28  8:47   ` Andy Shevchenko
  2021-04-30 22:54     ` Nick Desaulniers
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-04-28  8:47 UTC (permalink / raw)
  To: kernel test robot, Arnd Bergmann, Nick Desaulniers
  Cc: kbuild-all, clang-built-linux, linux-kernel

On Wed, Apr 28, 2021 at 11:43:33AM +0300, Andy Shevchenko wrote:
> +Cc: Arnd and Nick
> 
> (Seems like a clang bug)
> 
> On Wed, Apr 28, 2021 at 08:10:34AM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   e359bce39d9085ab24eaa0bb0778bb5f6894144a
> > commit: 10c857f063fc63902160755a6e23fa594290c6d3 pinctrl: cherryview: Switch to use intel_pinctrl_get_soc_data()
> > date:   8 months ago
> > config: x86_64-randconfig-a005-20210426 (attached as .config)
> > compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 87fc97169e7901dfe56ca0da0d92da0c02d2ef48)
> > 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 x86_64 cross compiling tool for clang build
> >         # apt-get install binutils-x86-64-linux-gnu
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10c857f063fc63902160755a6e23fa594290c6d3
> >         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> >         git fetch --no-tags linus master
> >         git checkout 10c857f063fc63902160755a6e23fa594290c6d3
> >         # save the attached .config to linux build tree
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 
> > 
> > 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/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
> >            const char *dummy;
> >                        ^
> >    1 warning generated.
> 
> Seems to me a bug in clang. The variable is used to check if the body of the
> loop should be executed or not.

The only way of make this variable being unused is to avoid the loop being
executed at all. This may be the case iff (mind to f:s) the supplied size
parameter is 0, but how on earth clang can prove it (esp. taking into
consideration that it's not true in real life)?!


> > vim +/dummy +1663 drivers/pinctrl/intel/pinctrl-intel.c
> > 
> > a0a5f7661e1c49 Chris Chiu      2019-04-15  1656  
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1657  static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c,
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1658  				  void __iomem *base, unsigned int gpp, u32 saved)
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1659  {
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1660  	const struct intel_community *community = &pctrl->communities[c];
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1661  	const struct intel_padgroup *padgrp = &community->gpps[gpp];
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1662  	struct device *dev = pctrl->dev;
> > d1bfd0229ec4de Andy Shevchenko 2020-06-10 @1663  	const char *dummy;
> > d1bfd0229ec4de Andy Shevchenko 2020-06-10  1664  	u32 requested = 0;
> > d1bfd0229ec4de Andy Shevchenko 2020-06-10  1665  	unsigned int i;
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1666  
> > e5a4ab6a55e230 Andy Shevchenko 2020-04-13  1667  	if (padgrp->gpio_base == INTEL_GPIO_BASE_NOMAP)
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1668  		return;
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1669  
> > d1bfd0229ec4de Andy Shevchenko 2020-06-10  1670  	for_each_requested_gpio_in_range(&pctrl->chip, i, padgrp->gpio_base, padgrp->size, dummy)
> > d1bfd0229ec4de Andy Shevchenko 2020-06-10  1671  		requested |= BIT(i);
> > d1bfd0229ec4de Andy Shevchenko 2020-06-10  1672  
> > 942c5ea49ffbe2 Andy Shevchenko 2019-10-22  1673  	if (!intel_gpio_update_reg(base + gpp * 4, requested, saved))
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1674  		return;
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1675  
> > 764cfe33517f7c Andy Shevchenko 2019-10-22  1676  	dev_dbg(dev, "restored hostown %u/%u %#08x\n", c, gpp, readl(base + gpp * 4));
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1677  }
> > 7101e022523bfb Andy Shevchenko 2019-10-22  1678  
> > 
> > :::::: The code at line 1663 was first introduced by commit
> > :::::: d1bfd0229ec4deb53e61f95c050b524152fd0d9e pinctrl: intel: Make use of for_each_requested_gpio_in_range()
> > 
> > :::::: TO: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > :::::: CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > 
> > ---
> > 0-DAY CI Kernel Test Service, Intel Corporation
> > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
> 
> 
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: drivers/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used
  2021-04-28  8:47   ` Andy Shevchenko
@ 2021-04-30 22:54     ` Nick Desaulniers
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2021-04-30 22:54 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: kernel test robot, Arnd Bergmann, kbuild-all, clang-built-linux, LKML

On Wed, Apr 28, 2021 at 1:47 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Apr 28, 2021 at 11:43:33AM +0300, Andy Shevchenko wrote:
> > +Cc: Arnd and Nick
> >
> > (Seems like a clang bug)
> >
> > On Wed, Apr 28, 2021 at 08:10:34AM +0800, kernel test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head:   e359bce39d9085ab24eaa0bb0778bb5f6894144a
> > > commit: 10c857f063fc63902160755a6e23fa594290c6d3 pinctrl: cherryview: Switch to use intel_pinctrl_get_soc_data()
> > > date:   8 months ago
> > > config: x86_64-randconfig-a005-20210426 (attached as .config)
> > > compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 87fc97169e7901dfe56ca0da0d92da0c02d2ef48)
> > > 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 x86_64 cross compiling tool for clang build
> > >         # apt-get install binutils-x86-64-linux-gnu
> > >         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10c857f063fc63902160755a6e23fa594290c6d3
> > >         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > >         git fetch --no-tags linus master
> > >         git checkout 10c857f063fc63902160755a6e23fa594290c6d3
> > >         # save the attached .config to linux build tree
> > >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64
> > >
> > > 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/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
> > >            const char *dummy;
> > >                        ^
> > >    1 warning generated.
> >
> > Seems to me a bug in clang. The variable is used to check if the body of the
> > loop should be executed or not.
>
> The only way of make this variable being unused is to avoid the loop being
> executed at all. This may be the case iff (mind to f:s) the supplied size
> parameter is 0, but how on earth clang can prove it (esp. taking into
> consideration that it's not true in real life)?!

Yep, the patch that enabled support for this warning in clang was
reported after multiple reports from projects; I'm working on helping
the author revise it based on cases it still flags from the kernel.
-- 
Thanks,
~Nick Desaulniers

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

end of thread, other threads:[~2021-04-30 22:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28  0:10 drivers/pinctrl/intel/pinctrl-intel.c:1663:14: warning: variable 'dummy' set but not used kernel test robot
2021-04-28  8:43 ` Andy Shevchenko
2021-04-28  8:47   ` Andy Shevchenko
2021-04-30 22:54     ` Nick Desaulniers

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).