From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=52944 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Olzuj-0006dR-L9 for qemu-devel@nongnu.org; Thu, 19 Aug 2010 03:51:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Olzui-00007A-FC for qemu-devel@nongnu.org; Thu, 19 Aug 2010 03:51:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51803) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Olzui-00006s-8w for qemu-devel@nongnu.org; Thu, 19 Aug 2010 03:51:52 -0400 Message-ID: <4C6CE292.7090404@redhat.com> Date: Thu, 19 Aug 2010 09:51:46 +0200 From: Paolo Bonzini MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules References: <4C6A43B5.40809@redhat.com> <4C6AD744.1070009@twiddle.net> <4C6B9B44.7020803@redhat.com> <4C6BB642.4000205@redhat.com> <4C6BE6E1.9010108@redhat.com> <4C6C1072.1000200@redhat.com> In-Reply-To: <4C6C1072.1000200@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Kevin Wolf , Blue Swirl , qemu-devel@nongnu.org, Jes Sorensen 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