Commit f77c6e9c authored by Ramkumar Ramachandra's avatar Ramkumar Ramachandra Committed by Arnaldo Carvalho de Melo

perf tools: Generalize percent_color_snprintf()

Make percent_color_snprintf() handle negative values correctly.
Signed-off-by: default avatarRamkumar Ramachandra <artagnon@gmail.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1388388861-7931-2-git-send-email-artagnon@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 741a0c59
#include <linux/kernel.h> #include <linux/kernel.h>
#include "cache.h" #include "cache.h"
#include "color.h" #include "color.h"
#include <math.h>
int perf_use_color_default = -1; int perf_use_color_default = -1;
...@@ -298,10 +299,10 @@ const char *get_percent_color(double percent) ...@@ -298,10 +299,10 @@ const char *get_percent_color(double percent)
* entries in green - and keep the low overhead places * entries in green - and keep the low overhead places
* normal: * normal:
*/ */
if (percent >= MIN_RED) if (fabs(percent) >= MIN_RED)
color = PERF_COLOR_RED; color = PERF_COLOR_RED;
else { else {
if (percent > MIN_GREEN) if (fabs(percent) > MIN_GREEN)
color = PERF_COLOR_GREEN; color = PERF_COLOR_GREEN;
} }
return color; return color;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment