qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [for-2.12 4/7] pci: Simplify pci_bus_is_root()


From: David Gibson
Subject: Re: [Qemu-devel] [for-2.12 4/7] pci: Simplify pci_bus_is_root()
Date: Fri, 1 Dec 2017 15:25:10 +1100
User-agent: Mutt/1.9.1 (2017-09-22)

On Thu, Nov 30, 2017 at 02:23:45PM +0800, Peter Xu wrote:
> On Wed, Nov 29, 2017 at 07:46:25PM +1100, David Gibson wrote:
> 
> [...]
> 
> >  struct PCIBus {
> >      BusState qbus;
> > +    enum PCIBusFlags flags;
> >      PCIIOMMUFunc iommu_fn;
> >      void *iommu_opaque;
> >      uint8_t devfn_min;
> > @@ -440,8 +446,12 @@ struct PCIBus {
> >      Notifier machine_done;
> >  };
> 
> I would prefer directly defining flags as uint64_t then it's more
> clear that it's a bitmask (enum let me think of only one flag will be
> set, but I may be wrong), but it's fine too to me.

In most languages an enum would only allow one value to be set, but C
enums are weird - they're basically just a funny way of defining
integer constants.

I'm not particularly bothered either way: using the enum type makes it
clear the right set of constants to use with this field, using an int
makes it clearer that bit flags can be set.  So both options are
slightly misleading in different ways.

If there's another vote for uint64_t over using the enum, I'll change
it.

> Reviewed-by: Peter Xu <address@hidden>
> 

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]