From d8a963aa9c93ac68746fff49f6b2fc6b5ceb6af6 Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Wed, 11 Sep 2024 10:38:57 +0200 Subject: [PATCH] [#264] Fix review findings --- iceoryx2-ffi/cxx/src/config.cpp | 7 +++-- iceoryx2-ffi/ffi/src/api/config.rs | 47 +++++++++--------------------- 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/iceoryx2-ffi/cxx/src/config.cpp b/iceoryx2-ffi/cxx/src/config.cpp index 4ca0c0574..bc78ff953 100644 --- a/iceoryx2-ffi/cxx/src/config.cpp +++ b/iceoryx2-ffi/cxx/src/config.cpp @@ -376,10 +376,11 @@ void Service::set_dynamic_config_storage_suffix(const iox::FileName& value) && { auto Service::creation_timeout() && -> iox::units::Duration { auto* ref_handle = iox2_cast_config_ref_h(*m_config); - auto secs = iox2_config_global_service_creation_timeout_sec(ref_handle); - auto nsec = iox2_config_global_service_creation_timeout_nsec_frac(ref_handle); + uint64_t secs = 0; + uint32_t nsecs = 0; + iox2_config_global_service_creation_timeout(ref_handle, &secs, &nsecs); - return iox::units::Duration::fromSeconds(secs) + iox::units::Duration::fromNanoseconds(nsec); + return iox::units::Duration::fromSeconds(secs) + iox::units::Duration::fromNanoseconds(nsecs); } void Service::set_creation_timeout(const iox::units::Duration& value) && { diff --git a/iceoryx2-ffi/ffi/src/api/config.rs b/iceoryx2-ffi/ffi/src/api/config.rs index d7a64794d..522303661 100644 --- a/iceoryx2-ffi/ffi/src/api/config.rs +++ b/iceoryx2-ffi/ffi/src/api/config.rs @@ -189,6 +189,7 @@ pub unsafe extern "C" fn iox2_config_from_file( config_file: *const c_char, ) -> c_int { debug_assert!(!handle_ptr.is_null()); + debug_assert!(!config_file.is_null()); let file = match FilePath::from_c_str(config_file) { Ok(file) => file, @@ -878,50 +879,28 @@ pub unsafe extern "C" fn iox2_config_global_service_set_dynamic_config_storage_s } } -/// Returns the second part of the time of how long another process will wait until the service +/// Returns the duration how long another process will wait until the service /// creation is finalized /// /// # Safety /// /// * `handle` - A valid non-owning [`iox2_config_ref_h`] obtained by [`iox2_cast_config_ref_h`]. +/// * `secs` - A valid pointer pointing to a [`u64`]. +/// * `nsecs` - A valid pointer pointing to a [`u32`] #[no_mangle] -pub unsafe extern "C" fn iox2_config_global_service_creation_timeout_sec( +pub unsafe extern "C" fn iox2_config_global_service_creation_timeout( handle: iox2_config_ref_h, -) -> u64 { - debug_assert!(!handle.is_null()); - - let config = &*handle.as_type(); - config - .value - .as_ref() - .value - .global - .service - .creation_timeout - .as_secs() -} - -/// Returns the nano second part of the time of how long another process will wait until the service -/// creation is finalized -/// -/// # Safety -/// -/// * `handle` - A valid non-owning [`iox2_config_ref_h`] obtained by [`iox2_cast_config_ref_h`]. -#[no_mangle] -pub unsafe extern "C" fn iox2_config_global_service_creation_timeout_nsec_frac( - handle: iox2_config_ref_h, -) -> u32 { + secs: *mut u64, + nsecs: *mut u32, +) { debug_assert!(!handle.is_null()); + debug_assert!(!secs.is_null()); + debug_assert!(!nsecs.is_null()); let config = &*handle.as_type(); - config - .value - .as_ref() - .value - .global - .service - .creation_timeout - .subsec_nanos() + let timeout = config.value.as_ref().value.global.service.creation_timeout; + *secs = timeout.as_secs(); + *nsecs = timeout.subsec_nanos(); } /// Sets the creation timeout