<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 8:44 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 15:40, Joel Sherrill wrote:<br>
> <br>
> <br>
> On Tue, Aug 30, 2022 at 12:05 AM Sebastian Huber <br>
> <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a> <br>
> <mailto:<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>>> wrote:<br>
> <br>
> On 30/08/2022 00:56, <a href="mailto:scan-admin@coverity.com" target="_blank">scan-admin@coverity.com</a><br>
> <mailto:<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>
> ________________________________________________________________________________________________________<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<br>
> bits to accommodate it. The expression "th->th_offset.sec" is cast<br>
> 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 =<br>
> 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<br>
> 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>
> <br>
> <br>
> Yes it should. It works by doing something like this:<br>
> <br>
> cov-build waf|make<br>
> <br>
> And looking at the newlib headers, I agree everything looks like it should<br>
> be defined to _int_least64_t. And preprocessing a simple file that includes<br>
> <sys/time.h> shows that it is typed to that.<br>
> <br>
> But.... something else is going on. time_uptime is defined to <br>
> _Timecounter_Time_uptime<br>
> which is an int32_t.<br>
<br>
Oh, sorry, I didn't notice this. Then this is a false positive. Using an <br>
int32_t for uptime seconds is enough.<br></blockquote><div><br></div><div>The variable time_uptime is still defined as two separate types. The </div><div>prototype and the declaration do not match. </div><div><br></div><div>Even if int32_t is wide enough for seconds of uptime, it is an assignment</div><div>that narrows types. Casting to make this narrowing intentional would at</div><div>least hint this was intentional. </div><div><br></div><div>But better would be to use the proper type and just make it time_t like</div><div>FreeBSD.</div><div><br></div><div>--joel </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>
</blockquote></div></div>