bug-standards
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnu.org #1509466] overflow in coding standard example (32 bit time_t)


From: Therese Godefroy via RT
Subject: [gnu.org #1509466] overflow in coding standard example (32 bit time_t)
Date: Sun, 29 Mar 2020 11:10:14 -0400

Hello GNU Standards maintainers,

I think this ticket is for you.

Best,
Thérèse

Le Dim 29 Mar 2020 09:34:16, address@hidden a écrit :
> https://www.gnu.org/prep/standards/html_node/Formatting.html#Formatting
> 
> In the "before and after" parentheses formatting examples near the end
> of this section:
> 
> v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
>     + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
> 
> The tv_sec * 1000 multiplication for milliseconds overflows
> on a platform where tv_sec is a 32 bit time_t.
> 
> One possible fix is to cast one of the operands to the same 64 bit
> type as the result v:
> (uint64_t)rup->ru_utime.tv_sec * 1000 ...
> 
> [A similar bug fix for a nanosecond calculation was accepted this
> month in the embedded linux library ell. Unfortunately some of us are
> still supporting platforms with 32 bit time_t Y2038 issues.]
> 
> [Apologies if this is not the best most direct way to report this
> documentation defect.]







reply via email to

[Prev in Thread] Current Thread [Next in Thread]