]> git.alsa-project.org Git - alsa-utils.git/commitdiff
amixer: fix print_dB for -0.99 .. -0.01 range
authorJaroslav Kysela <perex@perex.cz>
Tue, 28 May 2013 06:43:30 +0000 (08:43 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 28 May 2013 06:43:30 +0000 (08:43 +0200)
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 <GTBecker@RighTime.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
amixer/amixer.c

index 92b0f839fdf64dc798bf42985928b5d5453981a5..fe83b497e83c13c45de60cf2a1064afdc438012f 100644 (file)
@@ -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)