Skip to content

Commit

Permalink
Address andy's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
papertigers committed Nov 21, 2023
1 parent 279673c commit 2e25d56
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion ipcc/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ pub(crate) const LIBIPCC_ERR_KEY_VALTOOLONG: libipcc_err_t = 7;
pub(crate) const LIBIPCC_ERR_KEY_ZERR: libipcc_err_t = 8;
pub(crate) type libipcc_err_t = c_uint;

pub type libipcc_key_flag_t = ::std::os::raw::c_uint;
/// Maxium length of an error message retrieved by libipcc_errmsg().
pub(crate) const LIBIPCC_ERR_LEN: usize = 1024;

pub(crate) type libipcc_key_flag_t = ::std::os::raw::c_uint;

#[link(name = "ipcc")]
extern "C" {
Expand Down
5 changes: 2 additions & 3 deletions ipcc/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ fn ipcc_fatal_error<C: Into<String>>(
let syserr = if syserr == 0 {
"no system errno".to_string()
} else {
let syserr = unsafe { libc::strerror(syserr) };
unsafe { CStr::from_ptr(syserr) }.to_string_lossy().into_owned()
std::io::Error::from_raw_os_error(syserr).to_string()
};
let inner = IpccErrorInner {
context,
Expand All @@ -56,7 +55,7 @@ fn ipcc_fatal_error<C: Into<String>>(
impl IpccHandle {
pub fn new() -> Result<Self, IpccError> {
let mut ipcc_handle: *mut libipcc_handle_t = ptr::null_mut();
let errmsg = CString::new(vec![1; 1024]).unwrap();
let errmsg = CString::new(vec![1; LIBIPCC_ERR_LEN]).unwrap();
let errmsg_len = errmsg.as_bytes().len();
let errmsg_ptr = errmsg.into_raw();
let mut lerr = LIBIPCC_ERR_OK;
Expand Down
2 changes: 1 addition & 1 deletion ipcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub struct IpccErrorInner {
pub syserr: String,
}

/// These are the IPCC keys we can lookup.
/// These are the IPCC keys we can look up.
/// NB: These keys match the definitions found in libipcc (RFD 316) and should
/// match the values in `[ipcc::Key]` one-to-one.
#[derive(Debug, Clone, Copy)]
Expand Down

0 comments on commit 2e25d56

Please sign in to comment.