Skip to contentSkip to conversation

x86/msr: Fix build with older GCC versions

PATCH In review Daniel Kiper 4 participants 7 messages Apr 12, 2019 – Apr 19, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/msr: Fix build with older GCC versions

Some older GCC versions produce following error when x86 MSR modules are build:

In file included from commands/i386/rdmsr.c:29:0:
../include/grub/i386/rdmsr.h:27:29: error: no previous prototype for ‘grub_msr_read’ [-Werror=missing-prototypes]
extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)

                               ^

cc1: all warnings being treated as errors

This is due to incorrect use of extern keyword. So, replace it with static keyword.

Additionally, fix incorrect coding style.

---
 include/grub/i386/rdmsr.h | 3 ++-
 include/grub/i386/wrmsr.h | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
include/grub/i386/rdmsr.h +2 -1
index bddb7bbbb..c0a0c717a 100644
@@ -24,7 +24,8 @@
  *       Accessing a reserved or unimplemented MSR address results in a GP#.
  */
 
-extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)
+static inline grub_uint64_t
+grub_msr_read (grub_uint32_t msr_id)
 {
   grub_uint32_t low, high;
 
include/grub/i386/wrmsr.h +2 -1
index e14d7807f..dea60aed1 100644
@@ -24,7 +24,8 @@
  *       Accessing a reserved or unimplemented MSR address results in a GP#.
  */
 
-extern inline void grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value)
+static inline void
+grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value)
 {
   grub_uint32_t low = msr_value, high = msr_value >> 32;
 
Signature · 1 line
2.11.0
#1 lore raw

LGTM.
Just a note: it's a correct usage of extern, just not consistent with rest of codebase and not supported by old gcc

Quoted 53 lines · Daniel Kiper

Some older GCC versions produce following error when x86 MSR modules are build:

In file included from commands/i386/rdmsr.c:29:0:
../include/grub/i386/rdmsr.h:27:29: error: no previous prototype for ‘grub_msr_read’ [-Werror=missing-prototypes]
extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)

                               ^

cc1: all warnings being treated as errors

This is due to incorrect use of extern keyword. So, replace it with static keyword.

Additionally, fix incorrect coding style.

---
 include/grub/i386/rdmsr.h | 3 ++-
 include/grub/i386/wrmsr.h | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
include/grub/i386/rdmsr.h +2 -1
index bddb7bbbb..c0a0c717a 100644
@@ -24,7 +24,8 @@
  *       Accessing a reserved or unimplemented MSR address results in a GP#.
  */
 
-extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)
+static inline grub_uint64_t
+grub_msr_read (grub_uint32_t msr_id)
 {
   grub_uint32_t low, high;
 
include/grub/i386/wrmsr.h +2 -2
index e14d7807f..dea60aed1 100644
@@ -24,7 +24,8 @@
  *       Accessing a reserved or unimplemented MSR address results in a GP#.
  */
 
-extern inline void grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value)
+static inline void
+grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value)
 {
   grub_uint32_t low = msr_value, high = msr_value >> 32;
 
--

2.11.0

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
#2 lore raw
In reply to Daniel Kiper

I confirm this patch applied over 2.04rc1 tag enables me to build grub on my system.
Thank you very much!

adrian15

Quoted 50 lines · Daniel Kiper

Some older GCC versions produce following error when x86 MSR modules are build:

In file included from commands/i386/rdmsr.c:29:0:
../include/grub/i386/rdmsr.h:27:29: error: no previous prototype for ‘grub_msr_read’ [-Werror=missing-prototypes]
extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)

                               ^

cc1: all warnings being treated as errors

This is due to incorrect use of extern keyword. So, replace it with static keyword.

Additionally, fix incorrect coding style.

---
 include/grub/i386/rdmsr.h | 3 ++-
 include/grub/i386/wrmsr.h | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
include/grub/i386/rdmsr.h +2 -1
index bddb7bbbb..c0a0c717a 100644
@@ -24,7 +24,8 @@
  *       Accessing a reserved or unimplemented MSR address results in a GP#.
  */
 
-extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)
+static inline grub_uint64_t
+grub_msr_read (grub_uint32_t msr_id)
 {
   grub_uint32_t low, high;
 
include/grub/i386/wrmsr.h +2 -1
index e14d7807f..dea60aed1 100644
@@ -24,7 +24,8 @@
  *       Accessing a reserved or unimplemented MSR address results in a GP#.
  */
 
-extern inline void grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value)
+static inline void
+grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value)
 {
   grub_uint32_t low = msr_value, high = msr_value >> 32;
 
Signature · 2 lines
Support free software. Donate to Super Grub Disk. Apoya el software
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
#3 lore raw
Quoted 3 lines · On Sat, Apr 13, 2019 at 12:54:53PM +0200, adrian15 wrote:

I confirm this patch applied over 2.04rc1 tag enables me to build grub on my system.
Thank you very much!

May I add "Tested-by: adrian15 <[email protected]>" to this patch?

Daniel

#4 lore raw
Quoted 8 lines · Daniel Kiper
Quoted 3 lines · On Sat, Apr 13, 2019 at 12:54:53PM +0200, adrian15 wrote:

I confirm this patch applied over 2.04rc1 tag enables me to build grub on my system.
Thank you very much!

May I add "Tested-by: adrian15 <[email protected]>" to this patch?

Daniel

No problem.

adrian15

Signature · 2 lines
Support free software. Donate to Super Grub Disk. Apoya el software
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
#5 lore raw
Quoted 10 lines · On Fri, Apr 19, 2019 at 09:19:35AM +0200, adrian15 wrote:
Quoted 8 lines · Daniel Kiper
Quoted 3 lines · On Sat, Apr 13, 2019 at 12:54:53PM +0200, adrian15 wrote:

I confirm this patch applied over 2.04rc1 tag enables me to build grub on my system.
Thank you very much!

May I add "Tested-by: adrian15 <[email protected]>" to this patch?

Daniel

No problem.

Thanks!

Daniel

Reviewed-by on v1 1/1
#6 lore raw
In reply to Daniel Kiper
Quoted 11 lines · Daniel Kiper

Some older GCC versions produce following error when x86 MSR modules are build:

In file included from commands/i386/rdmsr.c:29:0:
../include/grub/i386/rdmsr.h:27:29: error: no previous prototype for ‘grub_msr_read’ [-Werror=missing-prototypes]
extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)

                              ^

cc1: all warnings being treated as errors

Quoted 8 lines

This is due to incorrect use of extern keyword. So, replace it with static keyword.

Additionally, fix incorrect coding style.

Quoted 41 lines

---
include/grub/i386/rdmsr.h | 3 ++-
include/grub/i386/wrmsr.h | 3 ++-

2 files changed, 4 insertions(+), 2 deletions(-)
include/grub/i386/rdmsr.h +2 -1
index bddb7bbbb..c0a0c717a 100644
@@ -24,7 +24,8 @@
 *       Accessing a reserved or unimplemented MSR address results in a GP#.
 */
 
-extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)
+static inline grub_uint64_t
+grub_msr_read (grub_uint32_t msr_id)
 {
  grub_uint32_t low, high;
 
include/grub/i386/wrmsr.h +2 -1
index e14d7807f..dea60aed1 100644
@@ -24,7 +24,8 @@
 *       Accessing a reserved or unimplemented MSR address results in a GP#.
 */
 
-extern inline void grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value)
+static inline void
+grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value)
 {
  grub_uint32_t low = msr_value, high = msr_value >> 32;
 
Signature · 7 lines
2.11.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel