Skip to content

Commit b85b2e7

Browse files
authored
Merge pull request #1573 from yishaih/verbs_misc
libibverbs: Fix cast-align warning with verbs_get_ctx().
2 parents d253f15 + 36461e3 commit b85b2e7

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ include(RDMA_DoFixup)
188188
include(publish_headers)
189189
include(rdma_functions)
190190
include(pyverbs_functions)
191+
192+
check_c_compiler_flag("-Wcast-align=strict" HAVE_WCAST_ALIGN_STRICT)
193+
191194
if (NO_MAN_PAGES)
192195
# define empty stub functions to omit man page processing
193196
function(rdma_man_pages)

libibverbs/examples/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ add_library(ibverbs_tools STATIC
33
pingpong.c
44
)
55

6+
if(HAVE_WCAST_ALIGN_STRICT)
7+
target_compile_options(ibverbs_tools PRIVATE "-Wcast-align=strict")
8+
endif()
9+
610
rdma_executable(ibv_asyncwatch asyncwatch.c)
711
target_link_libraries(ibv_asyncwatch LINK_PRIVATE ibverbs)
812

libibverbs/verbs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2220,7 +2220,7 @@ static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx)
22202220
return NULL;
22212221

22222222
/* open code container_of to not pollute the global namespace */
2223-
return (struct verbs_context *)(((uint8_t *)ctx) -
2223+
return (struct verbs_context *)(((uintptr_t)ctx) -
22242224
offsetof(struct verbs_context,
22252225
context));
22262226
}

0 commit comments

Comments
 (0)