From: Andrei Tatar Date: Tue, 7 Nov 2023 14:06:48 +0000 (+0100) Subject: lib/posix-time: Allow NULL arg in clock_getres X-Git-Tag: RELEASE-0.16.0~205 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7153f4aa4aecaacd674a1315a2b2613fd4ac456f;p=unikraft%2Funikraft.git lib/posix-time: Allow NULL arg in clock_getres This change fixes the behavior of clock_getres to not return an error when receiving a NULL as its output argument, in accordance with docs. Signed-off-by: Andrei Tatar Reviewed-by: Simon Kuenzer Approved-by: Simon Kuenzer GitHub-Closes: #1154 --- diff --git a/lib/posix-time/time.c b/lib/posix-time/time.c index a34ef4781..fbbd5c79a 100644 --- a/lib/posix-time/time.c +++ b/lib/posix-time/time.c @@ -149,17 +149,14 @@ UK_SYSCALL_R_DEFINE(int, clock_getres, clockid_t, clk_id, { int error; - if (!tp) { - error = EFAULT; - goto out_error; - } - switch (clk_id) { case CLOCK_MONOTONIC: case CLOCK_MONOTONIC_COARSE: case CLOCK_REALTIME: - tp->tv_sec = 0; - tp->tv_nsec = UKPLAT_TIME_TICK_NSEC; + if (tp) { + tp->tv_sec = 0; + tp->tv_nsec = UKPLAT_TIME_TICK_NSEC; + } break; default: error = EINVAL;