From: Alexander Kurz Date: Sat, 13 Feb 2016 09:54:52 +0000 (+0100) Subject: Helper time_support: const function arguments X-Git-Tag: v0.10.0-rc1~273 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3e07e1cdfac63d5fb93260803d16e79f292dae73;p=openocd 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 --- diff --git a/src/helper/time_support.c b/src/helper/time_support.c index c5978b42..780eb969 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 ab839826..5a95e7ee 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 */