lkml.org 
[lkml]   [2014]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2014-05-18 00:01    [W:0.032 / U:1.908 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site