[PATCH 1/3] _TOD_Validate(): Fix incorrect return code

Sebastian Huber sebastian.huber at embedded-brains.de
Wed May 12 04:40:36 UTC 2021


On 11/05/2021 22:00, Gedare Bloom wrote:
>> 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;
>>   }
>> diff --git a/bsps/shared/dev/rtc/rtc-support.c b/bsps/shared/dev/rtc/rtc-support.c
>> index 765bfe1d6b..04b8f0c847 100644
>> --- a/bsps/shared/dev/rtc/rtc-support.c
>> +++ b/bsps/shared/dev/rtc/rtc-support.c
>> @@ -255,7 +255,7 @@ int setRealTime(
>>     if (!RTC_Is_present())
>>       return -1;
>>
>> -  if ( !_TOD_Validate(tod) )
>> +  if (_TOD_Validate(tod) != RTEMS_SUCCESSFUL)
> These three files in bsps/ should not be calling score functions
> directly, unless they implement part of the score CPU port. These
> don't seem to be doing that. This issue exists before this patch, but
> a ticket should be opened to fix this. A new API should be added for
> application/BSP layers to validate an rtems_time_of_day value.

I added a ticket:

https://devel.rtems.org/ticket/4407

For me it has a very low priority.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


More information about the devel mailing list