On 03/26/2013 02:16 PM, Jason Gunthorpe wrote:
> On Tue, Mar 26, 2013 at 09:46:28AM -0700, Roland Dreier wrote:
>>> Checkpatch recommends since some time to use sizeof(e) instead of sizeof e,
>>> isn't it ?
>>
>> I actually prefer "sizeof e" since sizeof is an operator, not a
>> function.  "sizeof(e)" looks just as silly as "return(e)" to me.
> 
> Sizeof is used as an expression, return is not.
> 
> They have different precedence rules:
>  return e + 1; // == return (e + 1)
> vs
>  sizeof e + 1;  // == sizeof(e) + 1
> 
> Or weirder:
>  return (void *)x; // OK
> vs
>  sizeof (void *)x; // <-- compile error
> 
> Coding sizeof as a function call frees the reader from having to
> check/know the obscure precedence rules for sizeof.

Personally, I couldn't care less.  But about 5 lines outside of the
context of this patch in the same function is another use of that same
expression.  The real reason I used the form I did was to match the
style of that other instance.  I prepared a separate patch to convert
both of them to the checkpatch preferred style until I saw Roland say he
didn't want it.  But what I wouldn't have done is submitted a patch that
caused a single function to have two different styles within 8 lines of
each other just because some nanny state nag script tells me too.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to