2010-04-02 01:14:29

by Hartley Sweeten

[permalink] [raw]
Subject: [PATCH] printk.c: remove duplicate const

Noticed during a sparse build.

Signed-off-by: H Hartley Sweeten <[email protected]>

---

diff --git a/kernel/printk.c b/kernel/printk.c
index 75077ad..9abc79c 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1457,7 +1457,7 @@ int kmsg_dump_unregister(struct kmsg_dumper *dumper)
}
EXPORT_SYMBOL_GPL(kmsg_dump_unregister);

-static const char const *kmsg_reasons[] = {
+static const char *kmsg_reasons[] = {
[KMSG_DUMP_OOPS] = "oops",
[KMSG_DUMP_PANIC] = "panic",
[KMSG_DUMP_KEXEC] = "kexec",
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?


2010-04-02 01:20:07

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] printk.c: remove duplicate const

From: H Hartley Sweeten <[email protected]>
Date: Thu, 1 Apr 2010 20:13:27 -0500

> Noticed during a sparse build.
>
> Signed-off-by: H Hartley Sweeten <[email protected]>

Isn't it intentional? The two consts mark different aspects
of the declaration const, both the pointers as well as the
contents pointed to.

2010-04-02 01:28:44

by Hartley Sweeten

[permalink] [raw]
Subject: RE: [PATCH] printk.c: remove duplicate const

On Thursday, April 01, 2010 6:20 PM, David Miller wrote:
> From: H Hartley Sweeten <[email protected]>
> Date: Thu, 1 Apr 2010 20:13:27 -0500
>
>> Noticed during a sparse build.
>>
>> Signed-off-by: H Hartley Sweeten <[email protected]>
>
> Isn't it intentional? The two consts mark different aspects
> of the declaration const, both the pointers as well as the
> contents pointed to.

Isn't that a C++ and not a C feature?

If it is valid in C then I guess the sparse people should be informed.

Regards,
Hartley-

2010-04-02 01:29:49

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] printk.c: remove duplicate const

From: H Hartley Sweeten <[email protected]>
Date: Thu, 1 Apr 2010 20:28:33 -0500

> Isn't that a C++ and not a C feature?

I don't think so.

> If it is valid in C then I guess the sparse people should be informed.

Perhaps.

2010-04-02 01:57:02

by Andres Salomon

[permalink] [raw]
Subject: Re: [PATCH] printk.c: remove duplicate const

On Thu, 01 Apr 2010 18:20:04 -0700 (PDT)
David Miller <[email protected]> wrote:

> From: H Hartley Sweeten <[email protected]>
> Date: Thu, 1 Apr 2010 20:13:27 -0500
>
> > Noticed during a sparse build.
> >
> > Signed-off-by: H Hartley Sweeten <[email protected]>
>
> Isn't it intentional? The two consts mark different aspects
> of the declaration const, both the pointers as well as the
> contents pointed to.


I believe that'd be -

static const char *const kmsg_reasons[]

rather than what was originally in the code -

static const char const *kmsg_reasons[]

Read right-to-left, the first is a constant pointer to a char constant;
the second is a pointer to a constant character constant. I suspect
the first is what was intended.