<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 30, 2022 at 12:05 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 30/08/2022 00:56, <a href="mailto:scan-admin@coverity.com" target="_blank">scan-admin@coverity.com</a> wrote:<br>
> ** CID 1512552:  High impact quality  (Y2K38_SAFETY)<br>
> /cpukit/score/src/kern_tc.c: 1804 in _Timecounter_Windup()<br>
> <br>
> <br>
> ________________________________________________________________________________________________________<br>
> *** CID 1512552:  High impact quality  (Y2K38_SAFETY)<br>
> /cpukit/score/src/kern_tc.c: 1804 in _Timecounter_Windup()<br>
> 1798          /* Go live with the new struct timehands. */<br>
> 1799     #ifdef FFCLOCK<br>
> 1800          switch (sysclock_active) {<br>
> 1801          case SYSCLOCK_FBCK:<br>
> 1802     #endif<br>
> 1803                  time_second = th->th_microtime.tv_sec;<br>
>>>>      CID 1512552:  High impact quality  (Y2K38_SAFETY)<br>
>>>>      A "time_t" value is stored in an integer with too few bits to accommodate it.  The expression "th->th_offset.sec" is cast to "int32_t".<br>
> 1804                  time_uptime = th->th_offset.sec;<br>
> 1805     #ifdef FFCLOCK<br>
> 1806                  break;<br>
> 1807          case SYSCLOCK_FFWD:<br>
> 1808                  time_second = fftimehands->tick_time_lerp.sec;<br>
> 1809                  time_uptime = fftimehands->tick_time_lerp.sec - ffclock_boottime.sec;<br>
> <br>
> ** CID 1512551:    (Y2K38_SAFETY)<br>
<br>
This seems to be a new Coverity feature. The Newlib time_t definition is:<br>
<br>
#if defined(_USE_LONG_TIME_T) || __LONG_MAX__ > 0x7fffffffL<br>
#define _TIME_T_ long<br>
#else<br>
#define _TIME_T_ __int_least64_t<br>
#endif<br>
typedef _TIME_T_        __time_t;<br>
<br>
Does Coverity use the Newlib header files? The _USE_LONG_TIME_T should <br>
be undefined for RTEMS.<br></blockquote><div><br></div><div>Yes it should. It works by doing something like this:</div><div><br></div><div>cov-build waf|make</div><div><br></div><div>And looking at the newlib headers, I agree everything looks like it should </div><div>be defined to _int_least64_t. And preprocessing a simple file that includes</div><div><sys/time.h> shows that it is typed to that.</div><div><br></div><div>But.... something else is going on. time_uptime is defined to 

_Timecounter_Time_uptime</div><div>which is an int32_t. <br><br>$ grep -r _Timecounter_Time_uptime cpukit/<br>cpukit/include/rtems/score/timecounter.h:extern volatile int32_t _Timecounter_Time_uptime;<br>cpukit/include/machine/_kernel_time.h:#define   time_uptime _Timecounter_Time_uptime<br>cpukit/include/machine/_timecounter.h:extern volatile int32_t _Timecounter_Time_uptime;<br>cpukit/rtems/src/clockgetuptimeseconds.c:  return _Timecounter_Time_uptime - 1;<br>cpukit/score/src/kern_tc.c: *  ::_Timecounter, ::_Timecounter_Time_second, and ::_Timecounter_Time_uptime<br>cpukit/score/src/kern_tc.c:#define      time_uptime _Timecounter_Time_uptime<br>cpukit/score/src/kern_ntptime.c:#define time_uptime _Timecounter_Time_uptime<br></div><div><br></div><div>The declaration in kern_tc.c doesn't align with the prototype in _timecounter.h </div><div>once the macro redefinition is taken into account.</div><div><br></div><div>I'm surprised that gcc isn't generating a warning of some type for the</div><div>mismatch.</div><div><br></div><div>--joel</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- <br>
embedded brains GmbH<br>
Herr Sebastian HUBER<br>
Dornierstr. 4<br>
82178 Puchheim<br>
Germany<br>
email: <a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a><br>
phone: +49-89-18 94 741 - 16<br>
fax:   +49-89-18 94 741 - 08<br>
<br>
Registergericht: Amtsgericht München<br>
Registernummer: HRB 157899<br>
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler<br>
Unsere Datenschutzerklärung finden Sie hier:<br>
<a href="https://embedded-brains.de/datenschutzerklaerung/" rel="noreferrer" target="_blank">https://embedded-brains.de/datenschutzerklaerung/</a><br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a></blockquote></div></div>