From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLliM-0000Yd-MP for qemu-devel@nongnu.org; Wed, 20 Jan 2016 00:54:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLlhy-0008AG-Va for qemu-devel@nongnu.org; Wed, 20 Jan 2016 00:53:54 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:34939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLlhy-00088Y-H5 for qemu-devel@nongnu.org; Wed, 20 Jan 2016 00:53:30 -0500 Received: by mail-pf0-x241.google.com with SMTP id 65so14176369pff.2 for ; Tue, 19 Jan 2016 21:53:28 -0800 (PST) References: <1452859244-9500-1-git-send-email-david@gibson.dropbear.id.au> <1452859244-9500-8-git-send-email-david@gibson.dropbear.id.au> <569EBFA6.6090709@redhat.com> <569ED31D.1020307@ozlabs.ru> <569F12D2.60307@redhat.com> From: Alexey Kardashevskiy Message-ID: <569F20D2.3020508@ozlabs.ru> Date: Wed, 20 Jan 2016 16:53:22 +1100 MIME-Version: 1.0 In-Reply-To: <569F12D2.60307@redhat.com> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/10] pseries: Clean up error handling in spapr_rtas_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , David Gibson , armbru@redhat.com Cc: qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org On 01/20/2016 03:53 PM, Eric Blake wrote: > On 01/19/2016 05:21 PM, Alexey Kardashevskiy wrote: > >>> You could drop the redundant () while touching this, as in: >> >> >> Seriously? Why? I personally find it really annoying (but I stay silent) >> when people omit braces in cases like this. >> >> >>> assert(token >= RTAS_TOKEN_BASE && token < RTAS_TOKEN_MAX); > > Because it's the prevailing style. I estimate that less than 10% of qemu > over-parenthesizes, mostly because && and || are well-known C operator > precedence: > > $ git grep ' && ' | wc > 6462 57034 482477 > $ git grep ') && (' | wc > 578 6151 48655 > > Of course, that's a rough estimate, as it has false positives on 'if > (foo() && (b || c))', and false negatives on conditionals where there is > a unary rather than binary operator on either side of &&; but I'm sure > you could write a Coccinelle script if you wanted more accurate counting. > > But you are equally right that as long as HACKING doesn't document it, > and checkpatch.pl doesn't flag it, then you can over-parenthesize binary > arguments to the short-circuiting operators to your aesthetic tastes. C Operator Precedence is well-known and still confusing, I cannot get used to the fact that /==/etc have higher priority than &/&&/etc so not seeing braces in the cases like above makes me nervous. Yes, I am sort of retarded :( So, we can keep doing this over-parenthesizing, good, thanks :) > And for other operators, like '&' and '|', I definitely recommend the > parenthesis, particularly if you manage to trigger a gcc or clang > warning (in spite of the precedence being unambiguous) if you omit the > parenthesis. Goood. -- Alexey