]> xenbits.xensource.com Git - libvirt.git/commit
maint: prefer enum over int for virstoragefile structs
authorEric Blake <eblake@redhat.com>
Wed, 14 May 2014 22:40:33 +0000 (16:40 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 16 May 2014 06:22:18 +0000 (00:22 -0600)
commitb279e52f7bd07dfe6e7f5ef0b34f2b424c50eee2
tree9602d8283df16fbe306744bb9b53dd195c7bcbe6
parentab5178188f250385132338e004d5c1f160fc5f34
maint: prefer enum over int for virstoragefile structs

For internal structs, we might as well be type-safe and let the
compiler help us with less typing required on our part (getting
rid of casts is always nice).  In trying to use enums directly,
I noticed two problems in virstoragefile.h that can't be fixed
without more invasive refactoring: virStorageSource.format is
used as more of a union of multiple enums in storage volume
code (so it has to remain an int), and virStorageSourcePoolDef
refers to pooltype whose enum is declared in src/conf, but where
src/util can't pull in headers from src/conf.

* src/util/virstoragefile.h (virStorageNetHostDef)
(virStorageSourcePoolDef, virStorageSource): Use enums instead of
int for fields of internal types.
* src/qemu/qemu_command.c (qemuParseCommandLine): Cover all values.
* src/conf/domain_conf.c (virDomainDiskSourceParse)
(virDomainDiskSourceFormat): Simplify clients.
* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskInternal): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/conf/domain_conf.c
src/qemu/qemu_command.c
src/qemu/qemu_driver.c
src/util/virstoragefile.h