diff options
| author | Rafael Zalamena <rzalamena@users.noreply.github.com> | 2020-08-06 19:49:14 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-06 19:49:14 +0000 |
| commit | 084cb7525441d2d2a6f9401741ebe692d7ec7981 (patch) | |
| tree | 9c66d1a1a7b48da3a6db37d5a2e379ae1b2c32a1 /lib/thread.c | |
| parent | 67ac9b3fff569702d911cfa721ed9bbc4e4fe8e5 (diff) | |
| parent | df98b92c12066db2130bfed489762d99892aff86 (diff) | |
Merge pull request #6587 from AnuradhaKaruppiah/evpn-mh-pr-1
EVPN Multihoming part-1
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/thread.c b/lib/thread.c index 5c7c104842..1df4eee25c 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -634,6 +634,36 @@ struct timeval thread_timer_remain(struct thread *thread) return remain; } +static int time_hhmmss(char *buf, int buf_size, long sec) +{ + long hh; + long mm; + int wr; + + zassert(buf_size >= 8); + + hh = sec / 3600; + sec %= 3600; + mm = sec / 60; + sec %= 60; + + wr = snprintf(buf, buf_size, "%02ld:%02ld:%02ld", hh, mm, sec); + + return wr != 8; +} + +char *thread_timer_to_hhmmss(char *buf, int buf_size, + struct thread *t_timer) +{ + if (t_timer) { + time_hhmmss(buf, buf_size, + thread_timer_remain_second(t_timer)); + } else { + snprintf(buf, buf_size, "--:--:--"); + } + return buf; +} + /* Get new thread. */ static struct thread *thread_get(struct thread_master *m, uint8_t type, int (*func)(struct thread *), void *arg, |
