From c80a38dbf53531d57c9bd4ccdc05553bd7fb79a1 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 28 May 2013 08:43:30 +0200 Subject: [PATCH] amixer: fix print_dB for -0.99 .. -0.01 range The first number is 0 when input dB (hundreds) is in range -99 .. -1 . The printed number was positive in this case. This patch fixes this issue. Reported-by: Tom Becker Signed-off-by: Jaroslav Kysela --- amixer/amixer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/amixer/amixer.c b/amixer/amixer.c index 92b0f83..fe83b49 100644 --- a/amixer/amixer.c +++ b/amixer/amixer.c @@ -431,7 +431,11 @@ static void print_spaces(unsigned int spaces) static void print_dB(long dB) { - printf("%li.%02lidB", dB / 100, (dB < 0 ? -dB : dB) % 100); + if (dB < 0) { + printf("-%li.%02lidB", -dB / 100, -dB % 100); + } else { + printf("%li.%02lidB", dB / 100, dB % 100); + } } static void decode_tlv(unsigned int spaces, unsigned int *tlv, unsigned int tlv_size)