external/alsa-utils
修订版 | c9dc401264ad3c0b621f52e8098e7c1661c50cea (tree) |
---|---|
时间 | 2019-11-21 06:01:26 |
作者 | Rosen Penev <rosenp@gmai...> |
Commiter | Takashi Iwai |
aplay: Limit VUMeter progress bar to 100 for negative as well
While the progress bar cannot be negative, GCC concludes that it can be
and assumes tmp can be written past the end. Fixes this GCC warning:
aplay.c:1747:18: warning: '%02d' directive writing between 2 and 11 bytes
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
@@ -54,6 +54,8 @@ | ||
54 | 54 | #include "formats.h" |
55 | 55 | #include "version.h" |
56 | 56 | |
57 | +#define ABS(a) (a) < 0 ? -(a) : (a) | |
58 | + | |
57 | 59 | #ifdef SND_CHMAP_API_VERSION |
58 | 60 | #define CONFIG_SUPPORT_CHMAP 1 |
59 | 61 | #endif |
@@ -1741,7 +1743,7 @@ static void print_vu_meter_stereo(int *perc, int *maxperc) | ||
1741 | 1743 | line[bar_length + 6 + 1 + p] = '+'; |
1742 | 1744 | else |
1743 | 1745 | line[bar_length - p - 1] = '+'; |
1744 | - if (maxperc[c] > 99) | |
1746 | + if (ABS(maxperc[c]) > 99) | |
1745 | 1747 | sprintf(tmp, "MAX"); |
1746 | 1748 | else |
1747 | 1749 | sprintf(tmp, "%02d%%", maxperc[c]); |