Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754290AbbIAAwP (ORCPT ); Mon, 31 Aug 2015 20:52:15 -0400 Received: from mail-qk0-f178.google.com ([209.85.220.178]:33570 "EHLO mail-qk0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752596AbbIAAwO convert rfc822-to-8bit (ORCPT ); Mon, 31 Aug 2015 20:52:14 -0400 MIME-Version: 1.0 In-Reply-To: <1441039312-2961-1-git-send-email-keith.busch@intel.com> References: <1441039312-2961-1-git-send-email-keith.busch@intel.com> Date: Tue, 1 Sep 2015 09:52:13 +0900 X-Google-Sender-Auth: ucYvJf0LUNfz-BFpZq5ZPVyimbI Message-ID: Subject: Re: [PATCH] Regulator: Suppress compiler warnings From: Krzysztof Kozlowski To: Keith Busch Cc: linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2437 Lines: 67 2015-09-01 1:41 GMT+09:00 Keith Busch : > 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. > > Signed-off-by: Keith Busch > --- > drivers/regulator/helpers.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c > index 3bbb326..bb5b22a 100644 > --- a/drivers/regulator/helpers.c > +++ b/drivers/regulator/helpers.c > @@ -30,7 +30,7 @@ > */ > 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? Best regards, Krzysztof > @@ -114,7 +114,7 @@ EXPORT_SYMBOL_GPL(regulator_disable_regmap); > */ > int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev) > { > - unsigned int val; > + unsigned int uninitialized_var(val); > int ret; > > ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); > @@ -453,7 +453,7 @@ EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap); > */ > int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) > { > - unsigned int val; > + unsigned int uninitialized_var(val); > int ret; > > ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val); > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/