qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH 3/3] net.h: Add description fields for qdev


From: Markus Armbruster
Subject: Re: [Qemu-devel] [RFC PATCH 3/3] net.h: Add description fields for qdev properites
Date: Fri, 28 May 2010 15:45:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Amit Shah <address@hidden> writes:

> On (Fri) May 28 2010 [14:50:46], Markus Armbruster wrote:
>> Amit Shah <address@hidden> writes:
>> 
>> > Signed-off-by: Amit Shah <address@hidden>
>> > ---
>> >  net.h |   13 ++++++++++---
>> >  1 files changed, 10 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/net.h b/net.h
>> > index 0e9cc5d..8ad439a 100644
>> > --- a/net.h
>> > +++ b/net.h
>> > @@ -20,10 +20,17 @@ typedef struct NICConf {
>> >      VLANClientState *peer;
>> >  } NICConf;
>> >  
>> > +#define PROP_NET_MACADDR_DESC                   \
>> > +    "The MAC address for the NIC"
>> > +#define PROP_NET_VLAN_DESC                      \
>> > +    "The VLAN to associate the NIC with"
>> > +#define PROP_NET_NETDEV_DESC                    \
>> > +    "The peer net device to associate with this virtual NIC"
>> > +
>> >  #define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
>> > -    DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr, ""),            \
>> > -    DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan, ""),               \
>> > -    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer, "")
>> > +    DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr, 
>> > PROP_NET_MACADDR_DESC),\
>> > +    DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan, PROP_NET_VLAN_DESC), 
>> >     \
>> > +    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer, PROP_NET_NETDEV_DESC)
>> >  
>> >  /* VLANs support */
>> 
>> Why the macros?
>
> Just seems cleaner; big strings can become an eyesore in such places.
> What do you think?

I'd say the macros are a worse eyesore :)

Compare:

#define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
    DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr, PROP_NET_MACADDR_DESC),\
    DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan, PROP_NET_VLAN_DESC),     \
    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer, PROP_NET_NETDEV_DESC)

#define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
    DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr,                 \
        "The MAC address for the NIC"),                                 \
    DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan,                    \
        "The VLAN to associate the NIC with"),                          \
    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer,                    \
        "The peer net device to associate with this virtual NIC")

This way, the description string does double-duty as documentation of
the property definition.



reply via email to

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