diff options
| author | Quentin Young <qlyoung@users.noreply.github.com> | 2019-07-11 16:05:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-11 16:05:03 -0400 |
| commit | 11dbb76eebf6ff88fae886c4a483746c1015f5bb (patch) | |
| tree | 74c9fa606a710dea7099541e2ab8bf7bfd6a569e /lib/monotime.h | |
| parent | 84f4f72638d7f82fbbcb65599d8a27e7ef88bc8c (diff) | |
| parent | c9049b920fc1ee2965f43f12816dfd1c5991fbe2 (diff) | |
Merge pull request #4674 from mjstapp/fix_mono_ctime
lib,zebra: avoid use of ctime in monotime api
Diffstat (limited to 'lib/monotime.h')
| -rw-r--r-- | lib/monotime.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/monotime.h b/lib/monotime.h index 6aac966ea1..ca27c45dc6 100644 --- a/lib/monotime.h +++ b/lib/monotime.h @@ -84,7 +84,10 @@ static inline int64_t monotime_until(const struct timeval *ref, return (int64_t)tv.tv_sec * 1000000LL + tv.tv_usec; } -static inline char *time_to_string(time_t ts) +/* Char buffer size for time-to-string api */ +#define MONOTIME_STRLEN 32 + +static inline char *time_to_string(time_t ts, char *buf) { struct timeval tv; time_t tbuf; @@ -92,7 +95,7 @@ static inline char *time_to_string(time_t ts) monotime(&tv); tbuf = time(NULL) - (tv.tv_sec - ts); - return ctime(&tbuf); + return ctime_r(&tbuf, buf); } #ifdef __cplusplus |
