summaryrefslogtreecommitdiff
path: root/rust-src
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-03-04 07:35:29 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-03-04 19:14:50 -0500
commit9fc4b5d675cd6dc0b2503abe95b1c761d8d05abe (patch)
treeb547922481166d5279170a5bce58e58c03dcbbfc /rust-src
parent1ee7dc7a55273d34358a0ee525a9e823c999ffe6 (diff)
rust: Fix ptr casting in Fs::open()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'rust-src')
-rw-r--r--rust-src/bch_bindgen/src/fs.rs11
-rw-r--r--rust-src/bch_bindgen/src/lib.rs2
2 files changed, 5 insertions, 8 deletions
diff --git a/rust-src/bch_bindgen/src/fs.rs b/rust-src/bch_bindgen/src/fs.rs
index 1176846d..b26c51b6 100644
--- a/rust-src/bch_bindgen/src/fs.rs
+++ b/rust-src/bch_bindgen/src/fs.rs
@@ -9,15 +9,12 @@ pub struct Fs {
}
impl Fs {
- pub fn open(devices: &Vec<PathBuf>, opts: c::bch_opts) -> Result<Fs, bch_errcode> {
- let devices: Vec<_> = devices.iter()
- .map(|i| CString::new(i.as_os_str().as_bytes()).unwrap()).collect();
- let dev_c_strs: Vec<_> = devices.iter()
- .map(|i| { let p: *const i8 = i.as_ptr(); p })
+ pub fn open(devs: &Vec<PathBuf>, opts: c::bch_opts) -> Result<Fs, bch_errcode> {
+ let devs: Vec<_> = devs.iter()
+ .map(|i| CString::new(i.as_os_str().as_bytes()).unwrap().into_raw())
.collect();
- let dev_c_strarray: *const *mut i8 = dev_c_strs[..].as_ptr() as *const *mut i8;
- let ret = unsafe { c::bch2_fs_open(dev_c_strarray, dev_c_strs.len() as u32, opts) };
+ let ret = unsafe { c::bch2_fs_open(devs[..].as_ptr(), devs.len() as u32, opts) };
errptr_to_result(ret).map(|fs| Fs { raw: fs})
}
diff --git a/rust-src/bch_bindgen/src/lib.rs b/rust-src/bch_bindgen/src/lib.rs
index 3bc21a18..d2b58511 100644
--- a/rust-src/bch_bindgen/src/lib.rs
+++ b/rust-src/bch_bindgen/src/lib.rs
@@ -91,7 +91,7 @@ impl FromStr for c::btree_id {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let s = CString::new(s).unwrap();
- let p: *const i8 = s.as_ptr();
+ let p = s.as_ptr();
let v = unsafe {c::match_string(c::bch2_btree_ids[..].as_ptr(), (-(1 as isize)) as usize, p)};
if v >= 0 {