summaryrefslogtreecommitdiff
path: root/libc/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps')
-rw-r--r--libc/sysdeps/linux/common/clock_getres.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libc/sysdeps/linux/common/clock_getres.c b/libc/sysdeps/linux/common/clock_getres.c
index 8ee782845..93487c3d2 100644
--- a/libc/sysdeps/linux/common/clock_getres.c
+++ b/libc/sysdeps/linux/common/clock_getres.c
@@ -18,15 +18,18 @@ libc_hidden_proto(sysconf)
int clock_getres(clockid_t clock_id, struct timespec* res)
{
- long clk_tck;
int retval = -1;
switch (clock_id) {
case CLOCK_REALTIME:
- if ((clk_tck = sysconf(_SC_CLK_TCK)) < 0)
- clk_tck = 100;
- res->tv_sec = 0;
- res->tv_nsec = 1000000000 / clk_tck;
+ if (res) {
+ long clk_tck;
+
+ if ((clk_tck = sysconf(_SC_CLK_TCK)) < 0)
+ clk_tck = 100;
+ res->tv_sec = 0;
+ res->tv_nsec = 1000000000 / clk_tck;
+ }
retval = 0;
break;