~tsdh/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH swayrbar] Don't crash on empty wpctl output

Details
Message ID
<20241004195350.21744-1-bitraid@protonmail.ch>
DKIM signature
pass
Download raw message
Patch: +6 -4
---
 swayrbar/src/module/wpctl.rs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/swayrbar/src/module/wpctl.rs b/swayrbar/src/module/wpctl.rs
index be9f4f4..b51b268 100644
--- a/swayrbar/src/module/wpctl.rs
+++ b/swayrbar/src/module/wpctl.rs
@@ -52,10 +52,12 @@ fn run_wpctl(args: &[&str]) -> String {
fn get_volume(device: &str) -> (u8, bool) {
    let output = run_wpctl(&["get-volume", device]);
    let mut volume = String::new();
    VOLUME_RX
        .captures(&output)
        .unwrap()
        .expand("$num$frac", &mut volume);
    if !output.is_empty() {
        VOLUME_RX
            .captures(&output)
            .unwrap()
            .expand("$num$frac", &mut volume);
    }
    (volume.parse::<u8>().unwrap_or(255_u8), output.contains("[MUTED]"))
}

-- 
2.46.2
Details
Message ID
<87msjj9fhu.fsf@gnu.org>
In-Reply-To
<20241004195350.21744-1-bitraid@protonmail.ch> (view parent)
DKIM signature
pass
Download raw message
bitraid <bitraid@protonmail.ch> writes:

Applied, thanks!  Just for me to know how serious that issue is: under
what conditions does wpctl give empty output?

Bye,
  Tassilo
> ---
>  swayrbar/src/module/wpctl.rs | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/swayrbar/src/module/wpctl.rs b/swayrbar/src/module/wpctl.rs
> index be9f4f4..b51b268 100644
> --- a/swayrbar/src/module/wpctl.rs
> +++ b/swayrbar/src/module/wpctl.rs
> @@ -52,10 +52,12 @@ fn run_wpctl(args: &[&str]) -> String {
>  fn get_volume(device: &str) -> (u8, bool) {
>      let output = run_wpctl(&["get-volume", device]);
>      let mut volume = String::new();
> -    VOLUME_RX
> -        .captures(&output)
> -        .unwrap()
> -        .expand("$num$frac", &mut volume);
> +    if !output.is_empty() {
> +        VOLUME_RX
> +            .captures(&output)
> +            .unwrap()
> +            .expand("$num$frac", &mut volume);
> +    }
>      (volume.parse::<u8>().unwrap_or(255_u8), output.contains("[MUTED]"))
>  }
Details
Message ID
<bO3JNaJC4IlyEQO14eVKU_wk4_MICX2KBFVsffjhiOOw5C2uYsTY6tWG7AcZbznunueE8_lsPvV97BVndeSerMsJOUk4iaffDT-PGGWA3z0=@protonmail.ch>
In-Reply-To
<87msjj9fhu.fsf@gnu.org> (view parent)
DKIM signature
pass
Download raw message
I've only seen this on system startup, where the server isn't ready yet. There is a message on stderr, and stdout is empty.

On Saturday, October 5th, 2024 at 10:27, Tassilo Horn <tsdh@gnu.org> wrote:

> bitraid bitraid@protonmail.ch writes:
> 
> 
> Applied, thanks! Just for me to know how serious that issue is: under
> what conditions does wpctl give empty output?
> 
> Bye,
> Tassilo
> 
> > ---
> > swayrbar/src/module/wpctl.rs | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> > 
> > diff --git a/swayrbar/src/module/wpctl.rs b/swayrbar/src/module/wpctl.rs
> > index be9f4f4..b51b268 100644
> > --- a/swayrbar/src/module/wpctl.rs
> > +++ b/swayrbar/src/module/wpctl.rs
> > @@ -52,10 +52,12 @@ fn run_wpctl(args: &[&str]) -> String {
> > fn get_volume(device: &str) -> (u8, bool) {
> > let output = run_wpctl(&["get-volume", device]);
> > let mut volume = String::new();
> > - VOLUME_RX
> > - .captures(&output)
> > - .unwrap()
> > - .expand("$num$frac", &mut volume);
> > + if !output.is_empty() {
> > + VOLUME_RX
> > + .captures(&output)
> > + .unwrap()
> > + .expand("$num$frac", &mut volume);
> > + }
> > (volume.parse::<u8>().unwrap_or(255_u8), output.contains("[MUTED]"))
> > }
Details
Message ID
<87jzempctg.fsf@gnu.org>
In-Reply-To
<bO3JNaJC4IlyEQO14eVKU_wk4_MICX2KBFVsffjhiOOw5C2uYsTY6tWG7AcZbznunueE8_lsPvV97BVndeSerMsJOUk4iaffDT-PGGWA3z0=@protonmail.ch> (view parent)
DKIM signature
pass
Download raw message
bitraid <bitraid@protonmail.ch> writes:

> I've only seen this on system startup, where the server isn't ready
> yet. There is a message on stderr, and stdout is empty.

I've released 0.4.2 just now.  Better be safe than sorry.

Thanks,
  Tassilo
Reply to thread Export thread (mbox)