Skip to content

Commit 246bf3b

Browse files
bors[bot]tamird
andauthored
Merge #1332
1332: Suppress temporary libc deprecations r=asomers a=tamird See individual commits. This PR is an alternative to #1329. @asomers Co-authored-by: Tamir Duberstein <[email protected]>
2 parents 5d2a8c2 + b373f2f commit 246bf3b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/sys/socket/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -847,12 +847,13 @@ impl<'a> ControlMessage<'a> {
847847
}
848848
#[cfg(any(target_os = "android", target_os = "linux"))]
849849
ControlMessage::AlgSetIv(iv) => {
850+
#[allow(deprecated)] // https://github.com/rust-lang/libc/issues/1501
850851
let af_alg_iv = libc::af_alg_iv {
851852
ivlen: iv.len() as u32,
852853
iv: [0u8; 0],
853854
};
854855

855-
let size = mem::size_of::<libc::af_alg_iv>();
856+
let size = mem::size_of_val(&af_alg_iv);
856857

857858
unsafe {
858859
ptr::copy_nonoverlapping(
@@ -915,7 +916,7 @@ impl<'a> ControlMessage<'a> {
915916
}
916917
#[cfg(any(target_os = "android", target_os = "linux"))]
917918
ControlMessage::AlgSetIv(iv) => {
918-
mem::size_of::<libc::af_alg_iv>() + iv.len()
919+
mem::size_of_val(&iv) + iv.len()
919920
},
920921
#[cfg(any(target_os = "android", target_os = "linux"))]
921922
ControlMessage::AlgSetOp(op) => {

src/sys/time.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::{cmp, fmt, ops};
22
use std::time::Duration;
33
use std::convert::From;
44
use libc::{c_long, timespec, timeval};
5+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
56
pub use libc::{time_t, suseconds_t};
67

78
pub trait TimeValLike: Sized {
@@ -69,6 +70,7 @@ impl From<timespec> for TimeSpec {
6970

7071
impl From<Duration> for TimeSpec {
7172
fn from(duration: Duration) -> Self {
73+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
7274
TimeSpec(timespec {
7375
tv_sec: duration.as_secs() as time_t,
7476
tv_nsec: duration.subsec_nanos() as c_long
@@ -117,6 +119,7 @@ impl TimeValLike for TimeSpec {
117119
fn seconds(seconds: i64) -> TimeSpec {
118120
assert!(seconds >= TS_MIN_SECONDS && seconds <= TS_MAX_SECONDS,
119121
"TimeSpec out of bounds; seconds={}", seconds);
122+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
120123
TimeSpec(timespec {tv_sec: seconds as time_t, tv_nsec: 0 })
121124
}
122125

@@ -143,6 +146,7 @@ impl TimeValLike for TimeSpec {
143146
let (secs, nanos) = div_mod_floor_64(nanoseconds, NANOS_PER_SEC);
144147
assert!(secs >= TS_MIN_SECONDS && secs <= TS_MAX_SECONDS,
145148
"TimeSpec out of bounds");
149+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
146150
TimeSpec(timespec {tv_sec: secs as time_t,
147151
tv_nsec: nanos as c_long })
148152
}
@@ -179,6 +183,7 @@ impl TimeSpec {
179183
}
180184
}
181185

186+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
182187
pub fn tv_sec(&self) -> time_t {
183188
self.0.tv_sec
184189
}
@@ -315,6 +320,7 @@ impl TimeValLike for TimeVal {
315320
fn seconds(seconds: i64) -> TimeVal {
316321
assert!(seconds >= TV_MIN_SECONDS && seconds <= TV_MAX_SECONDS,
317322
"TimeVal out of bounds; seconds={}", seconds);
323+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
318324
TimeVal(timeval {tv_sec: seconds as time_t, tv_usec: 0 })
319325
}
320326

@@ -332,6 +338,7 @@ impl TimeValLike for TimeVal {
332338
let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC);
333339
assert!(secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS,
334340
"TimeVal out of bounds");
341+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
335342
TimeVal(timeval {tv_sec: secs as time_t,
336343
tv_usec: micros as suseconds_t })
337344
}
@@ -344,6 +351,7 @@ impl TimeValLike for TimeVal {
344351
let (secs, micros) = div_mod_floor_64(microseconds, MICROS_PER_SEC);
345352
assert!(secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS,
346353
"TimeVal out of bounds");
354+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
347355
TimeVal(timeval {tv_sec: secs as time_t,
348356
tv_usec: micros as suseconds_t })
349357
}
@@ -380,6 +388,7 @@ impl TimeVal {
380388
}
381389
}
382390

391+
#[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848
383392
pub fn tv_sec(&self) -> time_t {
384393
self.0.tv_sec
385394
}

0 commit comments

Comments
 (0)