[PATCH] xen: add missing noreturn attribute

Dmytro Prokopchuk1 posted 1 patch 3 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/7b2884c6f89a0af671daa26798154b5ac0042a80.1753397522.git.dmytro._5Fprokopchuk1@epam.com
xen/arch/arm/domain.c  | 2 +-
xen/arch/arm/setup.c   | 2 +-
xen/arch/arm/smpboot.c | 2 +-
xen/common/efi/boot.c  | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
[PATCH] xen: add missing noreturn attribute
Posted by Dmytro Prokopchuk1 3 months, 1 week ago
These functions never return to their caller,
causing a violation of MISRA C Rule 2.1:
"A project shall not contain unreachable code".
Add the `noreturn' attribute to fix this.

No functional changes.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
 xen/arch/arm/domain.c  | 2 +-
 xen/arch/arm/setup.c   | 2 +-
 xen/arch/arm/smpboot.c | 2 +-
 xen/common/efi/boot.c  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 79a144e61b..310c578909 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -298,7 +298,7 @@ static void schedule_tail(struct vcpu *prev)
 extern void noreturn return_to_new_vcpu32(void);
 extern void noreturn return_to_new_vcpu64(void);
 
-static void continue_new_vcpu(struct vcpu *prev)
+static void noreturn continue_new_vcpu(struct vcpu *prev)
 {
     current->arch.actlr = READ_SYSREG(ACTLR_EL1);
     processor_vcpu_initialise(current);
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 27bd3f5a6e..bb35afe56c 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -306,7 +306,7 @@ void __init init_pdx(void)
 size_t __read_mostly dcache_line_bytes;
 
 /* C entry point for boot CPU */
-void asmlinkage __init start_xen(unsigned long fdt_paddr)
+void asmlinkage __init noreturn start_xen(unsigned long fdt_paddr)
 {
     size_t fdt_size;
     const char *cmdline;
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index 73de7503e9..7f3cfa812e 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -315,7 +315,7 @@ smp_prepare_cpus(void)
 }
 
 /* Boot the current CPU */
-void asmlinkage start_secondary(void)
+void asmlinkage noreturn start_secondary(void)
 {
     unsigned int cpuid = init_data.cpuid;
 
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index df29444220..4b60bd719e 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -285,7 +285,7 @@ static bool __init match_guid(const EFI_GUID *guid1, const EFI_GUID *guid2)
 }
 
 /* generic routine for printing error messages */
-static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode)
+static void __init noreturn PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode)
 {
     StdOut = StdErr;
     PrintErr(mesg);
-- 
2.43.0
Re: [PATCH] xen: add missing noreturn attribute
Posted by Stefano Stabellini 3 months, 1 week ago
On Thu, 24 Jul 2025, Dmytro Prokopchuk1 wrote:
> These functions never return to their caller,
> causing a violation of MISRA C Rule 2.1:
> "A project shall not contain unreachable code".
> Add the `noreturn' attribute to fix this.
> 
> No functional changes.
> 
> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/arch/arm/domain.c  | 2 +-
>  xen/arch/arm/setup.c   | 2 +-
>  xen/arch/arm/smpboot.c | 2 +-
>  xen/common/efi/boot.c  | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 79a144e61b..310c578909 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -298,7 +298,7 @@ static void schedule_tail(struct vcpu *prev)
>  extern void noreturn return_to_new_vcpu32(void);
>  extern void noreturn return_to_new_vcpu64(void);
>  
> -static void continue_new_vcpu(struct vcpu *prev)
> +static void noreturn continue_new_vcpu(struct vcpu *prev)
>  {
>      current->arch.actlr = READ_SYSREG(ACTLR_EL1);
>      processor_vcpu_initialise(current);
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 27bd3f5a6e..bb35afe56c 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -306,7 +306,7 @@ void __init init_pdx(void)
>  size_t __read_mostly dcache_line_bytes;
>  
>  /* C entry point for boot CPU */
> -void asmlinkage __init start_xen(unsigned long fdt_paddr)
> +void asmlinkage __init noreturn start_xen(unsigned long fdt_paddr)
>  {
>      size_t fdt_size;
>      const char *cmdline;
> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> index 73de7503e9..7f3cfa812e 100644
> --- a/xen/arch/arm/smpboot.c
> +++ b/xen/arch/arm/smpboot.c
> @@ -315,7 +315,7 @@ smp_prepare_cpus(void)
>  }
>  
>  /* Boot the current CPU */
> -void asmlinkage start_secondary(void)
> +void asmlinkage noreturn start_secondary(void)
>  {
>      unsigned int cpuid = init_data.cpuid;
>  
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index df29444220..4b60bd719e 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -285,7 +285,7 @@ static bool __init match_guid(const EFI_GUID *guid1, const EFI_GUID *guid2)
>  }
>  
>  /* generic routine for printing error messages */
> -static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode)
> +static void __init noreturn PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode)
>  {
>      StdOut = StdErr;
>      PrintErr(mesg);
> -- 
> 2.43.0
>
Re: [PATCH] xen: add missing noreturn attribute
Posted by Marek Marczykowski-Górecki 3 months ago
On Thu, Jul 24, 2025 at 06:06:28PM -0700, Stefano Stabellini wrote:
> On Thu, 24 Jul 2025, Dmytro Prokopchuk1 wrote:
> > These functions never return to their caller,
> > causing a violation of MISRA C Rule 2.1:
> > "A project shall not contain unreachable code".
> > Add the `noreturn' attribute to fix this.
> > 
> > No functional changes.
> > 
> > Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
> 
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> # EFI

> 
> 
> > ---
> >  xen/arch/arm/domain.c  | 2 +-
> >  xen/arch/arm/setup.c   | 2 +-
> >  xen/arch/arm/smpboot.c | 2 +-
> >  xen/common/efi/boot.c  | 2 +-
> >  4 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> > index 79a144e61b..310c578909 100644
> > --- a/xen/arch/arm/domain.c
> > +++ b/xen/arch/arm/domain.c
> > @@ -298,7 +298,7 @@ static void schedule_tail(struct vcpu *prev)
> >  extern void noreturn return_to_new_vcpu32(void);
> >  extern void noreturn return_to_new_vcpu64(void);
> >  
> > -static void continue_new_vcpu(struct vcpu *prev)
> > +static void noreturn continue_new_vcpu(struct vcpu *prev)
> >  {
> >      current->arch.actlr = READ_SYSREG(ACTLR_EL1);
> >      processor_vcpu_initialise(current);
> > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> > index 27bd3f5a6e..bb35afe56c 100644
> > --- a/xen/arch/arm/setup.c
> > +++ b/xen/arch/arm/setup.c
> > @@ -306,7 +306,7 @@ void __init init_pdx(void)
> >  size_t __read_mostly dcache_line_bytes;
> >  
> >  /* C entry point for boot CPU */
> > -void asmlinkage __init start_xen(unsigned long fdt_paddr)
> > +void asmlinkage __init noreturn start_xen(unsigned long fdt_paddr)
> >  {
> >      size_t fdt_size;
> >      const char *cmdline;
> > diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> > index 73de7503e9..7f3cfa812e 100644
> > --- a/xen/arch/arm/smpboot.c
> > +++ b/xen/arch/arm/smpboot.c
> > @@ -315,7 +315,7 @@ smp_prepare_cpus(void)
> >  }
> >  
> >  /* Boot the current CPU */
> > -void asmlinkage start_secondary(void)
> > +void asmlinkage noreturn start_secondary(void)
> >  {
> >      unsigned int cpuid = init_data.cpuid;
> >  
> > diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> > index df29444220..4b60bd719e 100644
> > --- a/xen/common/efi/boot.c
> > +++ b/xen/common/efi/boot.c
> > @@ -285,7 +285,7 @@ static bool __init match_guid(const EFI_GUID *guid1, const EFI_GUID *guid2)
> >  }
> >  
> >  /* generic routine for printing error messages */
> > -static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode)
> > +static void __init noreturn PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode)
> >  {
> >      StdOut = StdErr;
> >      PrintErr(mesg);
> > -- 
> > 2.43.0
> > 

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab