[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/sched: resolve MISRA R18.3 pointer comparison



commit 4263fe42b736596cfa5bfec661f2f55f02759aa7
Author:     Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
AuthorDate: Thu Nov 12 09:22:30 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Nov 12 09:22:30 2026 +0100

    xen/sched: resolve MISRA R18.3 pointer comparison
    
    MISRA C Rule 18.3 states: "The relational operators >, >=, < and <=
    shall not be applied to objects of pointer type except where they
    point into the same object".
    
    sched_spin_lock_double() takes the lock at the lower address first.
    The two spinlock_t pointers are not required to point into the same
    object, so compare the addresses as integers.
    
    unsigned long is the right integer type here. It is pointer-sized on
    every architecture Xen supports, so the cast keeps the full address,
    and an unsigned comparison still means "lower address first". A signed
    long would interpret an address with the high bit set as negative, so
    the order would no longer follow that rule.
    
    No functional change.
    
    Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
---
 xen/common/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 88ae40f954..10b6eecccd 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -377,7 +377,7 @@ static always_inline void sched_spin_lock_double(
     {
         *flags = _spin_lock_irqsave(lock1);
     }
-    else if ( lock1 < lock2 )
+    else if ( (unsigned long)lock1 < (unsigned long)lock2 )
     {
         *flags = _spin_lock_irqsave(lock1);
         _spin_lock(lock2);
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.