diff mbox series

[XEN,v2,5/5] x86: refactor macros in 'xen-mca.h'

Message ID 8df1af6384606d8176525fbffb364ec814d48db1.1691492441.git.nicola.vetrini@bugseng.com (mailing list archive)
State Superseded
Headers show
Series x86: address MISRA C:2012 Rule 5.3 | expand

Commit Message

Nicola Vetrini Aug. 8, 2023, 11:08 a.m. UTC
The macros defined 'xen/include/public/arch-x86/xen-mca.h' are revised
to address the following concerns:
- needless underscore prefixes for parameter names;
- the variable 'i' in function 'mce_action' that is shadowed
  by the local variable in the macro.

Therefore, the refactoring aims to resolve present shadowing
issues, which violate MISRA C:2012 Rule 5.3, and lessen the
probability of future ones with some renames.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
Changes in v2:
- Added missing parentheses.
- Clarified commit message.
---
 xen/include/public/arch-x86/xen-mca.h | 38 +++++++++++++--------------
 1 file changed, 19 insertions(+), 19 deletions(-)

Comments

Nicola Vetrini Aug. 8, 2023, 12:02 p.m. UTC | #1
On 08/08/2023 13:08, Nicola Vetrini wrote:
> The macros defined 'xen/include/public/arch-x86/xen-mca.h' are revised
> to address the following concerns:
> - needless underscore prefixes for parameter names;
> - the variable 'i' in function 'mce_action' that is shadowed
>   by the local variable in the macro.
> 
> Therefore, the refactoring aims to resolve present shadowing
> issues, which violate MISRA C:2012 Rule 5.3, and lessen the
> probability of future ones with some renames.
> 
> No functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> ---
> Changes in v2:
> - Added missing parentheses.
> - Clarified commit message.
> ---

Missing a
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
from the other version, since nothing changed code-wise.
Jan Beulich Aug. 8, 2023, 12:06 p.m. UTC | #2
On 08.08.2023 14:02, Nicola Vetrini wrote:
> On 08/08/2023 13:08, Nicola Vetrini wrote:
>> The macros defined 'xen/include/public/arch-x86/xen-mca.h' are revised
>> to address the following concerns:
>> - needless underscore prefixes for parameter names;
>> - the variable 'i' in function 'mce_action' that is shadowed
>>   by the local variable in the macro.
>>
>> Therefore, the refactoring aims to resolve present shadowing
>> issues, which violate MISRA C:2012 Rule 5.3, and lessen the
>> probability of future ones with some renames.
>>
>> No functional change.
>>
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>> ---
>> Changes in v2:
>> - Added missing parentheses.

This ...

>> - Clarified commit message.
>> ---
> 
> Missing a
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> from the other version, since nothing changed code-wise.

... isn't exactly "nothing", but well.

Jan
Jan Beulich Aug. 8, 2023, 2:46 p.m. UTC | #3
On 08.08.2023 13:08, Nicola Vetrini wrote:
> The macros defined 'xen/include/public/arch-x86/xen-mca.h' are revised
> to address the following concerns:
> - needless underscore prefixes for parameter names;
> - the variable 'i' in function 'mce_action' that is shadowed
>   by the local variable in the macro.
> 
> Therefore, the refactoring aims to resolve present shadowing
> issues, which violate MISRA C:2012 Rule 5.3, and lessen the
> probability of future ones with some renames.
> 
> No functional change.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
diff mbox series

Patch

diff --git a/xen/include/public/arch-x86/xen-mca.h b/xen/include/public/arch-x86/xen-mca.h
index b897536ec5..bb1b12f14f 100644
--- a/xen/include/public/arch-x86/xen-mca.h
+++ b/xen/include/public/arch-x86/xen-mca.h
@@ -280,39 +280,39 @@  DEFINE_XEN_GUEST_HANDLE(xen_mc_logical_cpu_t);
 /* Prototype:
  *    uint32_t x86_mcinfo_nentries(struct mc_info *mi);
  */
-#define x86_mcinfo_nentries(_mi)    \
-    (_mi)->mi_nentries
+#define x86_mcinfo_nentries(mi)    \
+    (mi)->mi_nentries
 /* Prototype:
  *    struct mcinfo_common *x86_mcinfo_first(struct mc_info *mi);
  */
-#define x86_mcinfo_first(_mi)       \
-    ((struct mcinfo_common *)(_mi)->mi_data)
+#define x86_mcinfo_first(mi)       \
+    ((struct mcinfo_common *)(mi)->mi_data)
 /* Prototype:
  *    struct mcinfo_common *x86_mcinfo_next(struct mcinfo_common *mic);
  */
-#define x86_mcinfo_next(_mic)       \
-    ((struct mcinfo_common *)((uint8_t *)(_mic) + (_mic)->size))
+#define x86_mcinfo_next(mic)       \
+    ((struct mcinfo_common *)((uint8_t *)(mic) + (mic)->size))
 
 /* Prototype:
- *    void x86_mcinfo_lookup(void *ret, struct mc_info *mi, uint16_t type);
+ *    void x86_mcinfo_lookup(void *ret, struct mc_info *mi, uint16_t mc_type);
  */
-#define x86_mcinfo_lookup(_ret, _mi, _type)    \
+#define x86_mcinfo_lookup(ret, mi, mc_type)                     \
     do {                                                        \
-        uint32_t found, i;                                      \
-        struct mcinfo_common *_mic;                             \
+        uint32_t found_, i_;                                    \
+        struct mcinfo_common *mic_;                             \
                                                                 \
-        found = 0;                                              \
-        (_ret) = NULL;                                          \
-        if (_mi == NULL) break;                                 \
-        _mic = x86_mcinfo_first(_mi);                           \
-        for (i = 0; i < x86_mcinfo_nentries(_mi); i++) {        \
-            if (_mic->type == (_type)) {                        \
-                found = 1;                                      \
+        found_ = 0;                                             \
+        (ret) = NULL;                                           \
+        if ((mi) == NULL) break;                                \
+        mic_ = x86_mcinfo_first(mi);                            \
+        for (i_ = 0; i_ < x86_mcinfo_nentries(mi); i_++) {      \
+            if (mic_->type == (mc_type)) {                      \
+                found_ = 1;                                     \
                 break;                                          \
             }                                                   \
-            _mic = x86_mcinfo_next(_mic);                       \
+            mic_ = x86_mcinfo_next(mic_);                       \
         }                                                       \
-        (_ret) = found ? _mic : NULL;                           \
+        (ret) = found_ ? mic_ : NULL;                           \
     } while (0)