[PATCH] verbs: fix compilation warning with C++20

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

 



Our customer reported the below warning whe using Clang v16.0.4 and C++20,
on a code that includes the header "/usr/include/infiniband/verbs.h":

error: bitwise operation between different enumeration types ('ibv_access_flags' and
'ib_uverbs_access_flags') is deprecated [-Werror,-Wdeprecated-enum-enum-conversion]
                mem->mr = ibv_reg_mr(dev->pd, (void*)start, len, IBV_ACCESS_LOCAL_WRITE);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/infiniband/verbs.h:2514:19: note: expanded from macro 'ibv_reg_mr'
                             ((access) & IBV_ACCESS_OPTIONAL_RANGE) == 0))
                              ~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

According to the article "Clang 11 warning: Bitwise operation between different
enumeration types is deprecated":

C++20's P1120R0 deprecated bitwise operations between different enums. Such code is
likely to become ill-formed in C++23. Clang 11 warns about such cases. It should be fixed.

Reported-by: Rogerio Moraes <rogerio@xxxxxxxxxxx>
Signed-off-by: Daniel Vacek <neelx@xxxxxxxxxx>
---
 libibverbs/verbs.h     | 4 +++-
 libibverbs/verbs_api.h | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h
index 03a7a2a7..85995abe 100644
--- a/libibverbs/verbs.h
+++ b/libibverbs/verbs.h
@@ -617,7 +617,9 @@ enum ibv_access_flags {
 	IBV_ACCESS_HUGETLB		= (1<<7),
 	IBV_ACCESS_FLUSH_GLOBAL		= (1 << 8),
 	IBV_ACCESS_FLUSH_PERSISTENT	= (1 << 9),
-	IBV_ACCESS_RELAXED_ORDERING	= IBV_ACCESS_OPTIONAL_FIRST,
+
+	IBV_ACCESS_RELAXED_ORDERING	= IBV_ACCESS_OPTIONAL_FIRST,		// bit 20
+	IBV_ACCESS_OPTIONAL_RANGE	= IB_UVERBS_ACCESS_OPTIONAL_RANGE	// mask of bits 20-29
 };
 
 struct ibv_mw_bind_info {
diff --git a/libibverbs/verbs_api.h b/libibverbs/verbs_api.h
index 309f6fba..7a5f0cdf 100644
--- a/libibverbs/verbs_api.h
+++ b/libibverbs/verbs_api.h
@@ -94,7 +94,6 @@
 
 #define IBV_QPF_GRH_REQUIRED				IB_UVERBS_QPF_GRH_REQUIRED
 
-#define IBV_ACCESS_OPTIONAL_RANGE			IB_UVERBS_ACCESS_OPTIONAL_RANGE
 #define IBV_ACCESS_OPTIONAL_FIRST			IB_UVERBS_ACCESS_OPTIONAL_FIRST
 #endif
 
-- 
2.40.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux