]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
x86: Address MISRA Rule 13.6
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 2 Apr 2024 15:26:22 +0000 (16:26 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 5 Apr 2024 13:54:53 +0000 (14:54 +0100)
MISRA Rule 13.6 doesn't like having an expression in a sizeof() which
potentially has side effects, including function calls.

Address several violations by pulling the expression out into a local
variable.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/irq.c
xen/arch/x86/time.c
xen/drivers/passthrough/amd/iommu_intr.c

index 0487f734a5d28563927ecc2664bef5e511f49470..a042faf1045299313aa81c4bf5d965ad10263483 100644 (file)
@@ -1149,9 +1149,9 @@ static void cf_check irq_guest_eoi_timer_fn(void *data)
     for ( i = 0; i < action->nr_guests; i++ )
     {
         struct domain *d = action->guest[i];
-        unsigned int pirq = domain_irq_to_pirq(d, irq);
+        struct pirq *pirq = pirq_info(d, domain_irq_to_pirq(d, irq));
 
-        if ( test_and_clear_bool(pirq_info(d, pirq)->masked) )
+        if ( test_and_clear_bool(pirq->masked) )
             action->in_flight--;
     }
 
index 60870047894b26a9d8fd5ccae3a3a7df33ad8036..6f136f4b14bf655753938d3b48856a38d8b16101 100644 (file)
@@ -2503,7 +2503,9 @@ static long cmos_utc_offset; /* in seconds */
 
 int time_suspend(void)
 {
-    if ( smp_processor_id() == 0 )
+    unsigned int cpu = smp_processor_id();
+
+    if ( cpu == 0 )
     {
         cmos_utc_offset = -get_wallclock_time();
         cmos_utc_offset += get_sec();
@@ -2514,7 +2516,7 @@ int time_suspend(void)
     }
 
     /* Better to cancel calibration timer for accuracy. */
-    clear_bit(TIME_CALIBRATE_SOFTIRQ, &softirq_pending(smp_processor_id()));
+    clear_bit(TIME_CALIBRATE_SOFTIRQ, &softirq_pending(cpu));
 
     return 0;
 }
index d9eefcd8e4114c58626cd29387ed42cef49380ad..7fc796dec25bf9719940f4b143d5008aad043b7e 100644 (file)
@@ -183,6 +183,7 @@ static void free_intremap_entry(const struct amd_iommu *iommu,
                                 unsigned int bdf, unsigned int index)
 {
     union irte_ptr entry = get_intremap_entry(iommu, bdf, index);
+    struct ivrs_mappings *ivrs = get_ivrs_mappings(iommu->seg);
 
     if ( iommu->ctrl.ga_en )
     {
@@ -201,7 +202,7 @@ static void free_intremap_entry(const struct amd_iommu *iommu,
     else
         ACCESS_ONCE(entry.ptr32->raw) = 0;
 
-    __clear_bit(index, get_ivrs_mappings(iommu->seg)[bdf].intremap_inuse);
+    __clear_bit(index, ivrs[bdf].intremap_inuse);
 }
 
 static void update_intremap_entry(const struct amd_iommu *iommu,