Skip to content

Commit f1679c8

Browse files
committed
fix(test): reliance on nullptr
This now (rightfully) fails in debug mode: rust-lang/rust#134424
1 parent dc8d6bc commit f1679c8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Diff for: ibverbs-sys/src/lib.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn bindgen_test_layout_ibv_wc() {
202202
concat!("Alignment of ", stringify!(ibv_wc))
203203
);
204204
assert_eq!(
205-
unsafe { &(*(0 as *const ibv_wc)).wr_id as *const _ as usize },
205+
std::mem::offset_of!(ibv_wc, wr_id),
206206
0usize,
207207
concat!(
208208
"Alignment of field: ",
@@ -212,7 +212,7 @@ fn bindgen_test_layout_ibv_wc() {
212212
)
213213
);
214214
assert_eq!(
215-
unsafe { &(*(0 as *const ibv_wc)).status as *const _ as usize },
215+
std::mem::offset_of!(ibv_wc, status),
216216
8usize,
217217
concat!(
218218
"Alignment of field: ",
@@ -222,7 +222,7 @@ fn bindgen_test_layout_ibv_wc() {
222222
)
223223
);
224224
assert_eq!(
225-
unsafe { &(*(0 as *const ibv_wc)).opcode as *const _ as usize },
225+
std::mem::offset_of!(ibv_wc, opcode),
226226
12usize,
227227
concat!(
228228
"Alignment of field: ",
@@ -232,7 +232,7 @@ fn bindgen_test_layout_ibv_wc() {
232232
)
233233
);
234234
assert_eq!(
235-
unsafe { &(*(0 as *const ibv_wc)).vendor_err as *const _ as usize },
235+
std::mem::offset_of!(ibv_wc, vendor_err),
236236
16usize,
237237
concat!(
238238
"Alignment of field: ",
@@ -242,7 +242,7 @@ fn bindgen_test_layout_ibv_wc() {
242242
)
243243
);
244244
assert_eq!(
245-
unsafe { &(*(0 as *const ibv_wc)).byte_len as *const _ as usize },
245+
std::mem::offset_of!(ibv_wc, byte_len),
246246
20usize,
247247
concat!(
248248
"Alignment of field: ",
@@ -252,7 +252,7 @@ fn bindgen_test_layout_ibv_wc() {
252252
)
253253
);
254254
assert_eq!(
255-
unsafe { &(*(0 as *const ibv_wc)).qp_num as *const _ as usize },
255+
std::mem::offset_of!(ibv_wc, qp_num),
256256
28usize,
257257
concat!(
258258
"Alignment of field: ",
@@ -262,7 +262,7 @@ fn bindgen_test_layout_ibv_wc() {
262262
)
263263
);
264264
assert_eq!(
265-
unsafe { &(*(0 as *const ibv_wc)).src_qp as *const _ as usize },
265+
std::mem::offset_of!(ibv_wc, src_qp),
266266
32usize,
267267
concat!(
268268
"Alignment of field: ",
@@ -272,7 +272,7 @@ fn bindgen_test_layout_ibv_wc() {
272272
)
273273
);
274274
assert_eq!(
275-
unsafe { &(*(0 as *const ibv_wc)).wc_flags as *const _ as usize },
275+
std::mem::offset_of!(ibv_wc, wc_flags),
276276
36usize,
277277
concat!(
278278
"Alignment of field: ",
@@ -282,7 +282,7 @@ fn bindgen_test_layout_ibv_wc() {
282282
)
283283
);
284284
assert_eq!(
285-
unsafe { &(*(0 as *const ibv_wc)).pkey_index as *const _ as usize },
285+
std::mem::offset_of!(ibv_wc, pkey_index),
286286
40usize,
287287
concat!(
288288
"Alignment of field: ",
@@ -292,7 +292,7 @@ fn bindgen_test_layout_ibv_wc() {
292292
)
293293
);
294294
assert_eq!(
295-
unsafe { &(*(0 as *const ibv_wc)).slid as *const _ as usize },
295+
std::mem::offset_of!(ibv_wc, slid),
296296
42usize,
297297
concat!(
298298
"Alignment of field: ",
@@ -302,7 +302,7 @@ fn bindgen_test_layout_ibv_wc() {
302302
)
303303
);
304304
assert_eq!(
305-
unsafe { &(*(0 as *const ibv_wc)).sl as *const _ as usize },
305+
std::mem::offset_of!(ibv_wc, sl),
306306
44usize,
307307
concat!(
308308
"Alignment of field: ",
@@ -312,7 +312,7 @@ fn bindgen_test_layout_ibv_wc() {
312312
)
313313
);
314314
assert_eq!(
315-
unsafe { &(*(0 as *const ibv_wc)).dlid_path_bits as *const _ as usize },
315+
std::mem::offset_of!(ibv_wc, dlid_path_bits),
316316
45usize,
317317
concat!(
318318
"Alignment of field: ",

0 commit comments

Comments
 (0)