From c7e68dd3316db98f796784eafd7fd611bc0d0fd4 Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Fri, 18 Jul 2025 17:18:51 +0200 Subject: [PATCH] refactor: improve conditional compilation in get_pipe_open_options - Replace multiple early returns with a single mutable variable approach - Add conditional allow(unused_mut) attribute for non-Linux platforms - Makes the code more concise while maintaining the same functionality --- src/run/runner/wall_time/perf/fifo.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/run/runner/wall_time/perf/fifo.rs b/src/run/runner/wall_time/perf/fifo.rs index 1020a80d..f4b418da 100644 --- a/src/run/runner/wall_time/perf/fifo.rs +++ b/src/run/runner/wall_time/perf/fifo.rs @@ -20,17 +20,21 @@ pub struct RunnerFifo { ctl_fifo: TokioPipeReader, } +fn get_pipe_open_options() -> TokioPipeOpenOptions { + #[cfg_attr(not(target_os = "linux"), allow(unused_mut))] + let mut options = TokioPipeOpenOptions::new(); + #[cfg(target_os = "linux")] + options.read_write(true); + options +} + impl RunnerFifo { pub fn new() -> anyhow::Result { create_fifo(RUNNER_CTL_FIFO)?; create_fifo(RUNNER_ACK_FIFO)?; - let ack_fifo = TokioPipeOpenOptions::new() - .read_write(true) - .open_sender(RUNNER_ACK_FIFO)?; - let ctl_fifo = TokioPipeOpenOptions::new() - .read_write(true) - .open_receiver(RUNNER_CTL_FIFO)?; + let ack_fifo = get_pipe_open_options().open_sender(RUNNER_ACK_FIFO)?; + let ctl_fifo = get_pipe_open_options().open_receiver(RUNNER_CTL_FIFO)?; Ok(Self { ctl_fifo, ack_fifo }) } @@ -80,12 +84,8 @@ impl PerfFifo { create_fifo(&ctl_fifo_path)?; create_fifo(&ack_fifo_path)?; - let ack_fifo = TokioPipeOpenOptions::new() - .read_write(true) - .open_receiver(&ack_fifo_path)?; - let ctl_fifo = TokioPipeOpenOptions::new() - .read_write(true) - .open_sender(&ctl_fifo_path)?; + let ack_fifo = get_pipe_open_options().open_receiver(&ack_fifo_path)?; + let ctl_fifo = get_pipe_open_options().open_sender(&ctl_fifo_path)?; Ok(Self { ctl_fifo,