Skip to content

Commit eca4819

Browse files
authored
Merge pull request #36 from TrustMeItsCugel/fix/clippy-safety-docs
fix: add missing Safety documentation for FFI functions
2 parents 677a2be + 26fbfec commit eca4819

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

.github/workflows/cross-platform-ffi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- name: Install system dependencies (macOS)
4040
if: matrix.os == 'macos-latest'
4141
run: |
42+
brew uninstall --ignore-dependencies cmake || true
4243
brew install cmake pkg-config
4344
4445
- name: Install system dependencies (Windows)

timelock-ffi/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,10 @@ pub unsafe extern "C" fn timelock_get_last_error() -> *const c_char {
563563

564564
/// Get the version of the timelock library
565565
///
566+
/// # Safety
567+
/// This function is safe to call from any context. It returns a pointer to
568+
/// static string data that remains valid for the lifetime of the program.
569+
///
566570
/// # Returns
567571
/// Null-terminated string with the version (static, no need to free)
568572
#[no_mangle]
@@ -576,6 +580,11 @@ pub unsafe extern "C" fn timelock_get_version() -> *const c_char {
576580
/// Call this function before using any other timelock functions.
577581
/// It's safe to call this multiple times.
578582
///
583+
/// # Safety
584+
/// This function is safe to call from any context and performs internal
585+
/// validation of cryptographic constants. No special safety requirements
586+
/// for the caller.
587+
///
579588
/// # Returns
580589
/// `TimelockResult::Success` on success
581590
#[no_mangle]
@@ -596,6 +605,10 @@ pub unsafe extern "C" fn timelock_init() -> TimelockResult {
596605
///
597606
/// Call this function when you're done using the timelock library.
598607
/// It's safe to call this multiple times.
608+
///
609+
/// # Safety
610+
/// This function is safe to call from any context and only cleans up
611+
/// internal library state. No special safety requirements for the caller.
599612
#[no_mangle]
600613
pub unsafe extern "C" fn timelock_cleanup() {
601614
// Clean up any global resources

0 commit comments

Comments
 (0)