Skip to content

Commit 34f888e

Browse files
t-8chKAGA-KOKO
authored andcommitted
vdso/gettimeofday: Return bool from clock_getres() helpers
The internal helpers are effectively using boolean results, while pretending to use error numbers. Switch the return type to bool for more clarity. Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent ad64d71 commit 34f888e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/vdso/gettimeofday.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,16 +396,16 @@ static __maybe_unused __kernel_old_time_t __cvdso_time(__kernel_old_time_t *time
396396

397397
#ifdef VDSO_HAS_CLOCK_GETRES
398398
static __maybe_unused
399-
int __cvdso_clock_getres_common(const struct vdso_time_data *vd, clockid_t clock,
400-
struct __kernel_timespec *res)
399+
bool __cvdso_clock_getres_common(const struct vdso_time_data *vd, clockid_t clock,
400+
struct __kernel_timespec *res)
401401
{
402402
const struct vdso_clock *vc = vd->clock_data;
403403
u32 msk;
404404
u64 ns;
405405

406406
/* Check for negative values or invalid clocks */
407407
if (unlikely((u32) clock >= MAX_CLOCKS))
408-
return -1;
408+
return false;
409409

410410
if (IS_ENABLED(CONFIG_TIME_NS) &&
411411
vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
@@ -427,23 +427,25 @@ int __cvdso_clock_getres_common(const struct vdso_time_data *vd, clockid_t clock
427427
*/
428428
ns = LOW_RES_NSEC;
429429
} else {
430-
return -1;
430+
return false;
431431
}
432432

433433
if (likely(res)) {
434434
res->tv_sec = 0;
435435
res->tv_nsec = ns;
436436
}
437-
return 0;
437+
return true;
438438
}
439439

440440
static __maybe_unused
441441
int __cvdso_clock_getres_data(const struct vdso_time_data *vd, clockid_t clock,
442442
struct __kernel_timespec *res)
443443
{
444-
int ret = __cvdso_clock_getres_common(vd, clock, res);
444+
bool ok;
445445

446-
if (unlikely(ret))
446+
ok = __cvdso_clock_getres_common(vd, clock, res);
447+
448+
if (unlikely(!ok))
447449
return clock_getres_fallback(clock, res);
448450
return 0;
449451
}
@@ -460,18 +462,18 @@ __cvdso_clock_getres_time32_data(const struct vdso_time_data *vd, clockid_t cloc
460462
struct old_timespec32 *res)
461463
{
462464
struct __kernel_timespec ts;
463-
int ret;
465+
bool ok;
464466

465-
ret = __cvdso_clock_getres_common(vd, clock, &ts);
467+
ok = __cvdso_clock_getres_common(vd, clock, &ts);
466468

467-
if (unlikely(ret))
469+
if (unlikely(!ok))
468470
return clock_getres32_fallback(clock, res);
469471

470472
if (likely(res)) {
471473
res->tv_sec = ts.tv_sec;
472474
res->tv_nsec = ts.tv_nsec;
473475
}
474-
return ret;
476+
return 0;
475477
}
476478

477479
static __maybe_unused int

0 commit comments

Comments
 (0)