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 <akurz@blala.de>
Reviewed-on: http://openocd.zylin.com/3232
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
__archive__
Alexander Kurz 2016-02-13 10:54:52 +01:00 committed by Andreas Fritiofson
parent fdb8c598ec
commit 3e07e1cdfa
2 changed files with 4 additions and 4 deletions

View File

@ -78,14 +78,14 @@ int duration_measure(struct duration *duration)
return retval; return retval;
} }
float duration_elapsed(struct duration *duration) float duration_elapsed(const struct duration *duration)
{ {
float t = duration->elapsed.tv_sec; float t = duration->elapsed.tv_sec;
t += (float)duration->elapsed.tv_usec / 1000000.0; t += (float)duration->elapsed.tv_usec / 1000000.0;
return t; 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)); return count / (1024.0 * duration_elapsed(duration));
} }

View File

@ -55,8 +55,8 @@ int duration_start(struct duration *duration);
int duration_measure(struct duration *duration); int duration_measure(struct duration *duration);
/** @returns Elapsed time in seconds. */ /** @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. */ /** @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 */ #endif /* TIME_SUPPORT_H */