From: Gianni Tedesco Subject: Re: Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug Date: Thu, 19 Aug 2010 17:34:19 +0100 Message-ID: <1282235659.3731.37.camel@qabil.uk.xensource.com> References: <1282211932.3170.2341.camel@zakaz.uk.xensource.com> <1282211946-8629-1-git-send-email-ian.campbell@citrix.com> <1282215007.3170.2449.camel@zakaz.uk.xensource.com> <1282215140.3170.2454.camel@zakaz.uk.xensource.com> <4C6D577F.6020607@goop.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4C6D577F.6020607@goop.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jeremy Fitzhardinge Cc: Ian Campbell , "xen-devel@lists.xensource.com" , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Thu, 2010-08-19 at 17:10 +0100, Jeremy Fitzhardinge wrote: > On 08/19/2010 03:54 AM, Stefano Stabellini wrote: > > On Thu, 19 Aug 2010, Ian Campbell wrote: > >> On Thu, 2010-08-19 at 11:50 +0100, Ian Campbell wrote: > >>> On Thu, 2010-08-19 at 11:37 +0100, Stefano Stabellini wrote: > >>>> On Thu, 19 Aug 2010, Ian Campbell wrote: > >>>>> if (r && !(r == XEN_PLATFORM_ERR_MAGIC && > >>>>> + (xen_emul_unplug != -1) && > >>>>> (xen_emul_unplug & XEN_UNPLUG_IGNORE))) > >>>> I wouldn't add xen_emul_unplug != -1 because it should be clear that > >>>> xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1. > >>> That's not correct since -1 is all 1s. So you can get a false positive > >>> for "xen_emul_unplug & XEN_UNPLUG_IGNORE" if xen_emul_unplug == -1. > >> IOW if we were to rewrite the test to use less boolean logic the patch > >> might look like: > >> > >> if (r) { > >> if (r != XEN_PLATFORM_ERR_MAGIC) > >> return; > >> + if (xen_emul_unplug == -1) > >> + return; > >> if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE)) > >> return; > >> } > >> > >> Perhaps this refactoring is worthwhile in any case? It certainly makes > >> my head hurt less ;-) > >> > > > > Yeah, it is probably worth it anyway :) > > Treating a variable as an integer and a bitfield seems like a bad idea. Should be fine? I'd just #define XEN_UNPLUG_ALL_THE_BITS ~0U for the sake of cosmetics...