|
@@ -707,9 +707,13 @@ impl From<NlAttrError> for io::Error {
|
|
|
}
|
|
|
|
|
|
unsafe fn request_attributes<T>(req: &mut T, msg_len: usize) -> &mut [u8] {
|
|
|
- let attrs_addr = align_to(req as *mut _ as usize + msg_len, NLMSG_ALIGNTO as usize);
|
|
|
- let attrs_end = req as *mut _ as usize + mem::size_of::<T>();
|
|
|
- slice::from_raw_parts_mut(attrs_addr as *mut u8, attrs_end - attrs_addr)
|
|
|
+ let req: *mut _ = req;
|
|
|
+ let req: *mut u8 = req.cast();
|
|
|
+ let attrs_addr = req.add(msg_len);
|
|
|
+ let align_offset = attrs_addr.align_offset(NLMSG_ALIGNTO as usize);
|
|
|
+ let attrs_addr = attrs_addr.add(align_offset);
|
|
|
+ let len = mem::size_of::<T>() - msg_len - align_offset;
|
|
|
+ slice::from_raw_parts_mut(attrs_addr, len)
|
|
|
}
|
|
|
|
|
|
fn bytes_of<T>(val: &T) -> &[u8] {
|