On Wed, Sep 09, 2009 at 10:17:48AM +0200, Jim Meyering wrote:
Jim Meyering wrote:
...
> At Chris' suggestion, I've added a comment warning not to do what I did ;-)
>
> To make it even more obvious that these numbers matter,
> I've assigned explicit constants in the enum:
>
> + QEMUD_SAVE_FORMAT_RAW = 0,
> + QEMUD_SAVE_FORMAT_GZIP = 1,
> + QEMUD_SAVE_FORMAT_BZIP2 = 2,
>
> Currently, if someone accidentally adds this (mistakenly reused number):
>
> + QEMUD_SAVE_FORMAT_OOPS = 2,
>
> the compiler won't catch it.
> However, with a small additional change to use VIR_ENUM_DECL
> and VIR_ENUM_IMPL, thus replacing the if/elsif/ chains,
> and the compiler *would* detect that mistake.
> It'd also help to factor out the QEMUD_SAVE_FORMAT_<> to
"<>"
> association, rather than having literals like "gzip" and
"bzip2"
> in two places.
>
> Now that I've described that, I'll prepare a separate patch.
This depends on the preceding patch.
yup using VIR_ENUM_IMPL, and VIR_ENUM_DECL is a good cleanup,
could you apply this to the current git, we will then reduce options
later,
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/