Re: [PATCH] pinctrl: Cleanup string initializations (char[] instead of char *)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: pgpXdHLnORnAm.pgp
Description: PGP signature


[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux