ptp: Fix compilation with rustc 1.48

That's currently the minimum version we declare in meson.build but the
latest changes introduced some usage of 1.62 features.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5265>
This commit is contained in:
Sebastian Dröge 2023-08-31 09:04:05 +03:00 committed by GStreamer Marge Bot
parent 9d867356df
commit a0522c8193
2 changed files with 14 additions and 5 deletions

View file

@ -327,8 +327,11 @@ mod imp {
Ok(PollResult { Ok(PollResult {
ready_sockets: &*ready_sockets, ready_sockets: &*ready_sockets,
sockets: &self.sockets, sockets: &self.sockets,
stdin: (self.pollfd[self.pollfd.len() - 1].revents & POLLIN != 0) stdin: if self.pollfd[self.pollfd.len() - 1].revents & POLLIN != 0 {
.then_some(&self.stdin), Some(&self.stdin)
} else {
None
},
stdout: &self.stdout, stdout: &self.stdout,
}) })
} }
@ -866,7 +869,11 @@ mod imp {
Ok(PollResult { Ok(PollResult {
ready_sockets: &*ready_sockets, ready_sockets: &*ready_sockets,
sockets: &self.sockets, sockets: &self.sockets,
stdin: (res == self.handles.len() - 1).then_some(&self.stdin), stdin: if res == self.handles.len() - 1 {
Some(&self.stdin)
} else {
None
},
stdout: &self.stdout, stdout: &self.stdout,
}) })
} }

View file

@ -127,7 +127,7 @@ fn run() -> Result<(), Error> {
let general_socket = let general_socket =
create_socket(PTP_GENERAL_PORT).context("Failed creating general socket")?; create_socket(PTP_GENERAL_PORT).context("Failed creating general socket")?;
for socket in [&event_socket, &general_socket] { for socket in [&event_socket, &general_socket].iter() {
net::join_multicast_v4(socket, &PTP_MULTICAST_ADDR, iface) net::join_multicast_v4(socket, &PTP_MULTICAST_ADDR, iface)
.context("Failed to join multicast group")?; .context("Failed to join multicast group")?;
} }
@ -201,7 +201,9 @@ fn run() -> Result<(), Error> {
Err(err) => { Err(err) => {
bail!( bail!(
source: err, source: err,
"Failed reading from {:?} socket for interface {}", type_, idx, "Failed reading from {:?} socket for interface {}",
type_,
idx,
); );
} }
Ok((read, addr)) => (read, addr), Ok((read, addr)) => (read, addr),