Thread (8 messages) flat view 8 messages, 8 authors, 2012-02-13

Re: [PATCH net-next] drivers/net: Remove boolean comparisons to true/false

From: Arend van Spriel <hidden>
Date: 2012-02-10 09:53:25
Also in: linux-wireless

Possibly related (same subject, not in this thread)

On 02/10/2012 10:32 AM, David Laight wrote:
 
quoted
-	u32 func_encode = func |
-			((is_Pf == true ? 1 : 0) <<
IGU_FID_ENCODE_IS_PF_SHIFT);
quoted
+	u32 func_encode = func | (is_Pf ? 1 : 0) <<
IGU_FID_ENCODE_IS_PF_SHIFT;

This sort of thing is why I personally don't like 'bool' at all.
If 'is_Pf' were an integer type that is known to only contain 0 or 1
then the code can just be:
Properly chosing the bool type is not what is being handled by the
patch. Easiest way to convert would be using double inversion:

u32 func_encode = func | (!!is_Pf << IGU_FID_ENCODE_IS_PF_SHIFT);

The parenthesis are not needed due to operator precedence, but is more
clear this way (to me at least).

Gr. AvS
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help