All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	Kukjin Kim <kgene@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Maciej Purski <m.purski@samsung.com>,
	linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] thermal: exynos_tmu: avoid uninitialized variables
Date: Wed, 28 Mar 2018 15:44:44 +0200	[thread overview]
Message-ID: <20180328134520.1970967-1-arnd@arndb.de> (raw)

Removing the initialization in the error case introduced
a compile-time warning:

drivers/thermal/samsung/exynos_tmu.c: In function 'temp_to_code':
drivers/thermal/samsung/exynos_tmu.c:304:9: error: 'temp_code' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  return temp_code;
         ^~~~~~~~~
drivers/thermal/samsung/exynos_tmu.c: In function 'exynos_get_temp':
drivers/thermal/samsung/exynos_tmu.c:931:37: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   *temp = code_to_temp(data, value) * MCELSIUS;

Let's assume the runtime warning is sufficient, and make it
return a well-defined number instead of unintialized data.

Fixes: 480b5bfc16e1 ("thermal: exynos: remove parsing of samsung, tmu_default_temp_offset property")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/thermal/samsung/exynos_tmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 2ec854851da1..7e351fffdaee 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -298,6 +298,7 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 		break;
 	default:
 		WARN_ON(1);
+		temp_code = 0;
 		break;
 	}
 
@@ -324,6 +325,7 @@ static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)
 		break;
 	default:
 		WARN_ON(1);
+		temp = 0;
 		break;
 	}
 
-- 
2.9.0

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	Kukjin Kim <kgene@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-samsung-soc@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Maciej Purski <m.purski@samsung.com>,
	linux-arm-kernel@lists.infradead.org,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: [PATCH] thermal: exynos_tmu: avoid uninitialized variables
Date: Wed, 28 Mar 2018 15:44:44 +0200	[thread overview]
Message-ID: <20180328134520.1970967-1-arnd@arndb.de> (raw)

Removing the initialization in the error case introduced
a compile-time warning:

drivers/thermal/samsung/exynos_tmu.c: In function 'temp_to_code':
drivers/thermal/samsung/exynos_tmu.c:304:9: error: 'temp_code' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  return temp_code;
         ^~~~~~~~~
drivers/thermal/samsung/exynos_tmu.c: In function 'exynos_get_temp':
drivers/thermal/samsung/exynos_tmu.c:931:37: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   *temp = code_to_temp(data, value) * MCELSIUS;

Let's assume the runtime warning is sufficient, and make it
return a well-defined number instead of unintialized data.

Fixes: 480b5bfc16e1 ("thermal: exynos: remove parsing of samsung, tmu_default_temp_offset property")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/thermal/samsung/exynos_tmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 2ec854851da1..7e351fffdaee 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -298,6 +298,7 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 		break;
 	default:
 		WARN_ON(1);
+		temp_code = 0;
 		break;
 	}
 
@@ -324,6 +325,7 @@ static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)
 		break;
 	default:
 		WARN_ON(1);
+		temp = 0;
 		break;
 	}
 
-- 
2.9.0

WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] thermal: exynos_tmu: avoid uninitialized variables
Date: Wed, 28 Mar 2018 15:44:44 +0200	[thread overview]
Message-ID: <20180328134520.1970967-1-arnd@arndb.de> (raw)

Removing the initialization in the error case introduced
a compile-time warning:

drivers/thermal/samsung/exynos_tmu.c: In function 'temp_to_code':
drivers/thermal/samsung/exynos_tmu.c:304:9: error: 'temp_code' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  return temp_code;
         ^~~~~~~~~
drivers/thermal/samsung/exynos_tmu.c: In function 'exynos_get_temp':
drivers/thermal/samsung/exynos_tmu.c:931:37: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   *temp = code_to_temp(data, value) * MCELSIUS;

Let's assume the runtime warning is sufficient, and make it
return a well-defined number instead of unintialized data.

Fixes: 480b5bfc16e1 ("thermal: exynos: remove parsing of samsung, tmu_default_temp_offset property")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/thermal/samsung/exynos_tmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 2ec854851da1..7e351fffdaee 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -298,6 +298,7 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 		break;
 	default:
 		WARN_ON(1);
+		temp_code = 0;
 		break;
 	}
 
@@ -324,6 +325,7 @@ static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)
 		break;
 	default:
 		WARN_ON(1);
+		temp = 0;
 		break;
 	}
 
-- 
2.9.0

             reply	other threads:[~2018-03-28 13:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180328134538epcas2p4bb7a1f273824995e4baeb10d9563ffda@epcas2p4.samsung.com>
2018-03-28 13:44 ` Arnd Bergmann [this message]
2018-03-28 13:44   ` [PATCH] thermal: exynos_tmu: avoid uninitialized variables Arnd Bergmann
2018-03-28 13:44   ` Arnd Bergmann
2018-03-28 13:56   ` Bartlomiej Zolnierkiewicz
2018-03-28 13:56     ` Bartlomiej Zolnierkiewicz

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=20180328134520.1970967-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=b.zolnierkie@samsung.com \
    --cc=edubezval@gmail.com \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.purski@samsung.com \
    --cc=m.szyprowski@samsung.com \
    --cc=rui.zhang@intel.com \
    /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.