lkml.org 
[lkml]   [2020]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 01/24] inet_net_pton.3: Use 'PRIx32' rather than "%x" when printing 'uint32_t' values
From
Date
Hi Michael,

On 2020-09-11 11:31, Michael Kerrisk (man-pages) wrote:
> Hi Alex,
>
> On 9/10/20 11:13 PM, Alejandro Colomar wrote:
>> Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
>> ---
>> man3/inet_net_pton.3 | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/man3/inet_net_pton.3 b/man3/inet_net_pton.3
>> index 00f94b9d4..d74a33d74 100644
>> --- a/man3/inet_net_pton.3
>> +++ b/man3/inet_net_pton.3
>> @@ -332,6 +332,7 @@ Raw address: c1a80180
>> /* Link with "\-lresolv" */
>>
>> #include <arpa/inet.h>
>> +#include <inttypes.h>
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> @@ -381,7 +382,7 @@ main(int argc, char *argv[])
>> may not have been touched by inet_net_ntop(), and so will still
>> have any initial value that was specified in argv[2]. */
>>
>> - printf("Raw address: %x\en", htonl(addr.s_addr));
>> + printf("Raw address: %"PRIx32"\en", htonl(addr.s_addr));
>>
>> exit(EXIT_SUCCESS);
>> }
>
> So, I'm in a little bit of doubt about patches 01 and 02. Does
> this really win us anything? On the one hand, %"PRIx32" is more
> difficult to read than %x. On the other, does it win us anything
> in terms of portability? At first glance, the answers seems to me
> to be "no". Your thoughts?
>
> Thanks,
>
> Michael

On 16-bit systems 'unsigned int' might be shorter than 'uint32_t'.
There it would make a difference, I guess.


Thanks,

Alex

\
 
 \ /
  Last update: 2020-09-11 11:40    [W:0.126 / U:1.932 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site