diff options
| author | Mark Stapp <mjs@voltanet.io> | 2019-07-10 10:16:59 -0400 | 
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2019-07-10 10:16:59 -0400 | 
| commit | c9049b920fc1ee2965f43f12816dfd1c5991fbe2 (patch) | |
| tree | 51e5948d9dde774691abb58a7472a5574bf97637 /lib/monotime.h | |
| parent | e712856d8ebb94605944adf91a31e4cb1095fc84 (diff) | |
lib,zebra: avoid use of ctime in monotime api
Replace a call to ctime with ctime_r in the monotime module;
update the callers of the monotime api.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
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  | 
