From 3e07e1cdfac63d5fb93260803d16e79f292dae73 Mon Sep 17 00:00:00 2001 From: Alexander Kurz Date: Sat, 13 Feb 2016 10:54:52 +0100 Subject: [PATCH] Helper time_support: const function arguments duration_elapsed and duration_kbps will not modify the struct duration passed as function argument, hence it should be declared const. Change-Id: I459c396952c78e907257e2c2f2c630abde92aaa8 Signed-off-by: Alexander Kurz Reviewed-on: http://openocd.zylin.com/3232 Tested-by: jenkins Reviewed-by: Andreas Fritiofson --- src/helper/time_support.c | 4 ++-- src/helper/time_support.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helper/time_support.c b/src/helper/time_support.c index c5978b423..780eb9694 100644 --- a/src/helper/time_support.c +++ b/src/helper/time_support.c @@ -78,14 +78,14 @@ int duration_measure(struct duration *duration) return retval; } -float duration_elapsed(struct duration *duration) +float duration_elapsed(const struct duration *duration) { float t = duration->elapsed.tv_sec; t += (float)duration->elapsed.tv_usec / 1000000.0; return t; } -float duration_kbps(struct duration *duration, size_t count) +float duration_kbps(const struct duration *duration, size_t count) { return count / (1024.0 * duration_elapsed(duration)); } diff --git a/src/helper/time_support.h b/src/helper/time_support.h index ab839826b..5a95e7eee 100644 --- a/src/helper/time_support.h +++ b/src/helper/time_support.h @@ -55,8 +55,8 @@ int duration_start(struct duration *duration); int duration_measure(struct duration *duration); /** @returns Elapsed time in seconds. */ -float duration_elapsed(struct duration *duration); +float duration_elapsed(const struct duration *duration); /** @returns KB/sec for the elapsed @a duration and @a count bytes. */ -float duration_kbps(struct duration *duration, size_t count); +float duration_kbps(const struct duration *duration, size_t count); #endif /* TIME_SUPPORT_H */