diff --git a/src/header/sys_time/mod.rs b/src/header/sys_time/mod.rs index 940b0c9c04..a935c3734d 100644 --- a/src/header/sys_time/mod.rs +++ b/src/header/sys_time/mod.rs @@ -131,11 +131,11 @@ pub unsafe extern "C" fn utimes(path: *const c_char, times: *const timeval) -> c [ timespec { tv_sec: unsafe { (*times.offset(0)).tv_sec }, - tv_nsec: (unsafe { (*times.offset(0)).tv_usec } as c_long) * 1000, + tv_nsec: c_long::from(unsafe { (*times.offset(0)).tv_usec }) * 1000, }, timespec { tv_sec: unsafe { (*times.offset(1)).tv_sec }, - tv_nsec: (unsafe { (*times.offset(1)).tv_usec } as c_long) * 1000, + tv_nsec: c_long::from(unsafe { (*times.offset(1)).tv_usec }) * 1000, }, ] .as_ptr() diff --git a/src/header/time/mod.rs b/src/header/time/mod.rs index 59ce7d1423..fd0ba15035 100644 --- a/src/header/time/mod.rs +++ b/src/header/time/mod.rs @@ -480,7 +480,7 @@ pub unsafe extern "C" fn timelocal(tm: *mut tm) -> time_t { (*tm).tm_wday = dt.weekday().num_days_from_sunday() as _; (*tm).tm_yday = dt.ordinal0() as _; // day of year starting at 0 (*tm).tm_isdst = dt.offset().dst_offset().num_hours() as _; - (*tm).tm_gmtoff = dt.offset().fix().local_minus_utc() as _; + (*tm).tm_gmtoff = dt.offset().fix().local_minus_utc().into(); (*tm).tm_zone = tz_name.into_raw().cast(); } @@ -714,7 +714,7 @@ unsafe fn datetime_to_tm(local_time: &DateTime) -> tm { let offset = local_time.offset(); t.tm_isdst = offset.dst_offset().num_hours() as _; // Get the UTC offset in seconds - t.tm_gmtoff = offset.fix().local_minus_utc() as _; + t.tm_gmtoff = offset.fix().local_minus_utc().into(); let tm_zone = { let mut timezone_names = TIMEZONE_NAMES.lock(); diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 9004fef384..f842b9d4ae 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -1160,9 +1160,13 @@ pub unsafe extern "C" fn unlink(path: *const c_char) -> c_int { #[deprecated] #[unsafe(no_mangle)] pub extern "C" fn usleep(useconds: useconds_t) -> c_int { + #[cfg(not(target_arch = "x86"))] + let tv_nsec = c_long::from((useconds % 1_000_000) * 1000); + #[cfg(target_arch = "x86")] + let tv_nsec = ((useconds % 1_000_000) * 1000) as c_long; let rqtp = timespec { tv_sec: time_t::from(useconds / 1_000_000), - tv_nsec: ((useconds % 1_000_000) * 1000) as c_long, + tv_nsec, }; let rmtp = ptr::null_mut(); unsafe { Sys::nanosleep(&raw const rqtp, rmtp) } diff --git a/src/ld_so/linker.rs b/src/ld_so/linker.rs index b6e7013034..9a4a0591cd 100644 --- a/src/ld_so/linker.rs +++ b/src/ld_so/linker.rs @@ -561,10 +561,10 @@ impl Linker { let _ = self.objects.remove(&obj.id).unwrap(); for dep in obj.dependencies() { - if let Some(name) = self.name_to_object_id_map.get(*dep) { - if let Some(object_name) = self.objects.get(name) { - self.unload(ObjectHandle::new(object_name.clone())); - } + if let Some(name) = self.name_to_object_id_map.get(*dep) + && let Some(object_name) = self.objects.get(name) + { + self.unload(ObjectHandle::new(object_name.clone())); } } self.name_to_object_id_map.remove(&obj.name);