]> git.cworth.org Git - fips/commitdiff
Use consistent argument order for subtract functions and macros.
authorCarl Worth <cworth@cworth.org>
Tue, 12 Nov 2013 18:30:18 +0000 (10:30 -0800)
committerCarl Worth <cworth@cworth.org>
Tue, 12 Nov 2013 18:30:18 +0000 (10:30 -0800)
We were calling subtract_timestamp() on the line just before
TIMESPEC_DIFF() but with reversed argument order in the two. This
could obviously lead to convention. So we stick adopt the (a - b)
convention for both, (as well as the name "subtract" for both).

metrics.c

index c52bf2ee6c3557dd6b8b41dda820ac24bced4e5b..7b2a558985d525d554c89b23047d4aee550cbb8a 100644 (file)
--- a/metrics.c
+++ b/metrics.c
@@ -819,9 +819,9 @@ metrics_collect_available (metrics_t *metrics)
        }
 }
 
-/* Return the difference from ts0 to ts1 as floating-point seconds. */
-#define TIMESPEC_DIFF(ts0, ts1) (double) (ts1.tv_sec - ts0.tv_sec + \
-                                         (ts1.tv_nsec - ts0.tv_nsec) / 1e9)
+/* Subtract timespec values: Return (a - b) in seconds as a double. */
+#define SUBTRACT_TIMESPEC(a, b) (double) (a.tv_sec - b.tv_sec + \
+                                         (a.tv_nsec - b.tv_nsec) / 1e9)
 
 void
 metrics_end_frame_pre_swap (metrics_t *metrics)
@@ -864,7 +864,8 @@ metrics_end_frame_pre_swap (metrics_t *metrics)
                latency_ns = subtract_timestamp (swap_end_timestamp,
                                                 metrics->swap_begin_timestamp);
 
-               cpu_time = TIMESPEC_DIFF (metrics->previous_cpu_time_ts, metrics->cpu_time_ts);
+               cpu_time = SUBTRACT_TIMESPEC (metrics->cpu_time_ts,
+                                             metrics->previous_cpu_time_ts);
 
                /* We've waited one frame to ensure we have a timestamp
                 * result. So the time we've actually measured here is