From: Lucian Petrut Date: Fri, 26 Aug 2022 12:54:10 +0000 (+0000) Subject: include: fix IS_ERR on Windows X-Git-Tag: v16.2.11~326^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd0cde0939e680549391949f0abe545e42062b6e;p=ceph.git include: fix IS_ERR on Windows The "long" type uses 32b on x64 Windows platforms, which means it's not large enough to store a pointer. intptr_t or uintptr_t should be used instead. This change fixes include/err.h, using the right types. There was a previous patch on this topic but unfortunately it didn't address all the type casts. This issue was brought up by the unittest_crush test, which recently started to fail as the CrushWrapper methods use IS_ERR. Signed-off-by: Lucian Petrut (cherry picked from commit c95b6b6c774da05e989cd09e23eee1eeaa9e6ec2) --- diff --git a/src/include/err.h b/src/include/err.h index 2c63b69909bb..c188e97532f4 100644 --- a/src/include/err.h +++ b/src/include/err.h @@ -5,10 +5,11 @@ * adapted from linux 2.6.24 include/linux/err.h */ #define MAX_ERRNO 4095 -#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) +#define IS_ERR_VALUE(x) ((x) >= (uintptr_t)-MAX_ERRNO) #include #include +#include /* this generates a warning in c++; caller can do the cast manually static inline void *ERR_PTR(long error) @@ -17,12 +18,12 @@ static inline void *ERR_PTR(long error) } */ -static inline long PTR_ERR(const void *ptr) +static inline intptr_t PTR_ERR(const void *ptr) { - return (uintptr_t) ptr; + return (intptr_t) ptr; } -static inline long IS_ERR(const void *ptr) +static inline bool IS_ERR(const void *ptr) { return IS_ERR_VALUE((uintptr_t)ptr); }