diff --git a/rust/suseconnect-agama/src/lib.rs b/rust/suseconnect-agama/src/lib.rs index 24bf0107b3..e313610c6f 100644 --- a/rust/suseconnect-agama/src/lib.rs +++ b/rust/suseconnect-agama/src/lib.rs @@ -1,6 +1,7 @@ use std::{ ffi::{CString, IntoStringError}, fmt::Display, + os::raw::c_char, }; use serde_json::{json, Value}; @@ -8,7 +9,7 @@ use serde_json::{json, Value}; // Safety requirements: inherited from https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.from_ptr // expects that rust gets control of string pointer // note: it is different than libzypp bindings where string is still owned by libzypp -pub(crate) unsafe fn string_from_ptr(c_ptr: *mut i8) -> Result { +pub(crate) unsafe fn string_from_ptr(c_ptr: *mut c_char) -> Result { let c_str = CString::from_raw(c_ptr); c_str.into_string() } diff --git a/rust/zypp-agama/src/helpers.rs b/rust/zypp-agama/src/helpers.rs index 0169f8bb5e..d7ffd9149d 100644 --- a/rust/zypp-agama/src/helpers.rs +++ b/rust/zypp-agama/src/helpers.rs @@ -1,7 +1,7 @@ -use std::os::raw::c_void; +use std::os::raw::{c_char, c_void}; // Safety requirements: inherited from https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.from_ptr -pub(crate) unsafe fn string_from_ptr(c_ptr: *const i8) -> String { +pub(crate) unsafe fn string_from_ptr(c_ptr: *const c_char) -> String { String::from_utf8_lossy(std::ffi::CStr::from_ptr(c_ptr).to_bytes()).into_owned() } diff --git a/rust/zypp-agama/src/lib.rs b/rust/zypp-agama/src/lib.rs index 5379645190..758c23bb81 100644 --- a/rust/zypp-agama/src/lib.rs +++ b/rust/zypp-agama/src/lib.rs @@ -265,7 +265,7 @@ impl Zypp { .iter() .map(|s| CString::new(*s).expect("CString must not contain internal NUL")) .collect(); - let c_ptr_names: Vec<*const i8> = + let c_ptr_names: Vec<*const c_char> = c_names.iter().map(|c| c.as_c_str().as_ptr()).collect(); let pattern_names = PatternNames { size: names.len() as u32,