Skip to content

Commit 5d05c4b

Browse files
finkephSICKAGjhedberg
authored andcommitted
sys: timeutil: Replaced pointer to rvalues
Replaced all pointer to rvalues used for the second parameter in calls of timespec_compare() within function timespec_to_timeout(). This might be legal syntax in C, but leads to compile errors when timeutil.h is included and compiled in a C++ compilation unit. Signed-off-by: Philipp Finke <[email protected]>
1 parent 05b77ec commit 5d05c4b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

include/zephyr/sys/timeutil.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,11 @@ static inline void timespec_from_timeout(k_timeout_t timeout, struct timespec *t
641641
static inline k_timeout_t timespec_to_timeout(const struct timespec *req, struct timespec *rem)
642642
{
643643
k_timeout_t timeout;
644+
struct timespec temp = SYS_TIMESPEC_NO_WAIT;
644645

645646
__ASSERT_NO_MSG((req != NULL) && timespec_is_valid(req));
646647

647-
if (timespec_compare(req, &SYS_TIMESPEC_NO_WAIT) <= 0) {
648+
if (timespec_compare(req, &temp) <= 0) {
648649
if (rem != NULL) {
649650
*rem = *req;
650651
}
@@ -653,7 +654,9 @@ static inline k_timeout_t timespec_to_timeout(const struct timespec *req, struct
653654
return timeout;
654655
}
655656

656-
if (timespec_compare(req, &SYS_TIMESPEC_FOREVER) == 0) {
657+
temp = SYS_TIMESPEC_FOREVER;
658+
659+
if (timespec_compare(req, &temp) == 0) {
657660
if (rem != NULL) {
658661
*rem = SYS_TIMESPEC_NO_WAIT;
659662
}
@@ -662,7 +665,9 @@ static inline k_timeout_t timespec_to_timeout(const struct timespec *req, struct
662665
return timeout;
663666
}
664667

665-
if (timespec_compare(req, &SYS_TIMESPEC_MAX) >= 0) {
668+
temp = SYS_TIMESPEC_MAX;
669+
670+
if (timespec_compare(req, &temp) >= 0) {
666671
/* round down to align to max ticks */
667672
timeout.ticks = K_TICK_MAX;
668673
} else {

0 commit comments

Comments
 (0)