From 9607d9470eec07df817e58f64d312ccb5ac4cfcc Mon Sep 17 00:00:00 2001 From: Cristian Rodríguez Date: Mon, 1 Apr 2013 03:08:05 -0300 Subject: Always use our own MAX/MIN definitions code in src/shared/macro.h only defined MAX/MIN in case they were not defined previously. however the MAX/MIN macros implemented in glibc are not of the "safe" kind but defined as: define MIN(a,b) (((a)<(b))?(a):(b)) define MAX(a,b) (((a)>(b))?(a):(b)) Avoid nasty side effects by using our own versions instead. Also fix the warnings derived from this change. [zj: - modify MAX3 macro to fix warning about _a shadowing _a, - do bootchart/svg.c too, - remove unused MIN3.] --- src/bootchart/svg.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/bootchart/svg.c') diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index 0fb9fffd9b..a4086c5227 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -44,9 +44,6 @@ #define kb_to_graph(m) ((m) * arg_scale_y * 0.0001) #define to_color(n) (192.0 - ((n) * 192.0)) -#define max(x, y) (((x) > (y)) ? (x) : (y)) -#define min(x, y) (((x) < (y)) ? (x) : (y)) - static char str[8092]; #define svg(a...) do { snprintf(str, 8092, ## a); fputs(str, of); fflush(of); } while (0) @@ -441,8 +438,8 @@ static void svg_io_bi_bar(void) { int stop; double tot; - start = max(i - ((range / 2) - 1), 0); - stop = min(i + (range / 2), samples - 1); + start = MAX(i - ((range / 2) - 1), 0); + stop = MIN(i + (range / 2), samples - 1); tot = (double)(blockstat[stop].bi - blockstat[start].bi) / (stop - start); @@ -463,8 +460,8 @@ static void svg_io_bi_bar(void) { double tot; double pbi; - start = max(i - ((range / 2) - 1), 0); - stop = min(i + (range / 2), samples); + start = MAX(i - ((range / 2) - 1), 0); + stop = MIN(i + (range / 2), samples); tot = (double)(blockstat[stop].bi - blockstat[start].bi) / (stop - start); @@ -517,8 +514,8 @@ static void svg_io_bo_bar(void) { int stop; double tot; - start = max(i - ((range / 2) - 1), 0); - stop = min(i + (range / 2), samples - 1); + start = MAX(i - ((range / 2) - 1), 0); + stop = MIN(i + (range / 2), samples - 1); tot = (double)(blockstat[stop].bi - blockstat[start].bi) / (stop - start); @@ -539,8 +536,8 @@ static void svg_io_bo_bar(void) { double tot; double pbo; - start = max(i - ((range / 2) - 1), 0); - stop = min(i + (range / 2), samples); + start = MAX(i - ((range / 2) - 1), 0); + stop = MIN(i + (range / 2), samples); tot = (double)(blockstat[stop].bo - blockstat[start].bo) / (stop - start); -- cgit v1.2.3-54-g00ecf