Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250701-vdso-auxclock-v1-5-df7d9f87b9b8@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
34f888e3 ad64d71d

+13 -11
+13 -11
lib/vdso/gettimeofday.c
··· 396 396 397 397 #ifdef VDSO_HAS_CLOCK_GETRES 398 398 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) 401 401 { 402 402 const struct vdso_clock *vc = vd->clock_data; 403 403 u32 msk; ··· 405 405 406 406 /* Check for negative values or invalid clocks */ 407 407 if (unlikely((u32) clock >= MAX_CLOCKS)) 408 - return -1; 408 + return false; 409 409 410 410 if (IS_ENABLED(CONFIG_TIME_NS) && 411 411 vc->clock_mode == VDSO_CLOCKMODE_TIMENS) ··· 427 427 */ 428 428 ns = LOW_RES_NSEC; 429 429 } else { 430 - return -1; 430 + return false; 431 431 } 432 432 433 433 if (likely(res)) { 434 434 res->tv_sec = 0; 435 435 res->tv_nsec = ns; 436 436 } 437 - return 0; 437 + return true; 438 438 } 439 439 440 440 static __maybe_unused 441 441 int __cvdso_clock_getres_data(const struct vdso_time_data *vd, clockid_t clock, 442 442 struct __kernel_timespec *res) 443 443 { 444 - int ret = __cvdso_clock_getres_common(vd, clock, res); 444 + bool ok; 445 445 446 - if (unlikely(ret)) 446 + ok = __cvdso_clock_getres_common(vd, clock, res); 447 + 448 + if (unlikely(!ok)) 447 449 return clock_getres_fallback(clock, res); 448 450 return 0; 449 451 } ··· 462 460 struct old_timespec32 *res) 463 461 { 464 462 struct __kernel_timespec ts; 465 - int ret; 463 + bool ok; 466 464 467 - ret = __cvdso_clock_getres_common(vd, clock, &ts); 465 + ok = __cvdso_clock_getres_common(vd, clock, &ts); 468 466 469 - if (unlikely(ret)) 467 + if (unlikely(!ok)) 470 468 return clock_getres32_fallback(clock, res); 471 469 472 470 if (likely(res)) { 473 471 res->tv_sec = ts.tv_sec; 474 472 res->tv_nsec = ts.tv_nsec; 475 473 } 476 - return ret; 474 + return 0; 477 475 } 478 476 479 477 static __maybe_unused int