Skip to contentSkip to conversation

xen: Swap 'const static' for 'static const'

PATCH In review Andrew Cooper 4 participants 6 messages Apr 3, 2025 – Apr 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Swap 'const static' for 'static const'

MISRA C:2012 Ammendment 3 (which is under consideration, but not used by Xen yet) is more particular about the order of keywords.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Nicola Vetrini <[email protected]>
CC: [email protected]

---
 xen/arch/arm/gic-v2.c  | 2 +-
 xen/include/xen/init.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/gic-v2.c +1 -1
index 02043c0d4b1f..b23e72a3d05d 100644
@@ -1311,7 +1311,7 @@ static void gicv2_do_LPI(unsigned int lpi)
     BUG();
 }
 
-const static struct gic_hw_operations gicv2_ops = {
+static const struct gic_hw_operations gicv2_ops = {
     .info                = &gicv2_info,
     .init                = gicv2_init,
     .secondary_init      = gicv2_secondary_cpu_init,
xen/include/xen/init.h +2 -2
index 0a4223833755..abf275f0eb72 100644
@@ -63,9 +63,9 @@ typedef int (*initcall_t)(void);
 typedef void (*exitcall_t)(void);
 
 #define presmp_initcall(fn) \
-    const static initcall_t __initcall_##fn __init_call("presmp") = (fn)
+    static const initcall_t __initcall_##fn __init_call("presmp") = (fn)
 #define __initcall(fn) \
-    const static initcall_t __initcall_##fn __init_call("1") = (fn)
+    static const initcall_t __initcall_##fn __init_call("1") = (fn)
 #define __exitcall(fn) \
     static exitcall_t __exitcall_##fn __exit_call = fn
 

base-commit: befc384d21784affa3daf2abc85b02500e4dc545

Signature · 1 line
2.39.5
#1 lore raw
Quoted 1 line · Andrew Cooper

MISRA C:2012 Ammendment 3 (which is under consideration, but not used by Xen

^ typo

Quoted 5 lines

yet) is more particular about the order of keywords.

No functional change.

Any specific reason not to give [1] and [2] the same treatment? Other than that, looks good to me.

[1] https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/bugseng/xen/ECLAIR_normal/MISRA_C_AMD3/X86_64/9616508934/PROJECT.ecd;/sources/xen/arch/x86/genapic/x2apic.c.html#R4145_1
[2] https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/bugseng/xen/ECLAIR_normal/MISRA_C_AMD3/X86_64/9616508934/PROJECT.ecd;/sources/xen/arch/x86/hvm/dom0_build.c.html#R13937_1

Quoted 48 lines

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Nicola Vetrini <[email protected]>
CC: [email protected]

---
 xen/arch/arm/gic-v2.c  | 2 +-
 xen/include/xen/init.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
xen/arch/arm/gic-v2.c +1 -1
index 02043c0d4b1f..b23e72a3d05d 100644
@@ -1311,7 +1311,7 @@ static void gicv2_do_LPI(unsigned int lpi)
     BUG();
 }
 
-const static struct gic_hw_operations gicv2_ops = {
+static const struct gic_hw_operations gicv2_ops = {
     .info                = &gicv2_info,
     .init                = gicv2_init,
     .secondary_init      = gicv2_secondary_cpu_init,
xen/include/xen/init.h +2 -2
index 0a4223833755..abf275f0eb72 100644
@@ -63,9 +63,9 @@ typedef int (*initcall_t)(void);
 typedef void (*exitcall_t)(void);
 
 #define presmp_initcall(fn) \
-    const static initcall_t __initcall_##fn __init_call("presmp") = 
 (fn)
+    static const initcall_t __initcall_##fn __init_call("presmp") = 
 (fn)
 #define __initcall(fn) \
-    const static initcall_t __initcall_##fn __init_call("1") = (fn)
+    static const initcall_t __initcall_##fn __init_call("1") = (fn)
 #define __exitcall(fn) \

static exitcall_t __exitcall_##fn __exit_call = fn

base-commit: befc384d21784affa3daf2abc85b02500e4dc545

Signature · 4 lines
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
#2 lore raw
Quoted 10 lines · Nicola Vetrini
Quoted 2 lines · Andrew Cooper

MISRA C:2012 Ammendment 3 (which is under consideration, but not used by Xen

               ^ typo

Quoted 5 lines

yet) is more particular about the order of keywords.

No functional change.

Quoted 7 lines

Any specific reason not to give [1] and [2] the same treatment? Other than that, looks good to me.

[1]
https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/bugseng/xen/ECLAIR_normal/MISRA_C_AMD3/X86_64/9616508934/PROJECT.ecd;/sources/xen/arch/x86/genapic/x2apic.c.html#R4145_1
[2]
https://saas.eclairit.com:3787/fs/var/local/eclair/xen-project.ecdf/xen-project/people/bugseng/xen/ECLAIR_normal/MISRA_C_AMD3/X86_64/9616508934/PROJECT.ecd;/sources/xen/arch/x86/hvm/dom0_build.c.html#R13937_1

Oh, inattention to detail with my git grep.

I'll update to include these.  Thanks.

~Andrew

#3 lore raw

PATCH v2 1/1 xen: Consistently use 'static' first

In reply to Andrew Cooper

MISRA C:2012 Amendment 3 (which is under consideration, but not used by Xen yet) is more particular about having the storage class specifier first.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Nicola Vetrini <[email protected]>
CC: [email protected]

v2:
* Fix x2apic_mode and orders[] too.

---
 xen/arch/arm/gic-v2.c         | 2 +-
 xen/arch/x86/genapic/x2apic.c | 4 ++--
 xen/arch/x86/hvm/dom0_build.c | 4 ++--
 xen/include/xen/init.h        | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)
xen/arch/arm/gic-v2.c +1 -1
index 02043c0d4b1f..b23e72a3d05d 100644
@@ -1311,7 +1311,7 @@ static void gicv2_do_LPI(unsigned int lpi)
     BUG();
 }
 
-const static struct gic_hw_operations gicv2_ops = {
+static const struct gic_hw_operations gicv2_ops = {
     .info                = &gicv2_info,
     .init                = gicv2_init,
     .secondary_init      = gicv2_secondary_cpu_init,
xen/arch/x86/genapic/x2apic.c +2 -2
index 74a6d808ac30..1d55eb6b8a41 100644
@@ -216,9 +216,9 @@ static struct notifier_block x2apic_cpu_nfb = {
 static int8_t __initdata x2apic_phys = -1;
 boolean_param("x2apic_phys", x2apic_phys);
 
-enum {
+static enum {
    unset, physical, mixed
-} static __initdata x2apic_mode = unset;
+} x2apic_mode __initdata = unset;
 
 static int __init cf_check parse_x2apic_mode(const char *s)
 {
xen/arch/x86/hvm/dom0_build.c +2 -2
index daf1b6f88b14..9fd68df7b936 100644
@@ -91,10 +91,10 @@ static int __init pvh_populate_memory_range(struct domain *d,
                                             unsigned long start,
                                             unsigned long nr_pages)
 {
-    struct {
+    static const struct {
         unsigned long align;
         unsigned int order;
-    } static const __initconst orders[] = {
+    } orders[] __initconst = {
         /* NB: must be sorted by decreasing size. */
         { .align = PFN_DOWN(GB(1)), .order = PAGE_ORDER_1G },
         { .align = PFN_DOWN(MB(2)), .order = PAGE_ORDER_2M },
xen/include/xen/init.h +2 -2
index 0a4223833755..abf275f0eb72 100644
@@ -63,9 +63,9 @@ typedef int (*initcall_t)(void);
 typedef void (*exitcall_t)(void);
 
 #define presmp_initcall(fn) \
-    const static initcall_t __initcall_##fn __init_call("presmp") = (fn)
+    static const initcall_t __initcall_##fn __init_call("presmp") = (fn)
 #define __initcall(fn) \
-    const static initcall_t __initcall_##fn __init_call("1") = (fn)
+    static const initcall_t __initcall_##fn __init_call("1") = (fn)
 #define __exitcall(fn) \
     static exitcall_t __exitcall_##fn __exit_call = fn
 

base-commit: befc384d21784affa3daf2abc85b02500e4dc545

Signature · 1 line
2.39.5