summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-09-29 15:23:24 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-09-30 07:29:57 +0200
commitabda5595f89e3a02d5c99ca5c44b170f1c49d1e5 (patch)
treed0a2709f3795e09d49b55b9ce112e4b18978a599 /cpukit/rtems
parentscore: Improve variable names in thread init (diff)
downloadrtems-abda5595f89e3a02d5c99ca5c44b170f1c49d1e5.tar.bz2
rtems: Justify integer conversions
Close #2548.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/src/clockgettod.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/cpukit/rtems/src/clockgettod.c b/cpukit/rtems/src/clockgettod.c
index 5058b42375..01daa3dc15 100644
--- a/cpukit/rtems/src/clockgettod.c
+++ b/cpukit/rtems/src/clockgettod.c
@@ -100,9 +100,14 @@ rtems_status_code rtems_clock_get_tod(
/* Obtain the current time */
_TOD_Get_timeval( &now );
- /* How many days and how many seconds in the day ? */
- days = now.tv_sec / RTEMS_SECS_PER_DAY;
- day_secs = now.tv_sec % RTEMS_SECS_PER_DAY;
+ /*
+ * How many days and how many seconds in the day?
+ *
+ * A 32-bit integer can represent enough days for several 1000 years. When
+ * the current time is valid, the integer conversions below are well defined.
+ */
+ days = (uint32_t) ( now.tv_sec / RTEMS_SECS_PER_DAY );
+ day_secs = (uint32_t) ( now.tv_sec % RTEMS_SECS_PER_DAY );
/* How many non-leap year years ? */
year = ( days / RTEMS_DAYS_PER_YEAR ) + RTEMS_YEAR_BASE;