This is an automated email from Gerrit.

"Jan Matyas <jan.mat...@codasip.com>" just uploaded a new patch set to Gerrit, 
which you can find at https://review.openocd.org/c/openocd/+/8750

-- gerrit

commit 1e3b8b16d05a35128e7da70c118248ff008deed9
Author: Jan Matyas <jan.mat...@codasip.com>
Date:   Sun Feb 9 19:19:50 2025 +0100

    helper/bits.h: Avoid -Wconversion warnings
    
    -Wconversion warnings are not enabled now, but hopefully could
    be enabled one day (at least for parts of the OpenOCD codebase).
    
    This patch avoids a "size_t to unsigned int" conversion warning
    in bitmap_zero().
    
    Since bits.h is included into most of the codebase, this fix
    reduces the overall amount of -Wconversion significantly.
    
    Change-Id: I702c9079081a09faf7b16ef34b4470a33d1cf6e1
    Signed-off-by: Jan Matyas <jan.mat...@codasip.com>

diff --git a/src/helper/bits.h b/src/helper/bits.h
index 4e2a3456cf..c0e028f497 100644
--- a/src/helper/bits.h
+++ b/src/helper/bits.h
@@ -23,7 +23,7 @@
 #define BITS_PER_LONG_LONG          (BITS_PER_BYTE * sizeof(long long))
 #define GENMASK(h, l)               (((~0UL) - (1UL << (l)) + 1) & (~0UL >> 
(BITS_PER_LONG - 1 - (h))))
 #define GENMASK_ULL(h, l)           (((~0ULL) - (1ULL << (l)) + 1) & (~0ULL >> 
(BITS_PER_LONG_LONG - 1 - (h))))
-#define BITS_TO_LONGS(nr)           DIV_ROUND_UP(nr, BITS_PER_BYTE * 
sizeof(long))
+#define BITS_TO_LONGS(nr)           DIV_ROUND_UP(nr, BITS_PER_LONG)
 #define BIT_MASK(nr)                (1UL << ((nr) % BITS_PER_LONG))
 #define BIT_WORD(nr)                ((nr) / BITS_PER_LONG)
 #define DECLARE_BITMAP(name, bits)  unsigned long name[BITS_TO_LONGS(bits)]
@@ -33,9 +33,9 @@
  * @param dst the address of the bitmap
  * @param nbits the number of bits to clear
  */
-static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
+static inline void bitmap_zero(unsigned long *dst, size_t nbits)
 {
-       unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+       const size_t len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
        memset(dst, 0, len);
 }
 

-- 

Reply via email to