[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140517212421.GD1046@mithrandir>
Date: Sat, 17 May 2014 23:24:22 +0200
From: Thierry Reding <thierry.reding@...il.com>
To: Manuel Schölling <manuel.schoelling@....de>
Cc: linus.walleij@...aro.org, swarren@...dotorg.org,
linux-kernel@...r.kernel.org, linux-tegra@...r.kernel.org
Subject: Re: [PATCH] pinctrl: Cleanup string initializations (char[] instead
of char *)
On Sat, May 17, 2014 at 04:37:25PM +0200, Manuel Schölling wrote:
[...]
> diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
> index 6545809..43eeb1b 100644
> --- a/drivers/pinctrl/pinctrl-tegra.c
> +++ b/drivers/pinctrl/pinctrl-tegra.c
> @@ -576,7 +576,7 @@ static void tegra_pinconf_config_dbg_show(struct pinctrl_dev *pctldev,
> {
> enum tegra_pinconf_param param = TEGRA_PINCONF_UNPACK_PARAM(config);
> u16 arg = TEGRA_PINCONF_UNPACK_ARG(config);
> - const char *pname = "unknown";
> + const char pname[] = "unknown";
> int i;
>
> for (i = 0; i < ARRAY_SIZE(cfg_params); i++) {
When this hunk is applied, the build fails as follows:
CC drivers/pinctrl/pinctrl-tegra.o
drivers/pinctrl/pinctrl-tegra.c: In function 'tegra_pinconf_config_dbg_show':
drivers/pinctrl/pinctrl-tegra.c:589:4: warning: assignment of read-only location 'pname' [enabled by default]
pname = cfg_params[i].property;
^
drivers/pinctrl/pinctrl-tegra.c:589:10: error: incompatible types when assigning to type 'const char[8]' from type 'const char * const'
pname = cfg_params[i].property;
^
As you can see, pname is used to store a property name and the default
value is set to the static string "unknown" for cases where no matching
parameter is found in cfg_params. However, if a match is found the
default value will be overwritten, so you can't use const char [].
Thierry
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists