]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Use fabs() for floating point, labs() for long
authorWolfgang Stöggl <c72578@yahoo.de>
Wed, 3 Apr 2019 16:13:33 +0000 (18:13 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Thu, 4 Apr 2019 07:35:26 +0000 (09:35 +0200)
- Fixes the following clang compiler warnings:
  rrd_rpncalc.c:999:11: warning: using integer absolute value function
  'abs' when argument is of floating point type [-Wabsolute-value]
    if (abs(percentile) > 100) {
  rrd_rpncalc.c:1103:24: warning: using integer absolute value function
  'abs' when argument is of floating point type [-Wabsolute-value]
    int idx = round(abs(idxf));
  rrd_hw.c:519:36: warning: absolute value function 'abs' given an
  argument of type 'long' but has parameter of type 'int' which may
  cause truncation of value [-Wabsolute-value]
    new_val = ((unsigned long) abs(val)) % mod;

src/rrd_hw.c
src/rrd_rpncalc.c

index 9ce351f8c6a3d2e4e0630947b6401971e92e5772..bc919ac4aa2e61c80885714e845eedb075298f83 100644 (file)
@@ -516,7 +516,7 @@ static unsigned long MyMod(
     unsigned long new_val;
 
     if (val < 0)
-        new_val = ((unsigned long) abs(val)) % mod;
+        new_val = ((unsigned long) labs(val)) % mod;
     else
         new_val = (val % mod);
 
index 4f08bfab963cb2126a4c961b1b3787bb741eab10..0211491d77f29920b4e31238d5a68c1c1687af71 100644 (file)
@@ -996,7 +996,7 @@ short rpn_calc(
                if (rpnp[rpi].op == OP_PREDICTPERC) {
                    stackunderflow(1);
                    percentile = rpnstack->s[--stptr];
-                   if (abs(percentile) > 100) {
+                   if (fabs(percentile) > 100) {
                        rrd_set_error("unsupported percentile: %f",percentile);
                        return -1;
                    }
@@ -1100,7 +1100,7 @@ short rpn_calc(
                        /* get the percentile selected */
                        double idxf = percentile * ((float)count-1.0);
                        if (percentile < 0) { /* take the next best */
-                           int idx = round(abs(idxf));
+                           int idx = round(fabs(idxf));
                            val = extra[idx];
                        } else { /* interpolate */
                            int idx = floor(idxf);