[PATCH] misra: add missing noreturn attribute for __div0()

Dmytro Prokopchuk1 posted 1 patch 2 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/1b5549a97db31c65edb769302deff73576cec41d.1755013482.git.dmytro._5Fprokopchuk1@epam.com
xen/arch/arm/traps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] misra: add missing noreturn attribute for __div0()
Posted by Dmytro Prokopchuk1 2 months, 2 weeks ago
The __div0() function never returns to its caller, causing a violation
of MISRA C Rule 2.1: "A project shall not contain unreachable code".
Add the `noreturn` attribute to fix this.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/1980129839
---
 xen/arch/arm/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 445e7378dd..2bc3e1df04 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -172,7 +172,7 @@ void init_traps(void)
     isb();
 }
 
-void asmlinkage __div0(void)
+void asmlinkage noreturn __div0(void)
 {
     printk("Division by zero in hypervisor.\n");
     BUG();
-- 
2.43.0
Re: [PATCH] misra: add missing noreturn attribute for __div0()
Posted by Nicola Vetrini 2 months, 2 weeks ago
On 2025-08-12 17:46, Dmytro Prokopchuk1 wrote:
> The __div0() function never returns to its caller, causing a violation
> of MISRA C Rule 2.1: "A project shall not contain unreachable code".
> Add the `noreturn` attribute to fix this.
> 

I was convinced that this was already upstream, as I made a patch a 
while ago, but evidently I forgot to send it.

> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>

Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> ---
> Test CI pipeline:
> https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/1980129839
> ---
>  xen/arch/arm/traps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 445e7378dd..2bc3e1df04 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -172,7 +172,7 @@ void init_traps(void)
>      isb();
>  }
> 
> -void asmlinkage __div0(void)
> +void asmlinkage noreturn __div0(void)
>  {
>      printk("Division by zero in hypervisor.\n");
>      BUG();

-- 
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
Re: [PATCH] misra: add missing noreturn attribute for __div0()
Posted by Stefano Stabellini 2 months, 2 weeks ago
On Tue, 12 Aug 2025, Nicola Vetrini wrote:
> On 2025-08-12 17:46, Dmytro Prokopchuk1 wrote:
> > The __div0() function never returns to its caller, causing a violation
> > of MISRA C Rule 2.1: "A project shall not contain unreachable code".
> > Add the `noreturn` attribute to fix this.
> > 
> 
> I was convinced that this was already upstream, as I made a patch a while ago,
> but evidently I forgot to send it.
> 
> > Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
> 
> Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

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