Skip to content

Commit 37f0fbe

Browse files
mayastor-borsmaxwnewcomer
andcommitted
Merge #1796
1796: fix: proper to_ptr type cast to c_char r=tiagolobocastro a=maxwnewcomer ## Platform agnostic `c_char` type casting Instead of hard-casting to `i8` or `u8` we can just cast to the built in `std::os::raw::c_char`. This change allows for full `arm64` compilation of mayastor. ### Related - Fixes #1795 - Part of the fix to #1751 (not including `spdk-rs` changes) Co-authored-by: Max Newcomer <[email protected]>
2 parents 687da6c + 79c0bbe commit 37f0fbe

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

io-engine/src/bdev/ftl.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use std::{
4242
collections::HashMap,
4343
convert::TryFrom,
4444
fmt::{Debug, Formatter},
45+
os::raw::c_char,
4546
};
4647

4748
use core::ffi::c_void;
@@ -210,9 +211,9 @@ impl CreateDestroy for Ftl {
210211
..unsafe { mem::zeroed() }
211212
};
212213
unsafe { spdk_ftl_get_default_conf(&mut ftl_conf, spdk_ftl_conf_size) };
213-
ftl_conf.name = ftl_dev_name.as_ptr() as *mut i8;
214-
ftl_conf.base_bdev = base_dev_name.as_ptr() as *mut i8;
215-
ftl_conf.cache_bdev = cache_dev_name.as_ptr() as *mut i8;
214+
ftl_conf.name = ftl_dev_name.as_ptr() as *mut c_char;
215+
ftl_conf.base_bdev = base_dev_name.as_ptr() as *mut c_char;
216+
ftl_conf.cache_bdev = cache_dev_name.as_ptr() as *mut c_char;
216217
ftl_conf.fast_shutdown = true;
217218
ftl_conf.verbose_mode = true;
218219
ftl_conf.mode = spdk_ftl_mode::SPDK_FTL_MODE_CREATE as u32;

io-engine/tests/memory_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{collections::HashMap, ffi::CString, ptr::null_mut};
1+
use std::{collections::HashMap, ffi::CString, os::raw::c_char, ptr::null_mut};
22

33
use once_cell::sync::OnceCell;
44

@@ -16,7 +16,7 @@ fn get_ms() -> &'static MayastorTest<'static> {
1616
struct TestCtx {
1717
id: u64,
1818
pos: u32,
19-
ctx: *const i8,
19+
ctx: *const c_char,
2020
}
2121

2222
const POOL_SIZE: u64 = 128 * 1024 - 1;

libnvme-rs/src/nvme_uri.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{convert::TryFrom, io, time::Duration};
1+
use std::{convert::TryFrom, io, os::raw::c_char, time::Duration};
22

33
use url::{ParseError, Url};
44

@@ -15,14 +15,14 @@ use crate::{
1515

1616
/// Wrapper for caller-owned C-strings from libnvme
1717
pub struct NvmeStringWrapper {
18-
s: *mut i8,
18+
s: *mut c_char,
1919
}
2020

2121
impl NvmeStringWrapper {
22-
pub fn new(s: *mut i8) -> Self {
22+
pub fn new(s: *mut c_char) -> Self {
2323
NvmeStringWrapper { s }
2424
}
25-
pub fn as_ptr(&self) -> *const i8 {
25+
pub fn as_ptr(&self) -> *const c_char {
2626
self.s
2727
}
2828
}

0 commit comments

Comments
 (0)