linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rob Herring <robh@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] acpi: avoid uninialized-variable warning
Date: Wed, 29 Apr 2020 01:08:30 +0300	[thread overview]
Message-ID: <CAHp75VfSny=nSeiCnjE8MwL=hLT92G--9qy6=_0mittzuPxc-A@mail.gmail.com> (raw)
In-Reply-To: <20200428215804.48481-1-arnd@arndb.de>

On Wed, Apr 29, 2020 at 1:03 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> Older compilers like gcc-4.8 produce a bogus warning here
>
> In file included from include/linux/compiler_types.h:68:0,
>                  from <command-line>:0:
> drivers/acpi/property.c: In function 'acpi_data_prop_read':
> include/linux/compiler-gcc.h:75:45: error: 'obj' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>  #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
>                                              ^
> drivers/acpi/property.c:934:27: note: 'obj' was declared here
>   const union acpi_object *obj;
>                            ^
>
> Ensure the output is always initialized even when returning an error
> to avoid the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/acpi/property.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index e601c4511a8b..3aa71daeb0b4 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -587,8 +587,10 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data,
>         int ret, i;
>
>         ret = acpi_data_get_property(data, name, ACPI_TYPE_PACKAGE, &prop);
> -       if (ret)
> +       if (ret && obj) {

It changes semantics and requires obj to be non-NULL.

Should be
if (ret) {
  if (obj)
    *obj = NULL;
  return ret;
}

> +               *obj = NULL;
>                 return ret;
> +       }
>
>         if (type != ACPI_TYPE_ANY) {
>                 /* Check that all elements are of correct type. */
> --
> 2.26.0
>


-- 
With Best Regards,
Andy Shevchenko

      reply	other threads:[~2020-04-28 22:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 21:55 [PATCH] acpi: avoid uninialized-variable warning Arnd Bergmann
2020-04-28 22:08 ` Andy Shevchenko [this message]

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='CAHp75VfSny=nSeiCnjE8MwL=hLT92G--9qy6=_0mittzuPxc-A@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=geert+renesas@glider.be \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tglx@linutronix.de \
    /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 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).