[XEN PATCH] xen/sched: address violations of MISRA C:2012 Rule 8.2

Federico Serafini posted 1 patch 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/142049155775072b2a43eb2f052ffd0ab322867e.1696497380.git.federico.serafini@bugseng.com
There is a newer version of this series
xen/common/sched/private.h | 93 ++++++++++++++++++++------------------
1 file changed, 49 insertions(+), 44 deletions(-)
[XEN PATCH] xen/sched: address violations of MISRA C:2012 Rule 8.2
Posted by Federico Serafini 7 months ago
Add missing parameter names. No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
 xen/common/sched/private.h | 93 ++++++++++++++++++++------------------
 1 file changed, 49 insertions(+), 44 deletions(-)

diff --git a/xen/common/sched/private.h b/xen/common/sched/private.h
index c516976c37..68de469537 100644
--- a/xen/common/sched/private.h
+++ b/xen/common/sched/private.h
@@ -280,59 +280,64 @@ struct scheduler {
 
     int          (*global_init)    (void);
 
-    int          (*init)           (struct scheduler *);
-    void         (*deinit)         (struct scheduler *);
+    int          (*init)           (struct scheduler *s);
+    void         (*deinit)         (struct scheduler *s);
 
-    void         (*free_udata)     (const struct scheduler *, void *);
-    void *       (*alloc_udata)    (const struct scheduler *,
-                                    struct sched_unit *, void *);
-    void         (*free_pdata)     (const struct scheduler *, void *, int);
-    void *       (*alloc_pdata)    (const struct scheduler *, int);
-    void         (*deinit_pdata)   (const struct scheduler *, void *, int);
+    void         (*free_udata)     (const struct scheduler *s, void *data);
+    void *       (*alloc_udata)    (const struct scheduler *s,
+                                    struct sched_unit *unit, void *data);
+
+    void         (*free_pdata)     (const struct scheduler *s,
+                                    void *data, int cpu);
+    void *       (*alloc_pdata)    (const struct scheduler *s, int cpu);
+    void         (*deinit_pdata)   (const struct scheduler *s,
+                                    void *pcpu, int cpu);
 
     /* Returns ERR_PTR(-err) for error, NULL for 'nothing needed'. */
-    void *       (*alloc_domdata)  (const struct scheduler *, struct domain *);
+    void *       (*alloc_domdata)  (const struct scheduler *s,
+                                    struct domain *d);
     /* Idempotent. */
-    void         (*free_domdata)   (const struct scheduler *, void *);
+    void         (*free_domdata)   (const struct scheduler *s, void *data);
 
-    spinlock_t * (*switch_sched)   (struct scheduler *, unsigned int,
-                                    void *, void *);
+    spinlock_t * (*switch_sched)   (struct scheduler *s, unsigned int cpu,
+                                    void *pdata, void *vdata);
 
     /* Activate / deactivate units in a cpu pool */
-    void         (*insert_unit)    (const struct scheduler *,
-                                    struct sched_unit *);
-    void         (*remove_unit)    (const struct scheduler *,
-                                    struct sched_unit *);
-
-    void         (*sleep)          (const struct scheduler *,
-                                    struct sched_unit *);
-    void         (*wake)           (const struct scheduler *,
-                                    struct sched_unit *);
-    void         (*yield)          (const struct scheduler *,
-                                    struct sched_unit *);
-    void         (*context_saved)  (const struct scheduler *,
-                                    struct sched_unit *);
-
-    void         (*do_schedule)    (const struct scheduler *,
-                                    struct sched_unit *, s_time_t,
+    void         (*insert_unit)    (const struct scheduler *s,
+                                    struct sched_unit *unit);
+    void         (*remove_unit)    (const struct scheduler *s,
+                                    struct sched_unit *unit);
+
+    void         (*sleep)          (const struct scheduler *s,
+                                    struct sched_unit *unit);
+    void         (*wake)           (const struct scheduler *s,
+                                    struct sched_unit *unit);
+    void         (*yield)          (const struct scheduler *s,
+                                    struct sched_unit *unit);
+    void         (*context_saved)  (const struct scheduler *s,
+                                    struct sched_unit *unit);
+
+    void         (*do_schedule)    (const struct scheduler *s,
+                                    struct sched_unit *unit, s_time_t now,
                                     bool tasklet_work_scheduled);
 
-    struct sched_resource *(*pick_resource)(const struct scheduler *,
-                                            const struct sched_unit *);
-    void         (*migrate)        (const struct scheduler *,
-                                    struct sched_unit *, unsigned int);
-    int          (*adjust)         (const struct scheduler *, struct domain *,
-                                    struct xen_domctl_scheduler_op *);
-    void         (*adjust_affinity)(const struct scheduler *,
-                                    struct sched_unit *,
-                                    const struct cpumask *,
-                                    const struct cpumask *);
-    int          (*adjust_global)  (const struct scheduler *,
-                                    struct xen_sysctl_scheduler_op *);
-    void         (*dump_settings)  (const struct scheduler *);
-    void         (*dump_cpu_state) (const struct scheduler *, int);
-    void         (*move_timers)    (const struct scheduler *,
-                                    struct sched_resource *);
+    struct sched_resource *(*pick_resource)(const struct scheduler *s,
+                                            const struct sched_unit *unit);
+    void         (*migrate)        (const struct scheduler *s,
+                                    struct sched_unit *unit, unsigned int cpu);
+    int          (*adjust)         (const struct scheduler *s,
+                                    struct domain *d,
+                                    struct xen_domctl_scheduler_op *op);
+    void         (*adjust_affinity)(const struct scheduler *s,
+                                    struct sched_unit *unit,
+                                    const struct cpumask *hard,
+                                    const struct cpumask *soft);
+    int          (*adjust_global)  (const struct scheduler *s,
+                                    struct xen_sysctl_scheduler_op *op);
+    void         (*dump_settings)  (const struct scheduler *s);
+    void         (*dump_cpu_state) (const struct scheduler *s, int cpu);
+    void         (*move_timers)    (const struct scheduler *s,
+                                    struct sched_resource *sr);
 };
 
 static inline int sched_init(struct scheduler *s)
-- 
2.34.1
Re: [XEN PATCH] xen/sched: address violations of MISRA C:2012 Rule 8.2
Posted by Stefano Stabellini 7 months ago
On Thu, 5 Oct 2023, Federico Serafini wrote:
> Add missing parameter names. No functional change.
> 
> Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
> ---
>  xen/common/sched/private.h | 93 ++++++++++++++++++++------------------
>  1 file changed, 49 insertions(+), 44 deletions(-)
> 
> diff --git a/xen/common/sched/private.h b/xen/common/sched/private.h
> index c516976c37..68de469537 100644
> --- a/xen/common/sched/private.h
> +++ b/xen/common/sched/private.h
> @@ -280,59 +280,64 @@ struct scheduler {
>  
>      int          (*global_init)    (void);
>  
> -    int          (*init)           (struct scheduler *);
> -    void         (*deinit)         (struct scheduler *);
> +    int          (*init)           (struct scheduler *s);
> +    void         (*deinit)         (struct scheduler *s);

I only checked 2 schedulers but it looks like they are using "ops" not
"s" everywhere in this function pointers parameters.


> -    void         (*free_udata)     (const struct scheduler *, void *);
> -    void *       (*alloc_udata)    (const struct scheduler *,
> -                                    struct sched_unit *, void *);
> -    void         (*free_pdata)     (const struct scheduler *, void *, int);
> -    void *       (*alloc_pdata)    (const struct scheduler *, int);
> -    void         (*deinit_pdata)   (const struct scheduler *, void *, int);
> +    void         (*free_udata)     (const struct scheduler *s, void *data);
> +    void *       (*alloc_udata)    (const struct scheduler *s,
> +                                    struct sched_unit *unit, void *data);

here they use "dd" instead of "data"


> +    void         (*free_pdata)     (const struct scheduler *s,
> +                                    void *data, int cpu);

pcpu instead of cpu

I won't go through the whole list but if you look at
xen/common/sched/credit2.c and xen/common/sched/credit.c you'll see that
the naming scheme is pretty aligned



> +    void *       (*alloc_pdata)    (const struct scheduler *s, int cpu);
> +    void         (*deinit_pdata)   (const struct scheduler *s,
> +                                    void *pcpu, int cpu);
>  
>      /* Returns ERR_PTR(-err) for error, NULL for 'nothing needed'. */
> -    void *       (*alloc_domdata)  (const struct scheduler *, struct domain *);
> +    void *       (*alloc_domdata)  (const struct scheduler *s,
> +                                    struct domain *d);
>      /* Idempotent. */
> -    void         (*free_domdata)   (const struct scheduler *, void *);
> +    void         (*free_domdata)   (const struct scheduler *s, void *data);
>  
> -    spinlock_t * (*switch_sched)   (struct scheduler *, unsigned int,
> -                                    void *, void *);
> +    spinlock_t * (*switch_sched)   (struct scheduler *s, unsigned int cpu,
> +                                    void *pdata, void *vdata);
>  
>      /* Activate / deactivate units in a cpu pool */
> -    void         (*insert_unit)    (const struct scheduler *,
> -                                    struct sched_unit *);
> -    void         (*remove_unit)    (const struct scheduler *,
> -                                    struct sched_unit *);
> -
> -    void         (*sleep)          (const struct scheduler *,
> -                                    struct sched_unit *);
> -    void         (*wake)           (const struct scheduler *,
> -                                    struct sched_unit *);
> -    void         (*yield)          (const struct scheduler *,
> -                                    struct sched_unit *);
> -    void         (*context_saved)  (const struct scheduler *,
> -                                    struct sched_unit *);
> -
> -    void         (*do_schedule)    (const struct scheduler *,
> -                                    struct sched_unit *, s_time_t,
> +    void         (*insert_unit)    (const struct scheduler *s,
> +                                    struct sched_unit *unit);
> +    void         (*remove_unit)    (const struct scheduler *s,
> +                                    struct sched_unit *unit);
> +
> +    void         (*sleep)          (const struct scheduler *s,
> +                                    struct sched_unit *unit);
> +    void         (*wake)           (const struct scheduler *s,
> +                                    struct sched_unit *unit);
> +    void         (*yield)          (const struct scheduler *s,
> +                                    struct sched_unit *unit);
> +    void         (*context_saved)  (const struct scheduler *s,
> +                                    struct sched_unit *unit);
> +
> +    void         (*do_schedule)    (const struct scheduler *s,
> +                                    struct sched_unit *unit, s_time_t now,
>                                      bool tasklet_work_scheduled);
>  
> -    struct sched_resource *(*pick_resource)(const struct scheduler *,
> -                                            const struct sched_unit *);
> -    void         (*migrate)        (const struct scheduler *,
> -                                    struct sched_unit *, unsigned int);
> -    int          (*adjust)         (const struct scheduler *, struct domain *,
> -                                    struct xen_domctl_scheduler_op *);
> -    void         (*adjust_affinity)(const struct scheduler *,
> -                                    struct sched_unit *,
> -                                    const struct cpumask *,
> -                                    const struct cpumask *);
> -    int          (*adjust_global)  (const struct scheduler *,
> -                                    struct xen_sysctl_scheduler_op *);
> -    void         (*dump_settings)  (const struct scheduler *);
> -    void         (*dump_cpu_state) (const struct scheduler *, int);
> -    void         (*move_timers)    (const struct scheduler *,
> -                                    struct sched_resource *);
> +    struct sched_resource *(*pick_resource)(const struct scheduler *s,
> +                                            const struct sched_unit *unit);
> +    void         (*migrate)        (const struct scheduler *s,
> +                                    struct sched_unit *unit, unsigned int cpu);
> +    int          (*adjust)         (const struct scheduler *s,
> +                                    struct domain *d,
> +                                    struct xen_domctl_scheduler_op *op);
> +    void         (*adjust_affinity)(const struct scheduler *s,
> +                                    struct sched_unit *unit,
> +                                    const struct cpumask *hard,
> +                                    const struct cpumask *soft);
> +    int          (*adjust_global)  (const struct scheduler *s,
> +                                    struct xen_sysctl_scheduler_op *op);
> +    void         (*dump_settings)  (const struct scheduler *s);
> +    void         (*dump_cpu_state) (const struct scheduler *s, int cpu);
> +    void         (*move_timers)    (const struct scheduler *s,
> +                                    struct sched_resource *sr);
>  };
>  
>  static inline int sched_init(struct scheduler *s)
> -- 
> 2.34.1
>