Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1216841

Re: [PATCH] Regulator: Suppress compiler warnings

From Mark Brown <broonie@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] Regulator: Suppress compiler warnings
Date 2015-09-01 15:20 +0200
Message-ID <q3TDI-7C5-23@gated-at.bofh.it> (permalink)
References <q3Aro-50w-13@gated-at.bofh.it> <q3I5z-7zX-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, Sep 01, 2015 at 09:52:13AM +0900, Krzysztof Kozlowski wrote:
> 2015-09-01 1:41 GMT+09:00 Keith Busch <keith.busch@intel.com>:
> > Some compilers complain of possible uninitialized variable usage, like
> > the following:

> >   drivers/regulator/helpers.c: In function ‘regulator_get_bypass_regmap’:
> >   drivers/regulator/helpers.c:463:16: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized]

> > The code is safe though, and only uses the variables if they were
> > successfully set, so suppressing the warning with uninitialized_val.

> >  int regulator_is_enabled_regmap(struct regulator_dev *rdev)
> >  {
> > -       unsigned int val;
> > +       unsigned int uninitialized_var(val);
> >         int ret;
> >
> >         ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);

> This is quite common pattern so such work-around should be added to
> many other functions leading to code obfuscation. Which compiler do
> you have in mind?

Right, plus this will shut up valid compiler warnings which is poor
practice anyway.  I'd say this is a bug in the compiler.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] Regulator: Suppress compiler warnings Keith Busch <keith.busch@intel.com> - 2015-08-31 18:50 +0200
  Re: [PATCH] Regulator: Suppress compiler warnings Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2015-09-01 03:00 +0200
    Re: [PATCH] Regulator: Suppress compiler warnings Mark Brown <broonie@kernel.org> - 2015-09-01 15:20 +0200
      Re: [PATCH] Regulator: Suppress compiler warnings Keith Busch <keith.busch@intel.com> - 2015-09-01 20:50 +0200

csiph-web