diff options
author | David Robillard <d@drobilla.net> | 2025-02-06 14:24:22 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2025-02-06 14:32:37 -0500 |
commit | 40baf35b078b841cefbc55487b657aee25ee3b5f (patch) | |
tree | aa82cd7ec127d8aaa91f2743f3040a96c85dab4a | |
parent | b559cfbd322597f5e405fc94c288a0f5bf2238d6 (diff) | |
download | pugl-40baf35b078b841cefbc55487b657aee25ee3b5f.tar.gz pugl-40baf35b078b841cefbc55487b657aee25ee3b5f.tar.bz2 pugl-40baf35b078b841cefbc55487b657aee25ee3b5f.zip |
X11: Gracefully handle failure of clock_gettime()
As gracefully as possible given the API anyway. I don't think this is an error
case that happens enough to really need transparent error handling, if the
clock doesn't work all is lost anyway.
Appeases cert-err33-c, which started caring about clock_gettime() in clang-tidy
19.
-rw-r--r-- | src/x11.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -1872,7 +1872,10 @@ double puglGetTime(const PuglWorld* const world) { struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); + if (clock_gettime(CLOCK_MONOTONIC, &ts)) { + return 0.0; + } + return ((double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0) - world->startTime; } |