Re: [libvirt] Re: [PATCH] also allow use of XZ for Qemu image compression

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

 



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.
> For now, here's the added comment and enum initializers.

ACK, this looks good, and your above cleanups also sound like they are good ideas.

-- 
Chris Lalancette

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]