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.

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

Reply via email to