|
From: | Paolo Bonzini |
Subject: | Re: [Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules |
Date: | Thu, 19 Aug 2010 09:51:46 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.0.5 |
On 08/18/2010 06:55 PM, Avi Kivity wrote:
- Do not rely on the fact that bool normalizes logical non-false values to 1. So, write "x = true" instead of "x++" and "x = !x" instead of "x--". - Similarly, when x is a bool, it may be clearer to avoid "x |= y". Instead, use either "x = x || y" (if short circuiting is acceptable or even desirable) or "x |= (y != 0)". Probably a bit too verbose, but you get the idea._Bool can have values of 0 or 1, so all of the above should actually work.
Yes, I'd like to rule those out even though they work, because I find them confusing. The compiler is smart enough to generate the same code in both cases.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |