diff --git a/driver-bindings/src/lib.rs b/driver-bindings/src/lib.rs index e7f0f9032..ee1a33d75 100644 --- a/driver-bindings/src/lib.rs +++ b/driver-bindings/src/lib.rs @@ -7,5 +7,5 @@ #![allow(missing_docs)] #![allow(non_camel_case_types)] -mod bindings; +pub mod bindings; pub use self::bindings::*; diff --git a/src/common/mod.rs b/src/common/mod.rs index c4d7caa14..fafc37d22 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -572,7 +572,7 @@ mod tests { const TMP_DIR_STR: &str = "./tmp_sock_dir"; - fn unset_envvar(varname: &String) { + fn unset_envvar(varname: &str) { unsafe { libc::unsetenv(varname.as_ptr() as *const c_char); }; diff --git a/src/enclave_proc/connection_listener.rs b/src/enclave_proc/connection_listener.rs index 173b63c81..b611f1aed 100644 --- a/src/enclave_proc/connection_listener.rs +++ b/src/enclave_proc/connection_listener.rs @@ -320,7 +320,7 @@ mod tests { const THREADS_STR: &str = "Threads:"; const TMP_DIR: &str = "./npe"; - fn unset_envvar(varname: &String) { + fn unset_envvar(varname: &str) { unsafe { libc::unsetenv(varname.as_ptr() as *const c_char) }; } diff --git a/src/enclave_proc/resource_manager.rs b/src/enclave_proc/resource_manager.rs index 5454d1345..600061cef 100644 --- a/src/enclave_proc/resource_manager.rs +++ b/src/enclave_proc/resource_manager.rs @@ -368,7 +368,7 @@ impl ResourceAllocator { // Always allocate larger pages first, to reduce fragmentation and page count. // Once an allocation of a given page size fails, proceed to the next smaller // page size and retry. - for (_, page_info) in HUGE_PAGE_MAP.iter().enumerate() { + for page_info in HUGE_PAGE_MAP.iter() { while needed_mem >= page_info.1 as i64 { match MemoryRegion::new(page_info.0) { Ok(value) => { @@ -389,7 +389,7 @@ impl ResourceAllocator { // need to allocate in increasing order of page size in order to reduce wastage). if needed_mem > 0 { - for (_, page_info) in HUGE_PAGE_MAP.iter().rev().enumerate() { + for page_info in HUGE_PAGE_MAP.iter().rev() { while needed_mem > 0 { match MemoryRegion::new(page_info.0) { Ok(value) => { @@ -420,7 +420,7 @@ impl ResourceAllocator { .sort_by(|reg1, reg2| reg2.mem_size.cmp(®1.mem_size)); needed_mem = self.requested_mem as i64; - for (_, region) in self.mem_regions.iter().enumerate() { + for region in self.mem_regions.iter() { if needed_mem <= 0 { break; } @@ -434,7 +434,7 @@ impl ResourceAllocator { self.mem_regions.drain(split_index..); // Generate a summary of the allocated memory. - for (_, region) in self.mem_regions.iter().enumerate() { + for region in self.mem_regions.iter() { if let Some(page_count) = allocated_pages.get_mut(®ion.mem_size) { *page_count += 1; } else { diff --git a/tests/test_dev_driver.rs b/tests/test_dev_driver.rs index d9c0307ec..abc062097 100644 --- a/tests/test_dev_driver.rs +++ b/tests/test_dev_driver.rs @@ -14,6 +14,7 @@ use nitro_cli::enclave_proc::resource_manager::{ NE_START_ENCLAVE, }; use nitro_cli::enclave_proc::utils::MiB; +use driver_bindings::bindings::ne_enclave_start_info; const ENCLAVE_MEM_2MB_CHUNKS: u64 = 48; #[cfg(target_arch = "aarch64")] @@ -201,12 +202,12 @@ impl CheckDmesg { ]; let lines = self.get_dmesg_lines().unwrap(); - for i in self.recorded_line..lines.len() { - let upper_line = lines[i].to_uppercase(); + for line in lines.iter().skip(self.recorded_line) { + let upper_line = line.to_uppercase(); for word in checks.iter() { if upper_line.contains(&word.to_uppercase()) { return Err(NitroCliFailure::new() - .add_subaction(format!("Dmesg line: {} contains: {}", lines[i], word)) + .add_subaction(format!("Dmesg line: {} contains: {}", line, word)) .set_error_code(NitroCliErrorEnum::IoctlFailure) .set_file_and_line(file!(), line!())); } @@ -536,14 +537,12 @@ mod test_dev_driver { assert!(result.is_ok()); // Start with an invalid flag. - let mut enclave_start_info = EnclaveStartInfo::default(); - enclave_start_info.flags = 1234; + let enclave_start_info = ne_enclave_start_info { flags: 1234, ..Default::default() }; let result = enclave.start(enclave_start_info); assert!(result.is_err()); // Start with an invalid CID. - let mut enclave_start_info = EnclaveStartInfo::default(); - enclave_start_info.enclave_cid = VMADDR_CID_LOCAL as u64; + let mut enclave_start_info = ne_enclave_start_info { enclave_cid: VMADDR_CID_LOCAL as u64, ..Default::default() }; let result = enclave.start(enclave_start_info); assert!(result.is_err());