Skip to content

Commit

Permalink
regenerate driver-bindings with Default
Browse files Browse the repository at this point in the history
Use latest version of bindgen (0.62) and add Default to implementations.
This fixes `clippy::derivable_impls` warning and rust-lang/rust-bindgen#1651.

Signed-off-by: Petre Eftime <[email protected]>
  • Loading branch information
Petre Eftime authored and petreeftime committed Nov 21, 2022
1 parent 11633c0 commit 7539fc4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion driver-bindings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Supported Linux versions:
Generate bindings for a new Linux version:

```
bindgen --allowlist-type "ne_.*" --allowlist-var "NE_ERR_.*" -o bindings.rs \
bindgen --with-derive-default --allowlist-type "ne_.*" --allowlist-var "NE_ERR_.*" -o bindings.rs \
/usr/src/kernels/$(uname -r)/include/uapi/linux/nitro_enclaves.h -- \
-fretain-comments-from-system-headers -fparse-all-comments
```
Expand Down
38 changes: 19 additions & 19 deletions driver-bindings/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.59.2 */
/* automatically generated by rust-bindgen 0.62.0 */

pub const NE_ERR_VCPU_ALREADY_USED: u32 = 256;
pub const NE_ERR_VCPU_NOT_IN_CPU_POOL: u32 = 257;
Expand Down Expand Up @@ -28,13 +28,15 @@ pub type __u64 = ::std::os::raw::c_ulonglong;
#[doc = " @memory_offset:\tOffset in enclave memory where to start placing the"]
#[doc = "\t\t\tenclave image (out)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ne_image_load_info {
pub flags: __u64,
pub memory_offset: __u64,
}
#[test]
fn bindgen_test_layout_ne_image_load_info() {
const UNINIT: ::std::mem::MaybeUninit<ne_image_load_info> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ne_image_load_info>(),
16usize,
Expand All @@ -46,7 +48,7 @@ fn bindgen_test_layout_ne_image_load_info() {
concat!("Alignment of ", stringify!(ne_image_load_info))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<ne_image_load_info>())).flags as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
Expand All @@ -56,9 +58,7 @@ fn bindgen_test_layout_ne_image_load_info() {
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<ne_image_load_info>())).memory_offset as *const _ as usize
},
unsafe { ::std::ptr::addr_of!((*ptr).memory_offset) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
Expand All @@ -75,14 +75,17 @@ fn bindgen_test_layout_ne_image_load_info() {
#[doc = " @userspace_addr:\tThe start address of the userspace allocated memory of"]
#[doc = "\t\t\tthe memory region to set for an enclave (in)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ne_user_memory_region {
pub flags: __u64,
pub memory_size: __u64,
pub userspace_addr: __u64,
}
#[test]
fn bindgen_test_layout_ne_user_memory_region() {
const UNINIT: ::std::mem::MaybeUninit<ne_user_memory_region> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ne_user_memory_region>(),
24usize,
Expand All @@ -94,7 +97,7 @@ fn bindgen_test_layout_ne_user_memory_region() {
concat!("Alignment of ", stringify!(ne_user_memory_region))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<ne_user_memory_region>())).flags as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
Expand All @@ -104,9 +107,7 @@ fn bindgen_test_layout_ne_user_memory_region() {
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<ne_user_memory_region>())).memory_size as *const _ as usize
},
unsafe { ::std::ptr::addr_of!((*ptr).memory_size) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
Expand All @@ -116,9 +117,7 @@ fn bindgen_test_layout_ne_user_memory_region() {
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<ne_user_memory_region>())).userspace_addr as *const _ as usize
},
unsafe { ::std::ptr::addr_of!((*ptr).userspace_addr) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
Expand All @@ -134,13 +133,16 @@ fn bindgen_test_layout_ne_user_memory_region() {
#[doc = "\t\t\tinput, the CID is autogenerated by the hypervisor and"]
#[doc = "\t\t\treturned back as output by the driver (in / out)."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ne_enclave_start_info {
pub flags: __u64,
pub enclave_cid: __u64,
}
#[test]
fn bindgen_test_layout_ne_enclave_start_info() {
const UNINIT: ::std::mem::MaybeUninit<ne_enclave_start_info> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ne_enclave_start_info>(),
16usize,
Expand All @@ -152,7 +154,7 @@ fn bindgen_test_layout_ne_enclave_start_info() {
concat!("Alignment of ", stringify!(ne_enclave_start_info))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<ne_enclave_start_info>())).flags as *const _ as usize },
unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
Expand All @@ -162,9 +164,7 @@ fn bindgen_test_layout_ne_enclave_start_info() {
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<ne_enclave_start_info>())).enclave_cid as *const _ as usize
},
unsafe { ::std::ptr::addr_of!((*ptr).enclave_cid) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
Expand Down
4 changes: 0 additions & 4 deletions driver-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@
#![allow(missing_docs)]
#![allow(non_camel_case_types)]

// Keep this until https://github.com/rust-lang/rust-bindgen/issues/1651 is fixed.
#[cfg_attr(test, allow(deref_nullptr))]
mod bindings;
pub use self::bindings::*;
mod wrappers;
pub use self::wrappers::*;
13 changes: 0 additions & 13 deletions driver-bindings/src/wrappers.rs

This file was deleted.

0 comments on commit 7539fc4

Please sign in to comment.