Merge pull request #201 from volcano0dr/urts
remove #![feature(ptr_offset_from)] in sgx_urts. Thanks to @volcano0dr !
diff --git a/sgx_urts/src/env.rs b/sgx_urts/src/env.rs
index 39502e3..f079642 100644
--- a/sgx_urts/src/env.rs
+++ b/sgx_urts/src/env.rs
@@ -103,27 +103,27 @@
let mut temp_pwd = &mut *pwd;
let p = -1_isize as usize;
if !temp_pwd.pw_name.is_null() {
- temp_pwd.pw_name = temp_pwd.pw_name.offset_from(buf) as * mut c_char;
+ temp_pwd.pw_name = usize::checked_sub(temp_pwd.pw_name as _, buf as _).unwrap_or(p) as * mut c_char;
} else {
- temp_pwd.pw_name = p as usize as * mut c_char;
+ temp_pwd.pw_name = p as * mut c_char;
}
if !temp_pwd.pw_passwd.is_null() {
- temp_pwd.pw_passwd = temp_pwd.pw_passwd.offset_from(buf) as * mut c_char;
+ temp_pwd.pw_passwd = usize::checked_sub(temp_pwd.pw_passwd as _, buf as _).unwrap_or(p) as * mut c_char;
} else {
- temp_pwd.pw_passwd = p as usize as * mut c_char;
+ temp_pwd.pw_passwd = p as * mut c_char;
}
if !temp_pwd.pw_gecos.is_null() {
- temp_pwd.pw_gecos = temp_pwd.pw_gecos.offset_from(buf) as * mut c_char;
+ temp_pwd.pw_gecos = usize::checked_sub(temp_pwd.pw_gecos as _, buf as _).unwrap_or(p) as * mut c_char;
} else {
temp_pwd.pw_gecos = p as * mut c_char;
}
if !temp_pwd.pw_dir.is_null() {
- temp_pwd.pw_dir = temp_pwd.pw_dir.offset_from(buf) as * mut c_char;
+ temp_pwd.pw_dir = usize::checked_sub(temp_pwd.pw_dir as _, buf as _).unwrap_or(p) as * mut c_char;
} else {
temp_pwd.pw_dir = p as * mut c_char;
}
if !temp_pwd.pw_shell.is_null() {
- temp_pwd.pw_shell = temp_pwd.pw_shell.offset_from(buf) as * mut c_char;
+ temp_pwd.pw_shell = usize::checked_sub(temp_pwd.pw_shell as _, buf as _).unwrap_or(p) as * mut c_char;
} else {
temp_pwd.pw_shell = p as * mut c_char;
}
diff --git a/sgx_urts/src/lib.rs b/sgx_urts/src/lib.rs
index 4c434b6..2019043 100644
--- a/sgx_urts/src/lib.rs
+++ b/sgx_urts/src/lib.rs
@@ -16,7 +16,6 @@
// under the License..
#![allow(clippy::not_unsafe_ptr_arg_deref)]
-#![feature(ptr_offset_from)]
extern crate libc;
extern crate sgx_types;