mtd: mxc_nand: Fix sparse warning

Submitted by Fabio Estevam on Feb. 11, 2013, 3:51 p.m.

Details

Message ID 1360597903-10378-1-git-send-email-festevam@gmail.com
State New, archived
Headers show

Commit Message

Fabio Estevam Feb. 11, 2013, 3:51 p.m.
From: Fabio Estevam <fabio.estevam@freescale.com>

Fix the following sparse warning:

drivers/mtd/nand/mxc_nand.c:269:25: warning: duplicate const

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/mtd/nand/mxc_nand.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ezequiel Garcia Feb. 12, 2013, 2:39 a.m.
Hi Fabio,

On Mon, Feb 11, 2013 at 12:51 PM, Fabio Estevam <festevam@gmail.com> wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Fix the following sparse warning:
>
> drivers/mtd/nand/mxc_nand.c:269:25: warning: duplicate const
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/mtd/nand/mxc_nand.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> index 45204e4..37037cb 100644
> --- a/drivers/mtd/nand/mxc_nand.c
> +++ b/drivers/mtd/nand/mxc_nand.c
> @@ -266,7 +266,7 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
>         }
>  };
>
> -static const char const *part_probes[] = {
> +static const char *part_probes[] = {
>         "cmdlinepart", "RedBoot", "ofpart", NULL };
>

Are you sure checkpatch.pl didn't complain about this patch?
I think it will complain, because it's expecting to see this instead:

  static const char * const part_probes[] = {

And then you'll probably have to cast part_probes to (const char **)
on the mtd_device_parse_register call to remove every warning.

Hope this helps,
Fabio Estevam Feb. 12, 2013, 8:50 p.m.
Hi Ezequiel,

On Tue, Feb 12, 2013 at 12:39 AM, Ezequiel Garcia <elezegarcia@gmail.com> wrote:

>> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
>> index 45204e4..37037cb 100644
>> --- a/drivers/mtd/nand/mxc_nand.c
>> +++ b/drivers/mtd/nand/mxc_nand.c
>> @@ -266,7 +266,7 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
>>         }
>>  };
>>
>> -static const char const *part_probes[] = {
>> +static const char *part_probes[] = {
>>         "cmdlinepart", "RedBoot", "ofpart", NULL };
>>
>
> Are you sure checkpatch.pl didn't complain about this patch?

Yes, checkpatch complains, but it seems that checkpatch and sparse are
in contradiction then.

Regards,

Fabio Estevam
Ezequiel Garcia Feb. 13, 2013, 8:40 a.m.
Hi Fabio,

On Tue, Feb 12, 2013 at 5:50 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Tue, Feb 12, 2013 at 12:39 AM, Ezequiel Garcia <elezegarcia@gmail.com> wrote:
>
>>> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
>>> index 45204e4..37037cb 100644
>>> --- a/drivers/mtd/nand/mxc_nand.c
>>> +++ b/drivers/mtd/nand/mxc_nand.c
>>> @@ -266,7 +266,7 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
>>>         }
>>>  };
>>>
>>> -static const char const *part_probes[] = {
>>> +static const char *part_probes[] = {
>>>         "cmdlinepart", "RedBoot", "ofpart", NULL };
>>>
>>
>> Are you sure checkpatch.pl didn't complain about this patch?
>
> Yes, checkpatch complains, but it seems that checkpatch and sparse are
> in contradiction then.
>

Well it doesn't seem in contradiction to me. You fixed a redundant
double const:

-static const char const *part_probes[] = {
+static const char *part_probes[] = {
        "cmdlinepart", "RedBoot", "ofpart", NULL };

Notice how the 'const char const' type is nonesense.
And checkpatch.pl will suggest you this in turn:

static const char * const part_probes[] = {
        "cmdlinepart", "RedBoot", "ofpart", NULL };

Notice how the second 'const' is after the pointer.

My point is, the code you're fixing needs a fix,
just not the fix you were proposing :-)

Hope it helped,

Patch hide | download patch | download mbox

diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 45204e4..37037cb 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -266,7 +266,7 @@  static struct nand_ecclayout nandv2_hw_eccoob_4k = {
 	}
 };
 
-static const char const *part_probes[] = {
+static const char *part_probes[] = {
 	"cmdlinepart", "RedBoot", "ofpart", NULL };
 
 static void memcpy32_fromio(void *trg, const void __iomem  *src, size_t size)