Re: [PATCH] util: changing all the "enum" structures into typedef's in "src/util/" directory.

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

 



On 04/26/2014 06:15 PM, Julio Faracco wrote:
> In "src/util/" there are many enumeration (enum) structures. Sometimes, it's better using a typedef for variable types, function types and other usages. Other enumeration will be changed to typedef's in the future.

I line wrapped this and fixed a merge conflict in qemu_domain.c that got
introduced in the meantime.  Also, I shortened the subject line to fit
in 60 columns (for that matter, 'enum structure' doesn't make sense;
'enum type' or 'enum declaration' is closer to the C standard naming).

util: use typedefs for enums in "src/util/" directory

> 
> Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx>
> ---

>  24 files changed, 86 insertions(+), 87 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index c655bcf..402c234 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -4972,7 +4972,7 @@ virDomainDiskSourceParse(xmlNodePtr node,
>  
>      memset(&host, 0, sizeof(host));
>  
> -    switch ((enum virStorageType)src->type) {
> +    switch ((virStorageType)src->type) {

Most of your patch is mechanical changes of types that are now typedef'd...


> +++ b/src/util/viraudit.h
> @@ -26,11 +26,11 @@
>  # include "internal.h"
>  # include "virlog.h"
>  
> -enum virAuditRecordType {
> +typedef enum {
>      VIR_AUDIT_RECORD_MACHINE_CONTROL,
>      VIR_AUDIT_RECORD_MACHINE_ID,
>      VIR_AUDIT_RECORD_RESOURCE,
> -};
> +} virAuditRecordType;

...the remainder is the change to use typedefs.

It may have been cleaner to do one type per header file converted, but
the overall diffstat was still manageable for the types you converted.

> +++ b/src/util/virfile.h
> @@ -31,7 +31,7 @@
>  # include "internal.h"
>  # include "virstoragefile.h"
>  
> -typedef enum virFileCloseFlags {
> +typedef enum {
>      VIR_FILE_CLOSE_PRESERVE_ERRNO = 1 << 0,
>      VIR_FILE_CLOSE_IGNORE_EBADF = 1 << 1,
>      VIR_FILE_CLOSE_DONT_LOG = 1 << 2,
> @@ -83,10 +83,10 @@ typedef virFileWrapperFd *virFileWrapperFdPtr;

Huh - that one was already a typedef, with the enum name used twice.

Once the conversions are all complete, I can help you write a syntax
check to ensure we use the same consistent style in new code.

ACK and pushed.  Congrats on your first libvirt patch.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]