summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/status_cmd.rs2
-rw-r--r--src/utils.rs7
-rw-r--r--src/wm_info_provider/hyprland.rs2
3 files changed, 4 insertions, 7 deletions
diff --git a/src/status_cmd.rs b/src/status_cmd.rs
index 243b209..68dd1b7 100644
--- a/src/status_cmd.rs
+++ b/src/status_cmd.rs
@@ -38,7 +38,7 @@ impl StatusCmd {
}
pub fn receive_blocks(&mut self) -> Result<Option<Vec<Block>>> {
- match read_to_vec(&mut self.output, &mut self.buf) {
+ match read_to_vec(&self.output, &mut self.buf) {
Ok(0) => bail!("status command exited"),
Ok(_n) => (),
Err(e) if e.kind() == ErrorKind::WouldBlock => return Ok(None),
diff --git a/src/utils.rs b/src/utils.rs
index 128493d..c7913f1 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -9,11 +9,8 @@ use serde_json::{Deserializer, Error as JsonError};
/// Read from a raw file descriptor to the vector.
///
/// Appends data at the end of the buffer. Resizes vector as needed.
-#[allow(clippy::needless_pass_by_ref_mut)]
-pub fn read_to_vec(fd: &mut impl AsFd, buf: &mut Vec<u8>) -> io::Result<usize> {
- if buf.capacity() - buf.len() < 1024 {
- buf.reserve(buf.capacity().max(1024));
- }
+pub fn read_to_vec(fd: impl AsFd, buf: &mut Vec<u8>) -> io::Result<usize> {
+ buf.reserve(1024);
let res = unsafe {
libc::read(
diff --git a/src/wm_info_provider/hyprland.rs b/src/wm_info_provider/hyprland.rs
index 16a58a3..d1ab42c 100644
--- a/src/wm_info_provider/hyprland.rs
+++ b/src/wm_info_provider/hyprland.rs
@@ -153,7 +153,7 @@ impl Ipc {
self.sock2_buf.drain(..=i);
return Ok(event);
}
- if read_to_vec(&mut self.sock2, &mut self.sock2_buf)? == 0 {
+ if read_to_vec(&self.sock2, &mut self.sock2_buf)? == 0 {
return Err(io::Error::new(
io::ErrorKind::BrokenPipe,
"hyprland socked disconnected",