[libvirt] [PATCH] libvirt-domain.h: changing some unsigned int parameters to the respective enum type.

Recently, some code were cleaned ups. Now, some parameters are being converted to its respective enum type. For example, there are many functions that are using int or unsigned int types instead enum types. So, this kind of cleaning up can be necessary. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> --- include/libvirt/libvirt-domain.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 9487b80..8016e2a 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -854,7 +854,7 @@ typedef enum { int virDomainShutdown (virDomainPtr domain); int virDomainShutdownFlags (virDomainPtr domain, - unsigned int flags); + virDomainShutdownFlagValues flags); typedef enum { VIR_DOMAIN_REBOOT_DEFAULT = 0, /* hypervisor choice */ @@ -866,7 +866,7 @@ typedef enum { } virDomainRebootFlagValues; int virDomainReboot (virDomainPtr domain, - unsigned int flags); + virDomainRebootFlagValues flags); int virDomainReset (virDomainPtr domain, unsigned int flags); @@ -884,7 +884,7 @@ typedef enum { } virDomainDestroyFlagsValues; int virDomainDestroyFlags (virDomainPtr domain, - unsigned int flags); + virDomainDestroyFlagsValues flags); int virDomainRef (virDomainPtr domain); int virDomainFree (virDomainPtr domain); -- 1.9.1

Hi guys! I'm really don't know the reason of keeping 'unsigned int' instead 'enum' types. I asked it at IRC, but no response. =( Is it need a clean up or it is designed this way? Thanks! -- *Julio Cesar Faracco*

On Sun, Mar 08, 2015 at 11:47:11PM -0300, Julio Faracco wrote:
Recently, some code were cleaned ups. Now, some parameters are being converted to its respective enum type. For example, there are many functions that are using int or unsigned int types instead enum types. So, this kind of cleaning up can be necessary.
The size of the enum type is not fixed in the C standard - compilers are free to use any sized integer to represent it. As such as have a policy of never using enum types in function parameters, always unsigned ints. In addition the 'flags' parameters are not taking individual enum values, they are taking a bitwise OR of values, so declaring them with the enum type is simply wrong. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Thanks Daniel to explain the reason of using unsigned int instead the enum type. Specially, because it is a policy of the project. I should send the question instead the a PATCH. Sorry about that. And thanks again. =) -- *Julio Cesar Faracco*
participants (2)
-
Daniel P. Berrange
-
Julio Faracco