Skip to content

Commit 0c45936

Browse files
committed
Remove cast_ptr macro and cast argv to c_char
1 parent 19df685 commit 0c45936

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

crates/cli/src/lib.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,13 @@ use std::time::Duration;
1212
use std::{env, ffi::CStr};
1313
use std::{fs, thread};
1414

15-
#[macro_export]
16-
macro_rules! cast_ptr {
17-
($ptr:expr) => {{
18-
#[cfg(all(target_arch = "aarch64", target_os = "macos"))]
19-
{
20-
$ptr as *const i8
21-
}
22-
23-
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
24-
{
25-
$ptr as *const u8
26-
}
27-
28-
#[cfg(not(target_arch = "aarch64"))]
29-
{
30-
$ptr as *const i8
31-
}
32-
}};
33-
}
34-
3515
#[no_mangle]
3616
pub extern "C" fn parse_args(argc: usize, argv: *const *const u8) -> i32 {
3717
let string_array = unsafe { std::slice::from_raw_parts(argv, argc) };
3818
let args: Vec<&str> = string_array
3919
.iter()
4020
.map(|&ptr| {
41-
let c_str = unsafe { CStr::from_ptr(cast_ptr!(ptr)) };
21+
let c_str = unsafe { CStr::from_ptr(ptr as *const std::ffi::c_char) };
4222
c_str
4323
.to_str()
4424
.unwrap_or("[Invalid UTF-8 or Non Null-Terminated String]")

0 commit comments

Comments
 (0)