From 40baf35b078b841cefbc55487b657aee25ee3b5f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 6 Feb 2025 14:24:22 -0500 Subject: 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. --- src/x11.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.1