summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-09-03 10:01:04 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-09-06 12:22:44 +0200
commitff3df9f32f4652cd250c74bc5b872b0e6704b791 (patch)
tree8655fa038f9d10b9d11ac2da704594f637f9a308 /cpukit/rtems/src
parentscore: Limit the CLOCK_REALTIME setting (diff)
downloadrtems-ff3df9f32f4652cd250c74bc5b872b0e6704b791.tar.bz2
score: Simplify _TOD_Validate()
Split up the multi line if statement into smaller parts.
Diffstat (limited to 'cpukit/rtems/src')
-rw-r--r--cpukit/rtems/src/clocktodvalidate.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/cpukit/rtems/src/clocktodvalidate.c b/cpukit/rtems/src/clocktodvalidate.c
index 14b3f79d8e..0e3b5772b5 100644
--- a/cpukit/rtems/src/clocktodvalidate.c
+++ b/cpukit/rtems/src/clocktodvalidate.c
@@ -51,15 +51,31 @@ rtems_status_code _TOD_Validate(
ticks_per_second = rtems_clock_get_ticks_per_second();
ticks_mask = (uint32_t) ticks_validation;
- if ( ( ( the_tod->ticks & ticks_mask ) >= ticks_per_second ) ||
- (the_tod->second >= TOD_SECONDS_PER_MINUTE) ||
- (the_tod->minute >= TOD_MINUTES_PER_HOUR) ||
- (the_tod->hour >= TOD_HOURS_PER_DAY) ||
- (the_tod->month == 0) ||
- (the_tod->month > TOD_MONTHS_PER_YEAR) ||
- (the_tod->year < TOD_BASE_YEAR) ||
- (the_tod->year > TOD_LATEST_YEAR) ||
- (the_tod->day == 0) ) {
+ if ( ( the_tod->ticks & ticks_mask ) >= ticks_per_second ) {
+ return RTEMS_INVALID_CLOCK;
+ }
+
+ if ( the_tod->second >= TOD_SECONDS_PER_MINUTE ) {
+ return RTEMS_INVALID_CLOCK;
+ }
+
+ if ( the_tod->minute >= TOD_MINUTES_PER_HOUR ) {
+ return RTEMS_INVALID_CLOCK;
+ }
+
+ if ( the_tod->hour >= TOD_HOURS_PER_DAY ) {
+ return RTEMS_INVALID_CLOCK;
+ }
+
+ if ( the_tod->month == 0 || the_tod->month > TOD_MONTHS_PER_YEAR ) {
+ return RTEMS_INVALID_CLOCK;
+ }
+
+ if ( the_tod->year < TOD_BASE_YEAR || the_tod->year > TOD_LATEST_YEAR ) {
+ return RTEMS_INVALID_CLOCK;
+ }
+
+ if ( the_tod->day == 0 ) {
return RTEMS_INVALID_CLOCK;
}