2011-07-01 00:22:09

by Greg Dietsche

[permalink] [raw]
Subject: [tip:x86/cleanups] x86, smpboot: Mark names[] array as const

Commit-ID: a5fd117a8fda8621e1ae1bb3b8d55e4c0ebabd94
Gitweb: http://git.kernel.org/tip/a5fd117a8fda8621e1ae1bb3b8d55e4c0ebabd94
Author: Greg Dietsche <[email protected]>
AuthorDate: Thu, 30 Jun 2011 17:31:48 -0500
Committer: H. Peter Anvin <[email protected]>
CommitDate: Thu, 30 Jun 2011 16:44:12 -0700

x86, smpboot: Mark names[] array as const

The array names[] in __inquire_remote_apic is read-only. Make it
explicit by marking as const.

Signed-off-by: Greg Dietsche <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: H. Peter Anvin <[email protected]>
---
arch/x86/kernel/smpboot.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index a3c430b..4dbf60e 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -425,7 +425,7 @@ static void impress_friends(void)
void __inquire_remote_apic(int apicid)
{
unsigned i, regs[] = { APIC_ID >> 4, APIC_LVR >> 4, APIC_SPIV >> 4 };
- char *names[] = { "ID", "VERSION", "SPIV" };
+ const char const *names[] = { "ID", "VERSION", "SPIV" };
int timeout;
u32 status;


2011-07-01 00:25:45

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86, smpboot: Mark names[] array as const

On 06/30/2011 05:21 PM, tip-bot for Greg Dietsche wrote:
> + const char const *names[] = { "ID", "VERSION", "SPIV" };
^^^^^^^^^^^^^^^^

Doesn't make sense, patch removed...

-hpa

2011-07-01 00:41:28

by Greg Dietsche

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86, smpboot: Mark names[] array as const

On Thu, Jun 30, 2011 at 05:25:36PM -0700, H. Peter Anvin wrote:
> On 06/30/2011 05:21 PM, tip-bot for Greg Dietsche wrote:
> > + const char const *names[] = { "ID", "VERSION", "SPIV" };
> ^^^^^^^^^^^^^^^^
>
> Doesn't make sense, patch removed...
>
could you explain a little more? I don't see my mistake.
it compiles and is running on my box currently.

Thanks!
Greg

> -hpa
>

2011-07-01 00:47:26

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86, smpboot: Mark names[] array as const

On 06/30/2011 05:41 PM, Greg Dietsche wrote:
> On Thu, Jun 30, 2011 at 05:25:36PM -0700, H. Peter Anvin wrote:
>> On 06/30/2011 05:21 PM, tip-bot for Greg Dietsche wrote:
>>> + const char const *names[] = { "ID", "VERSION", "SPIV" };
>> ^^^^^^^^^^^^^^^^
>>
>> Doesn't make sense, patch removed...
>>
> could you explain a little more? I don't see my mistake.
> it compiles and is running on my box currently.
>

Those two "const"s are redundant.

-hpa

2011-07-01 01:20:29

by Brian Gerst

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86, smpboot: Mark names[] array as const

On Thu, Jun 30, 2011 at 8:47 PM, H. Peter Anvin <[email protected]> wrote:
> On 06/30/2011 05:41 PM, Greg Dietsche wrote:
>> On Thu, Jun 30, 2011 at 05:25:36PM -0700, H. Peter Anvin wrote:
>>> On 06/30/2011 05:21 PM, tip-bot for Greg Dietsche wrote:
>>>> +   const char const *names[] = { "ID", "VERSION", "SPIV" };
>>>         ^^^^^^^^^^^^^^^^
>>>
>>> Doesn't make sense, patch removed...
>>>
>> could you explain a little more? I don't see my mistake.
>> it compiles and is running on my box currently.
>>

One const is for the strings, the other is for the array of pointers.

--
Brian Gerst

2011-07-01 01:22:02

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [tip:x86/cleanups] x86, smpboot: Mark names[] array as const

On 06/30/2011 06:20 PM, Brian Gerst wrote:
> On Thu, Jun 30, 2011 at 8:47 PM, H. Peter Anvin <[email protected]> wrote:
>> On 06/30/2011 05:41 PM, Greg Dietsche wrote:
>>> On Thu, Jun 30, 2011 at 05:25:36PM -0700, H. Peter Anvin wrote:
>>>> On 06/30/2011 05:21 PM, tip-bot for Greg Dietsche wrote:
>>>>> + const char const *names[] = { "ID", "VERSION", "SPIV" };
>>>> ^^^^^^^^^^^^^^^^
>>>>
>>>> Doesn't make sense, patch removed...
>>>>
>>> could you explain a little more? I don't see my mistake.
>>> it compiles and is running on my box currently.
>>>
>
> One const is for the strings, the other is for the array of pointers.
>

Yes, the syntax is wrong for that.

const char * const names[] is I think what he wanted.

-hpa