Re: [PATCH (2) 11/34] timerfd_create.2: Use sizeof consistently

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

 



On 9/4/20 5:14 PM, Michael Kerrisk (man-pages) wrote:
> Hello Alex,
> 
> On 9/4/20 3:45 PM, Alejandro Colomar wrote:
>> >From d347c933a8c253028f8f76c4170b65b85ce7d605 Mon Sep 17 00:00:00 2001
>> From: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx>
>> Date: Thu, 3 Sep 2020 21:42:28 +0200
>> Subject: [PATCH 11/34] timerfd_create.2: Use sizeof consistently
>>
>> Use ``sizeof`` consistently through all the examples in the following
>> way:
>>
>> - Use the name of the variable instead of its type as argument for
>>   ``sizeof``.
>>
>> 	Rationale:
>> 	https://www.kernel.org/doc/html/v5.8/process/coding-style.html#allocating-memory
>>
>> Signed-off-by: Alejandro Colomar <colomar.6.4.3@xxxxxxxxx>
> 
> Applied. Thanks!
> 
> Michael

I've changed my mind on this one (for similar reasons to patch 03/34).
The buffer here must be an 8-byte integer; it's baked into the API,
and I think it's helpful to show the type, to emphasize this point.
I've decided not to apply this patch.

Thanks,

Michael

>> ---
>>  man2/timerfd_create.2 | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/man2/timerfd_create.2 b/man2/timerfd_create.2
>> index 67a13dba3..fd4acf3e9 100644
>> --- a/man2/timerfd_create.2
>> +++ b/man2/timerfd_create.2
>> @@ -700,8 +700,8 @@ main(int argc, char *argv[])
>>      printf("timer started\en");
>>
>>      for (tot_exp = 0; tot_exp < max_exp;) {
>> -        s = read(fd, &exp, sizeof(uint64_t));
>> -        if (s != sizeof(uint64_t))
>> +        s = read(fd, &exp, sizeof(exp));
>> +        if (s != sizeof(exp))
>>              handle_error("read");
>>
>>          tot_exp += exp;
>>
> 
> 


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