Re: [PATCH 03/12] pthread_getcpuclockid.3: Cast 'time_t' to 'intmax_t' for printf()

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

 



Hi Jakub,

On Mon, 14 Sep 2020 at 10:58, Jakub Wilk <jwilk@xxxxxxxxx> wrote:
>
> * Michael Kerrisk <mtk.manpages@xxxxxxxxx>, 2020-09-13, 07:58:
> >Casting to long is the historical practive here, and should be
> >sufficient, don't you think?
>
> It general, the practice of casting time_t to long is wrong. There are
> existing systems that have 64-bit time_t but 32-bit long.
>
> In this particular case, we're measuring CPU time, so there's
> practically no danger of overflow.

Yes, what you say makes sense.

> I'd either cast it to int (to make the code shortest and simplest) or to
> intmax_t (to be pedantically correct).

As per the patch from Alex, we'll universally move to intmax_t/uintmax_t casts.

Thanks,

Michael
-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux