Skip to contentSkip to conversation

x86/MCE: drop bogus const modifier from AMD's bank4_names()

PATCH Applied Jan Beulich 3 participants 5 messages Jan 23, 2015 x86

lore
Share & tools
lore
#0 lore raw

The compiler validly warns about it being ignored.

---
 arch/x86/kernel/cpu/mcheck/mce_amd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +1 -1
@@ -79,7 +79,7 @@ static inline bool is_shared_bank(int ba
 	return (bank == 4);
 }
 
-static const char * const bank4_names(struct threshold_block *b)
+static const char *bank4_names(const struct threshold_block *b)
 {
 	switch (b->address) {
 	/* MSR4_MISC0 */
maintainer Applied
#1 lore raw
Quoted 3 lines · Jan Beulich

The compiler validly warns about it being ignored.

Applied, thanks.

Out of curiosity: When do you see this? Building with -Wignored-qualifiers or -Wextra?

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#2 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 23.01.15 at 10:58, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich

The compiler validly warns about it being ignored.

Applied, thanks.

Out of curiosity: When do you see this? Building with -Wignored-qualifiers or -Wextra?

It's been a long while ago that I noticed and fixed the warning, so I don't recall the details. What I do know is that I didn't force any extra flags, and that a similar issue elsewhere in the tree (fixed in 3.19-rc5) triggered the same warning in at least one of my builds (again without any extra warning options) in -rc4.

Jan

maintainer
#3 lore raw
Quoted 5 lines · Jan Beulich

It's been a long while ago that I noticed and fixed the warning, so I don't recall the details. What I do know is that I didn't force any extra flags, and that a similar issue elsewhere in the tree (fixed in 3.19-rc5) triggered the same warning in at least one of my builds (again without any extra warning options) in -rc4.

Older compiler maybe. Not that it is worth wasting too much time on it though...

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#4 lore raw

Jan Beulich wrote, On 01/23/2015 09:32 AM:

arch/x86/kernel/cpu/mcheck/mce_amd.c static inline bool is_shared_bank(int ba · line 82

Quoted 3 lines
arch/x86/kernel/cpu/mcheck/mce_amd.c +1 -1
-static const char * const bank4_names(struct threshold_block *b)
+static const char *bank4_names(const struct threshold_block *b)

There is a big difference in the return type, cf. below. Of course, if possible, the more const the better.

Borislav Petkov wrote, On 01/23/2015 11:16 AM:

Quoted 9 lines · Jan Beulich
Quoted 5 lines

It's been a long while ago that I noticed and fixed the warning, so I don't recall the details. What I do know is that I didn't force any extra flags, and that a similar issue elsewhere in the tree (fixed in 3.19-rc5) triggered the same warning in at least one of my builds (again without any extra warning options) in -rc4.

Older compiler maybe. Not that it is worth wasting too much time on it though...

int main()
{
char mem1[] = "foo";
char mem2[] = "bar";

const char* const p1 = mem1; // both ptr and content are const
const char* p2 = mem2; // content is const, but not the ptr

// ++p1; // not possible b/c p1 is const
++p2; // possible b/c p2 is not const

// *p1 = 'X'; // not possible b/c content of p1 is const
// *p2 = 'A'; // not possible b/c content of p2 is const

return 0;
}

cu
Uenal