[ovs-dev] [PATCH v2] lib/util.h: use types compatible with DWORD

Nithin Raju nithin at vmware.com
Thu Feb 12 18:53:10 UTC 2015


_BitScanForward() and friends are part of the Windows API and
take DWORD as parameter type. DWORD is defined to be 'unsigned long'
in Windows' header files.

We call into these functions from within lib/util.h. Currently, we
pass arguments of type uint32_t which is type defined to
'unsigned int'. This incompatiblity causes failures when we compile
the code as C++ code or with warnings enabled, when compiled as C
code.

The fix is to use 'unsigned long' rather than fixed size type.

Signed-off-by: Nithin Raju <nithin at vmware.com>
Signed-off-by: Linda Sun <lsun at vmware.com>
Co-Authored-by: Linda Sun <lsun at vmware.com>
---
 lib/util.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/util.h b/lib/util.h
index cbaa3ac..276edb5 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -352,11 +352,11 @@ static inline int
 raw_ctz(uint64_t n)
 {
 #ifdef _WIN64
-    uint32_t r = 0;
+    unsigned long r = 0;
     _BitScanForward64(&r, n);
     return r;
 #else
-    uint32_t low = n, high, r = 0;
+    unsigned long low = n, high, r = 0;
     if (_BitScanForward(&r, low)) {
         return r;
     }
@@ -370,11 +370,11 @@ static inline int
 raw_clz64(uint64_t n)
 {
 #ifdef _WIN64
-    uint32_t r = 0;
+    unsigned long r = 0;
     _BitScanReverse64(&r, n);
     return 63 - r;
 #else
-    uint32_t low, high = n >> 32, r = 0;
+    unsigned long low, high = n >> 32, r = 0;
     if (_BitScanReverse(&r, high)) {
         return 31 - r;
     }
-- 
1.9.4.msysgit.2




More information about the dev mailing list