]> xenbits.xensource.com Git - xen.git/commitdiff
xen: introduce function type bug_fn_t.
authorFederico Serafini <federico.serafini@bugseng.com>
Fri, 17 Nov 2023 08:28:26 +0000 (09:28 +0100)
committerStefano Stabellini <stefano.stabellini@amd.com>
Sat, 18 Nov 2023 02:29:51 +0000 (18:29 -0800)
Introduce function type bug_fn_t. This improves readability and could be
used to help validating that the function passed to
run_in_exception_handle() has the expected prototype.

Use the newly-intoduced type to address a violation of MISRA
C:2012 Rule 8.2.

Suggested-by: Julien Grall <julien@xen.org>
Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
[stefano: minor commit improvement]
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/traps.c
xen/include/xen/bug.h

index ce89f16404d987cf4665da79b5793fafc1260c0e..8492e2b7bbb8d187080c273f9ca98d52ccf7cc64 100644 (file)
@@ -1236,7 +1236,7 @@ int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc)
 
     if ( id == BUGFRAME_run_fn )
     {
-        void (*fn)(const struct cpu_user_regs *) = (void *)regs->BUG_FN_REG;
+        bug_fn_t *fn = (void *)regs->BUG_FN_REG;
 
         fn(regs);
         return 0;
index e8a4eea71a45272d2845f6a9ca24438662702e0d..cb5138410ea7d973eb26dc45958680304c667d96 100644 (file)
@@ -99,6 +99,9 @@ struct bug_frame {
 
 #endif
 
+struct cpu_user_regs;
+typedef void bug_fn_t(const struct cpu_user_regs *regs);
+
 #ifndef run_in_exception_handler
 
 /*
@@ -132,8 +135,6 @@ struct bug_frame {
 
 #ifdef CONFIG_GENERIC_BUG_FRAME
 
-struct cpu_user_regs;
-
 /*
  * Returns a negative value in case of an error otherwise
  * BUGFRAME_{run_fn, warn, bug, assert}