Skip to content

Commit 8e84090

Browse files
committed
Explicitly cast pointers for AArch64 compatibility
Implicitly, pointers are i8 on x86_64 and u8 on AArch64. Cast them explicitly so we can compile cleaner in the later architecture. Signed-off-by: Sergio Lopez <[email protected]>
1 parent b841e3e commit 8e84090

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/start.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ unsafe fn exec_vm(vmcfg: &VmConfig, rootfs: &str, cmd: &str, args: Vec<CString>)
7777
}
7878

7979
let c_rootfs = CString::new(rootfs).unwrap();
80-
let ret = bindings::krun_set_root(ctx, c_rootfs.as_ptr());
80+
let ret = bindings::krun_set_root(ctx, c_rootfs.as_ptr() as *const i8);
8181
if ret < 0 {
8282
println!("Error setting VM rootfs");
8383
std::process::exit(-1);
@@ -92,7 +92,7 @@ unsafe fn exec_vm(vmcfg: &VmConfig, rootfs: &str, cmd: &str, args: Vec<CString>)
9292
}
9393
let mut ps: Vec<*const i8> = Vec::new();
9494
for port in ports.iter() {
95-
ps.push(port.as_ptr());
95+
ps.push(port.as_ptr() as *const i8);
9696
}
9797
ps.push(std::ptr::null());
9898
let ret = bindings::krun_set_port_map(ctx, ps.as_ptr());
@@ -102,30 +102,35 @@ unsafe fn exec_vm(vmcfg: &VmConfig, rootfs: &str, cmd: &str, args: Vec<CString>)
102102
}
103103

104104
let c_workdir = CString::new(vmcfg.workdir.clone()).unwrap();
105-
let ret = bindings::krun_set_workdir(ctx, c_workdir.as_ptr());
105+
let ret = bindings::krun_set_workdir(ctx, c_workdir.as_ptr() as *const i8);
106106
if ret < 0 {
107107
println!("Error setting VM workdir");
108108
std::process::exit(-1);
109109
}
110110

111111
let mut argv: Vec<*const i8> = Vec::new();
112112
for a in args.iter() {
113-
argv.push(a.as_ptr());
113+
argv.push(a.as_ptr() as *const i8);
114114
}
115115
argv.push(std::ptr::null());
116116

117117
let hostname = CString::new(format!("HOSTNAME={}", vmcfg.name)).unwrap();
118118
let home = CString::new("HOME=/root").unwrap();
119119
let path = CString::new("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin").unwrap();
120120
let env: [*const i8; 4] = [
121-
hostname.as_ptr(),
122-
home.as_ptr(),
123-
path.as_ptr(),
121+
hostname.as_ptr() as *const i8,
122+
home.as_ptr() as *const i8,
123+
path.as_ptr() as *const i8,
124124
std::ptr::null(),
125125
];
126126

127127
let c_cmd = CString::new(cmd).unwrap();
128-
let ret = bindings::krun_set_exec(ctx, c_cmd.as_ptr(), argv.as_ptr(), env.as_ptr());
128+
let ret = bindings::krun_set_exec(
129+
ctx,
130+
c_cmd.as_ptr() as *const i8,
131+
argv.as_ptr() as *const *const i8,
132+
env.as_ptr() as *const *const i8,
133+
);
129134
if ret < 0 {
130135
println!("Error setting VM config");
131136
std::process::exit(-1);

0 commit comments

Comments
 (0)