aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2025-02-06 14:24:22 -0500
committerDavid Robillard <d@drobilla.net>2025-02-06 14:32:37 -0500
commit40baf35b078b841cefbc55487b657aee25ee3b5f (patch)
treeaa82cd7ec127d8aaa91f2743f3040a96c85dab4a
parentb559cfbd322597f5e405fc94c288a0f5bf2238d6 (diff)
downloadpugl-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.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/x11.c b/src/x11.c
index 9583296..3cde709 100644
--- a/src/x11.c
+++ b/src/x11.c
@@ -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;
}