Skip to content

Commit

Permalink
xen: introduce function type bug_fn_t.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Federico Serafini <[email protected]>
[stefano: minor commit improvement]
Signed-off-by: Stefano Stabellini <[email protected]>
Acked-by: Julien Grall <[email protected]>
  • Loading branch information
FedericoSerafini authored and sstabellini committed Nov 18, 2023
1 parent 83e9e30 commit 98758ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion xen/arch/arm/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions xen/include/xen/bug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 98758ae

Please sign in to comment.