Re: [PATCH 05/12] getpwent_r.3: Cast 'uid_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/getpwent_r.3 | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/man3/getpwent_r.3 b/man3/getpwent_r.3
> index b6c1c281f..ef4c01c21 100644
> --- a/man3/getpwent_r.3
> +++ b/man3/getpwent_r.3
> @@ -179,6 +179,7 @@ in the stream with all other threads.
>  #define _GNU_SOURCE
>  #include <pwd.h>
>  #include <stdio.h>
> +#include <stdint.h>
>  #define BUFLEN 4096
>  
>  int
> @@ -194,8 +195,8 @@ main(void)
>          i = getpwent_r(&pw, buf, sizeof(buf), &pwp);
>          if (i)
>              break;
> -        printf("%s (%d)\etHOME %s\etSHELL %s\en", pwp\->pw_name,
> -               pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell);
> +        printf("%s (%jd)\etHOME %s\etSHELL %s\en", pwp\->pw_name,
> +               (intmax_t) pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell);
>      }
>      endpwent();
>      exit(EXIT_SUCCESS);


Casting to long is the historical practice here, and should be sufficient,
don't you think? I realize there's an argument for making all of these 
system data type casts intmax_t / uintmax_t. But the counterarguments
(admittedly not compelling), are:

* Some people might still be confined to a pre C-99 world
* Churn (lots of changes)
* (long) is a sufficient cast for all of these types
  (except off_t).

Your thoughts?

Thanks,

Michael


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