Skip to content

Commit

Permalink
chore: mark pactffi_logger_attach_sink as unsafe #148
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Sep 24, 2021
1 parent ab89152 commit 40cf1ab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rust/pact_ffi/src/log/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub extern "C" fn pactffi_log_to_stdout(level_filter: LevelFilter) -> c_int {
}
};

let status = pactffi_logger_attach_sink(spec.as_ptr(), level_filter);
let status = unsafe { pactffi_logger_attach_sink(spec.as_ptr(), level_filter) };
if status != 0 {
return status;
}
Expand All @@ -57,7 +57,7 @@ pub extern "C" fn pactffi_log_to_stderr(level_filter: LevelFilter) -> c_int {
}
};

let status = pactffi_logger_attach_sink(spec.as_ptr(), level_filter);
let status = unsafe { pactffi_logger_attach_sink(spec.as_ptr(), level_filter) };
if status != 0 {
return status;
}
Expand Down Expand Up @@ -134,7 +134,7 @@ pub extern "C" fn pactffi_log_to_buffer(level_filter: LevelFilter) -> c_int {
}
};

let status = pactffi_logger_attach_sink(spec.as_ptr(), level_filter);
let status = unsafe { pactffi_logger_attach_sink(spec.as_ptr(), level_filter) };
if status != 0 {
return status;
}
Expand Down Expand Up @@ -228,12 +228,12 @@ pub extern "C" fn pactffi_logger_init() {
#[allow(clippy::missing_safety_doc)]
#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn pactffi_logger_attach_sink(
pub unsafe extern "C" fn pactffi_logger_attach_sink(
sink_specifier: *const c_char,
level_filter: LevelFilter,
) -> c_int {
// Get the specifier from the raw C string.
let sink_specifier = unsafe { CStr::from_ptr(sink_specifier) };
let sink_specifier = CStr::from_ptr(sink_specifier);
let sink_specifier = match sink_specifier.to_str() {
Ok(sink_specifier) => sink_specifier,
// TODO: Permit non-UTF8 strings, as some filesystems may have non-UTF8
Expand Down

0 comments on commit 40cf1ab

Please sign in to comment.