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

[xen master] bitmap: fix nbits signess



commit 5704923f9477afa17c29d23a01d28f20fac346fb
Author:     Stefano Stabellini <stefano.stabellini@xxxxxxx>
AuthorDate: Tue Oct 17 14:04:36 2023 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xxxxxxx>
CommitDate: Tue Nov 7 12:38:50 2023 -0800

    bitmap: fix nbits signess
    
    To avoid potentially dangerous sign conversions in bitmap_switch, all
    the callers of the bitmap_switch macro (which are all within bitmap.h)
    should pass an unsigned int as first parameter.
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/include/xen/bitmap.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
index 3caf92c76d..657390e32e 100644
--- a/xen/include/xen/bitmap.h
+++ b/xen/include/xen/bitmap.h
@@ -110,7 +110,7 @@ extern int bitmap_allocate_region(unsigned long *bitmap, 
int pos, int order);
                large;                                                    \
        }
 
-static inline void bitmap_zero(unsigned long *dst, int nbits)
+static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
 {
        bitmap_switch(nbits,,
                *dst = 0UL,
@@ -134,7 +134,7 @@ static inline void bitmap_fill(unsigned long *dst, int 
nbits)
 }
 
 static inline void bitmap_copy(unsigned long *dst, const unsigned long *src,
-                       int nbits)
+                       unsigned int nbits)
 {
        bitmap_switch(nbits,,
                *dst = *src,
@@ -142,7 +142,7 @@ static inline void bitmap_copy(unsigned long *dst, const 
unsigned long *src,
 }
 
 static inline void bitmap_and(unsigned long *dst, const unsigned long *src1,
-                       const unsigned long *src2, int nbits)
+                       const unsigned long *src2, unsigned int nbits)
 {
        bitmap_switch(nbits,,
                *dst = *src1 & *src2,
@@ -150,7 +150,7 @@ static inline void bitmap_and(unsigned long *dst, const 
unsigned long *src1,
 }
 
 static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
-                       const unsigned long *src2, int nbits)
+                       const unsigned long *src2, unsigned int nbits)
 {
        bitmap_switch(nbits,,
                *dst = *src1 | *src2,
@@ -158,7 +158,7 @@ static inline void bitmap_or(unsigned long *dst, const 
unsigned long *src1,
 }
 
 static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1,
-                       const unsigned long *src2, int nbits)
+                       const unsigned long *src2, unsigned int nbits)
 {
        bitmap_switch(nbits,,
                *dst = *src1 ^ *src2,
@@ -166,7 +166,7 @@ static inline void bitmap_xor(unsigned long *dst, const 
unsigned long *src1,
 }
 
 static inline void bitmap_andnot(unsigned long *dst, const unsigned long *src1,
-                       const unsigned long *src2, int nbits)
+                       const unsigned long *src2, unsigned int nbits)
 {
        bitmap_switch(nbits,,
                *dst = *src1 & ~*src2,
@@ -174,7 +174,7 @@ static inline void bitmap_andnot(unsigned long *dst, const 
unsigned long *src1,
 }
 
 static inline void bitmap_complement(unsigned long *dst, const unsigned long 
*src,
-                       int nbits)
+                       unsigned int nbits)
 {
        bitmap_switch(nbits,,
                *dst = ~*src & BITMAP_LAST_WORD_MASK(nbits),
@@ -182,7 +182,7 @@ static inline void bitmap_complement(unsigned long *dst, 
const unsigned long *sr
 }
 
 static inline int bitmap_equal(const unsigned long *src1,
-                       const unsigned long *src2, int nbits)
+                       const unsigned long *src2, unsigned int nbits)
 {
        bitmap_switch(nbits,
                return -1,
@@ -191,7 +191,7 @@ static inline int bitmap_equal(const unsigned long *src1,
 }
 
 static inline int bitmap_intersects(const unsigned long *src1,
-                       const unsigned long *src2, int nbits)
+                       const unsigned long *src2, unsigned int nbits)
 {
        bitmap_switch(nbits,
                return -1,
@@ -200,7 +200,7 @@ static inline int bitmap_intersects(const unsigned long 
*src1,
 }
 
 static inline int bitmap_subset(const unsigned long *src1,
-                       const unsigned long *src2, int nbits)
+                       const unsigned long *src2, unsigned int nbits)
 {
        bitmap_switch(nbits,
                return -1,
@@ -208,7 +208,7 @@ static inline int bitmap_subset(const unsigned long *src1,
                return __bitmap_subset(src1, src2, nbits));
 }
 
-static inline int bitmap_empty(const unsigned long *src, int nbits)
+static inline int bitmap_empty(const unsigned long *src, unsigned int nbits)
 {
        bitmap_switch(nbits,
                return -1,
@@ -216,7 +216,7 @@ static inline int bitmap_empty(const unsigned long *src, 
int nbits)
                return __bitmap_empty(src, nbits));
 }
 
-static inline int bitmap_full(const unsigned long *src, int nbits)
+static inline int bitmap_full(const unsigned long *src, unsigned int nbits)
 {
        bitmap_switch(nbits,
                return -1,
--
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®.