]> www.infradead.org Git - mtd-utils.git/commitdiff
jittertest: Use the appropriate versions of abs()
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 2 Nov 2017 00:10:11 +0000 (01:10 +0100)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Fri, 3 Nov 2017 18:41:32 +0000 (19:41 +0100)
When passing a long argument, actually use labs().

The other case of passing a float to "int abs(int)" and
casting the result to an int doesn't really make sense.
Pull the cast inside the abs().

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
tests/jittertest/JitterTest.c
tests/jittertest/plotJittervsFill.c

index 4627fb07af1400202aa326e50b956ece79c6d21a..e1099959d0f697426b36f5151f60d9e9d43fbd9f 100644 (file)
@@ -591,12 +591,12 @@ void AlarmHandler(
 
 
         /* Store some historical #'s */
-        if(abs(timeDiffusec) > LastMaxDiff)
+        if(labs(timeDiffusec) > LastMaxDiff)
        {
-            LastMaxDiff = abs(timeDiffusec);
+            LastMaxDiff = labs(timeDiffusec);
             sprintf(&tmpBuf[strlen(tmpBuf)],"!");
 
-           if((GrabKProfile == TRUE) && (ProfileTriggerMSecs < (abs(timeDiffusec)/1000)))
+           if((GrabKProfile == TRUE) && (ProfileTriggerMSecs < (labs(timeDiffusec)/1000)))
              {
                  sprintf(profileFileName, "JitterTest.profilesnap-%i", profileFileNo);
 
index 8d71a337f7e192872a90ae32d1d9f77043113346..03929a962ee34415758cb3db852a54c6e2dee30a 100644 (file)
@@ -267,7 +267,7 @@ int main(
         }
 
         /* Is the jitter value > threshold value? */
-        if(abs(jitter_ms) > JitterThreshold_ms)
+        if(abs((int)jitter_ms) > JitterThreshold_ms)
         {
             /* Found a jitter line that matches our crietrion.
                Now set flag to be on the look out for the next
@@ -276,7 +276,7 @@ int main(
 
             if(saveJitterCnt < MAX_SAVE_BUFFER)
             {
-                saveJitter[saveJitterCnt] = (int)abs(jitter_ms); /* why keep the (ms) jitter in float */
+                saveJitter[saveJitterCnt] = abs((int)jitter_ms); /* why keep the (ms) jitter in float */
                 dataLineNo[saveJitterCnt] = lineNo;
                 saveJitterCnt++;
                 lookFor_df = TRUE;