From 3af2dc7802164d6c22dbef1f144c9bd945a35c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20K=C3=BChndel?= Date: Tue, 11 May 2021 16:26:55 +0200 Subject: _TOD_Validate(): Fix incorrect return code This patch fixes bug #4403. Directives * rtems_timer_fire_when() * rtems_timer_server_fire_when() * rtems_task_wake_when() are documented to return RTEMS_INVALID_ADDRESS when their time-of-day argument is NULL. But actually they return RTEMS_INVALID_CLOCK. To fix the issue this patch changes _TOD_Validate() to return a status code instead of just true/false. Close #4403 --- bsps/arm/altera-cyclone-v/rtc/rtc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'bsps/arm') diff --git a/bsps/arm/altera-cyclone-v/rtc/rtc.c b/bsps/arm/altera-cyclone-v/rtc/rtc.c index 3e8c68e789..fb30da8d66 100644 --- a/bsps/arm/altera-cyclone-v/rtc/rtc.c +++ b/bsps/arm/altera-cyclone-v/rtc/rtc.c @@ -353,10 +353,9 @@ static int altera_cyclone_v_ds1339_get_time(int minor, rtems_time_of_day* tod) temp_tod.month = ds1339_get_month(&time); temp_tod.year = ds1339_get_year(&time); - if (_TOD_Validate(&temp_tod)) + sc = _TOD_Validate(&temp_tod) + if (sc == RTEMS_SUCCESSFUL) memcpy(tod, &temp_tod, sizeof(temp_tod)); - else - sc = RTEMS_INVALID_CLOCK; } return -sc; @@ -737,10 +736,9 @@ static int altera_cyclone_v_m41st87_get_time(int minor, rtems_time_of_day* tod) temp_tod.month = m41st87_get_month(&time); temp_tod.year = m41st87_get_year(&time); - if (_TOD_Validate(&temp_tod)) + sc = _TOD_Validate(&temp_tod); + if (sc == RTEMS_SUCCESSFUL) memcpy(tod, &temp_tod, sizeof(temp_tod)); - else - sc = RTEMS_INVALID_CLOCK; return -sc; } -- cgit v1.2.3