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 Alex,

On 9/12/20 1:14 AM, Alejandro Colomar wrote:
> Signed-off-by: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx>
> ---
>  man3/pthread_getcpuclockid.3 | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Casting to long is the historical practive here, and should be sufficient,
don't you think?

Thanks,

Michael


> diff --git a/man3/pthread_getcpuclockid.3 b/man3/pthread_getcpuclockid.3
> index 703735b91..a457a4cee 100644
> --- a/man3/pthread_getcpuclockid.3
> +++ b/man3/pthread_getcpuclockid.3
> @@ -115,6 +115,7 @@ Subthread CPU time:        0.992
>  
>  #include <time.h>
>  #include <stdio.h>
> +#include <stdint.h>
>  #include <stdlib.h>
>  #include <unistd.h>
>  #include <pthread.h>
> @@ -143,7 +144,7 @@ pclock(char *msg, clockid_t cid)
>      printf("%s", msg);
>      if (clock_gettime(cid, &ts) == \-1)
>          handle_error("clock_gettime");
> -    printf("%4ld.%03ld\en", ts.tv_sec, ts.tv_nsec / 1000000);
> +    printf("%4jd.%03ld\en", (intmax_t) ts.tv_sec, ts.tv_nsec / 1000000);
>  }
>  
>  int
> 


-- 
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