From c62977cf563a64823c5c6ebb78e983f9fd125107 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Fri, 15 Apr 2022 20:12:06 +0200 Subject: [PATCH] ash/entry: Fix `trivial_casts` lint warning on Android/aarch64 (#612) On certain platforms including Android and `aarch64` `c_char` is unsigned, resulting in the same `u8` type as the byte-string here making the cast redundant. Just like any other code calling `get_instance_proc_addr`, use `CStr::from_bytes_with_nul_unchecked` which abstracts away any pointer-cast. --- ash/src/entry.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ash/src/entry.rs b/ash/src/entry.rs index e323aa0..b27fd64 100644 --- a/ash/src/entry.rs +++ b/ash/src/entry.rs @@ -194,10 +194,12 @@ impl Entry { unsafe { let mut api_version = 0; let enumerate_instance_version: Option = { - let name = b"vkEnumerateInstanceVersion\0".as_ptr() as *const _; + let name = ::std::ffi::CStr::from_bytes_with_nul_unchecked( + b"vkEnumerateInstanceVersion\0", + ); mem::transmute((self.static_fn.get_instance_proc_addr)( vk::Instance::null(), - name, + name.as_ptr(), )) }; if let Some(enumerate_instance_version) = enumerate_instance_version {