summaryrefslogtreecommitdiff
path: root/alsamixer
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2010-02-19 17:07:20 +0100
committerClemens Ladisch <clemens@ladisch.de>2010-02-19 17:07:20 +0100
commit5a016b583b5c949253a9e791ad79f13e54f87054 (patch)
treecfcbe51a01d4c21e66dc132d278770db168803f7 /alsamixer
parent69c6bead434e7a4a546ab1300413312994b93e35 (diff)
alsamixer: fix division by zero
The attempt to divide by max-min fails if a control has only one valid value. In this case, adjust the maximum so that the computation can succeed; the control will look like 0%. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'alsamixer')
-rw-r--r--alsamixer/mixer_display.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/alsamixer/mixer_display.c b/alsamixer/mixer_display.c
index 9eadcc9..260c9b0 100644
--- a/alsamixer/mixer_display.c
+++ b/alsamixer/mixer_display.c
@@ -462,6 +462,8 @@ static void display_control(unsigned int control_index)
err = snd_mixer_selem_get_capture_volume_range(control->elem, &min, &max);
if (err < 0)
return;
+ if (min == max)
+ max = min + 1;
if (control->flags & IS_ACTIVE)
wattrset(mixer_widget.window, 0);