Skip to content

Commit

Permalink
Use uninit() instead of -1 for file descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Nov 13, 2023
1 parent abdbff2 commit df84beb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions ash/src/extensions/khr/external_fence_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ impl ExternalFenceFd {
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetFenceFdKHR.html>
#[inline]
pub unsafe fn get_fence_fd(&self, get_info: &vk::FenceGetFdInfoKHR<'_>) -> VkResult<i32> {
let mut fd = -1;
(self.fp.get_fence_fd_khr)(self.handle, get_info, &mut fd).result_with_success(fd)
let mut fd = mem::MaybeUninit::uninit();
(self.fp.get_fence_fd_khr)(self.handle, get_info, fd.as_mut_ptr())
.assume_init_on_success(fd)
}

pub const NAME: &'static CStr = vk::KhrExternalFenceFdFn::NAME;
Expand Down
5 changes: 3 additions & 2 deletions ash/src/extensions/khr/external_memory_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ impl ExternalMemoryFd {
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryFdKHR.html>
#[inline]
pub unsafe fn get_memory_fd(&self, get_fd_info: &vk::MemoryGetFdInfoKHR<'_>) -> VkResult<i32> {
let mut fd = -1;
(self.fp.get_memory_fd_khr)(self.handle, get_fd_info, &mut fd).result_with_success(fd)
let mut fd = mem::MaybeUninit::uninit();
(self.fp.get_memory_fd_khr)(self.handle, get_fd_info, fd.as_mut_ptr())
.assume_init_on_success(fd)
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryFdPropertiesKHR.html>
Expand Down
5 changes: 3 additions & 2 deletions ash/src/extensions/khr/external_semaphore_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ impl ExternalSemaphoreFd {
&self,
get_info: &vk::SemaphoreGetFdInfoKHR<'_>,
) -> VkResult<i32> {
let mut fd = -1;
(self.fp.get_semaphore_fd_khr)(self.handle, get_info, &mut fd).result_with_success(fd)
let mut fd = mem::MaybeUninit::uninit();
(self.fp.get_semaphore_fd_khr)(self.handle, get_info, fd.as_mut_ptr())
.assume_init_on_success(fd)
}

pub const NAME: &'static CStr = vk::KhrExternalSemaphoreFdFn::NAME;
Expand Down

0 comments on commit df84beb

Please sign in to comment.