[PATCH 3/3] xen/x86: Address two misc MISRA 17.7 violations

Andrew Cooper posted 3 patches 6 months ago
[PATCH 3/3] xen/x86: Address two misc MISRA 17.7 violations
Posted by Andrew Cooper 6 months ago
Neither text_poke() nor watchdog_setup() have return value consulted.  Switch
them to being void.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: George Dunlap <George.Dunlap@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Roberto Bagnara <roberto.bagnara@bugseng.com>
CC: consulting@bugseng.com <consulting@bugseng.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 xen/arch/x86/alternative.c | 4 ++--
 xen/arch/x86/nmi.c         | 5 ++---
 xen/include/xen/watchdog.h | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
index 2e7ba6e0b833..7824053c9d33 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -155,10 +155,10 @@ void init_or_livepatch add_nops(void *insns, unsigned int len)
  * "noinline" to cause control flow change and thus invalidate I$ and
  * cause refetch after modification.
  */
-static void *init_or_livepatch noinline
+static void init_or_livepatch noinline
 text_poke(void *addr, const void *opcode, size_t len)
 {
-    return memcpy(addr, opcode, len);
+    memcpy(addr, opcode, len);
 }
 
 extern void *const __initdata_cf_clobber_start[];
diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c
index f6329cb0270e..9793fa23168d 100644
--- a/xen/arch/x86/nmi.c
+++ b/xen/arch/x86/nmi.c
@@ -464,12 +464,12 @@ bool watchdog_enabled(void)
     return !atomic_read(&watchdog_disable_count);
 }
 
-int __init watchdog_setup(void)
+void __init watchdog_setup(void)
 {
     unsigned int cpu;
 
     /*
-     * Activate periodic heartbeats. We cannot do this earlier during 
+     * Activate periodic heartbeats. We cannot do this earlier during
      * setup because the timer infrastructure is not available.
      */
     for_each_online_cpu ( cpu )
@@ -477,7 +477,6 @@ int __init watchdog_setup(void)
     register_cpu_notifier(&cpu_nmi_nfb);
 
     watchdog_enable();
-    return 0;
 }
 
 /* Returns false if this was not a watchdog NMI, true otherwise */
diff --git a/xen/include/xen/watchdog.h b/xen/include/xen/watchdog.h
index 434fcbdd2b11..40c21bca823f 100644
--- a/xen/include/xen/watchdog.h
+++ b/xen/include/xen/watchdog.h
@@ -10,7 +10,7 @@
 #include <xen/types.h>
 
 /* Try to set up a watchdog. */
-int watchdog_setup(void);
+void watchdog_setup(void);
 
 /* Enable the watchdog. */
 void watchdog_enable(void);
-- 
2.30.2
Re: [PATCH 3/3] xen/x86: Address two misc MISRA 17.7 violations
Posted by Stefano Stabellini 6 months ago
On Tue, 21 May 2024, Andrew Cooper wrote:
> Neither text_poke() nor watchdog_setup() have return value consulted.  Switch
> them to being void.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

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


> ---
> CC: George Dunlap <George.Dunlap@citrix.com>
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien@xen.org>
> CC: Roberto Bagnara <roberto.bagnara@bugseng.com>
> CC: consulting@bugseng.com <consulting@bugseng.com>
> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> ---
>  xen/arch/x86/alternative.c | 4 ++--
>  xen/arch/x86/nmi.c         | 5 ++---
>  xen/include/xen/watchdog.h | 2 +-
>  3 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
> index 2e7ba6e0b833..7824053c9d33 100644
> --- a/xen/arch/x86/alternative.c
> +++ b/xen/arch/x86/alternative.c
> @@ -155,10 +155,10 @@ void init_or_livepatch add_nops(void *insns, unsigned int len)
>   * "noinline" to cause control flow change and thus invalidate I$ and
>   * cause refetch after modification.
>   */
> -static void *init_or_livepatch noinline
> +static void init_or_livepatch noinline
>  text_poke(void *addr, const void *opcode, size_t len)
>  {
> -    return memcpy(addr, opcode, len);
> +    memcpy(addr, opcode, len);
>  }
>  
>  extern void *const __initdata_cf_clobber_start[];
> diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c
> index f6329cb0270e..9793fa23168d 100644
> --- a/xen/arch/x86/nmi.c
> +++ b/xen/arch/x86/nmi.c
> @@ -464,12 +464,12 @@ bool watchdog_enabled(void)
>      return !atomic_read(&watchdog_disable_count);
>  }
>  
> -int __init watchdog_setup(void)
> +void __init watchdog_setup(void)
>  {
>      unsigned int cpu;
>  
>      /*
> -     * Activate periodic heartbeats. We cannot do this earlier during 
> +     * Activate periodic heartbeats. We cannot do this earlier during
>       * setup because the timer infrastructure is not available.
>       */
>      for_each_online_cpu ( cpu )
> @@ -477,7 +477,6 @@ int __init watchdog_setup(void)
>      register_cpu_notifier(&cpu_nmi_nfb);
>  
>      watchdog_enable();
> -    return 0;
>  }
>  
>  /* Returns false if this was not a watchdog NMI, true otherwise */
> diff --git a/xen/include/xen/watchdog.h b/xen/include/xen/watchdog.h
> index 434fcbdd2b11..40c21bca823f 100644
> --- a/xen/include/xen/watchdog.h
> +++ b/xen/include/xen/watchdog.h
> @@ -10,7 +10,7 @@
>  #include <xen/types.h>
>  
>  /* Try to set up a watchdog. */
> -int watchdog_setup(void);
> +void watchdog_setup(void);
>  
>  /* Enable the watchdog. */
>  void watchdog_enable(void);
> -- 
> 2.30.2
>