From: "Jan Beulich" Subject: Re: [PATCH v2] x86: reduce redundancy in tsc_[gs]et_info() Date: Tue, 06 May 2014 14:56:21 +0100 Message-ID: <53690625020000780000F719@mail.emea.novell.com> References: <5368FFD0020000780000F64D@mail.emea.novell.com> <5368E854.2050303@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Whfr7-0004rn-V4 for xen-devel@lists.xenproject.org; Tue, 06 May 2014 13:56:26 +0000 In-Reply-To: <5368E854.2050303@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: xen-devel , Boris Ostrovsky , Keir Fraser List-Id: xen-devel@lists.xenproject.org >>> On 06.05.14 at 15:49, wrote: > On 06/05/14 14:29, Jan Beulich wrote: >> case TSC_MODE_PVRDTSCP: >> - d->arch.vtsc = boot_cpu_has(X86_FEATURE_RDTSCP) && >> - host_tsc_is_safe() ? 0 : 1; >> + d->arch.vtsc = boot_cpu_has(X86_FEATURE_RDTSCP) && >> + host_tsc_is_safe() ? 0 : 1; > > Can this be reduced to boot_cpu_has(X86_FEATURE_RDTSCP) && > !host_tsc_is_safe() ? > > I believe this is the correct way around with the precedence between && > and ?!, but it is far from clear. Alternatively, could some brackets be > introduced for clarity? No, ?: has lower precedence than all binary operators other than assignment ones and comma. But yes, this is ugly - I'll change it to d->arch.vtsc = !(boot_cpu_has(X86_FEATURE_RDTSCP) && host_tsc_is_safe()); or, one character shorter, d->arch.vtsc = !boot_cpu_has(X86_FEATURE_RDTSCP) || !host_tsc_is_safe(); (somehow I also managed to overlook the other double space in there). Jan