mirror of
https://github.com/openvswitch/ovs
synced 2025-09-05 08:45:23 +00:00
Embrace anonymous unions.
Several OVS structs contain embedded named unions, like this: struct { ... union { ... } u; }; C11 standardized a feature that many compilers already implemented anyway, where an embedded union may be unnamed, like this: struct { ... union { ... }; }; This is more convenient because it allows the programmer to omit "u." in many places. OVS already used this feature in several places. This commit embraces it in several others. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org> Tested-by: Alin Gabriel Serdean <aserdean@ovn.org> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
This commit is contained in:
@@ -83,19 +83,19 @@ struct ovsdb_base_type {
|
||||
struct ovsdb_table *refTable; /* Referenced table, if available. */
|
||||
enum ovsdb_ref_type refType; /* Reference type. */
|
||||
} uuid;
|
||||
} u;
|
||||
};
|
||||
};
|
||||
|
||||
#define OVSDB_BASE_VOID_INIT { .type = OVSDB_TYPE_VOID }
|
||||
#define OVSDB_BASE_INTEGER_INIT { .type = OVSDB_TYPE_INTEGER, \
|
||||
.u.integer = { INT64_MIN, INT64_MAX } }
|
||||
.integer = { INT64_MIN, INT64_MAX } }
|
||||
#define OVSDB_BASE_REAL_INIT { .type = OVSDB_TYPE_REAL, \
|
||||
.u.real = { -DBL_MAX, DBL_MAX } }
|
||||
.real = { -DBL_MAX, DBL_MAX } }
|
||||
#define OVSDB_BASE_BOOLEAN_INIT { .type = OVSDB_TYPE_BOOLEAN }
|
||||
#define OVSDB_BASE_STRING_INIT { .type = OVSDB_TYPE_STRING, \
|
||||
.u.string = { 0, UINT_MAX } }
|
||||
.string = { 0, UINT_MAX } }
|
||||
#define OVSDB_BASE_UUID_INIT { .type = OVSDB_TYPE_UUID, \
|
||||
.u.uuid = { NULL, NULL, 0 } }
|
||||
.uuid = { NULL, NULL, 0 } }
|
||||
|
||||
void ovsdb_base_type_init(struct ovsdb_base_type *, enum ovsdb_atomic_type);
|
||||
void ovsdb_base_type_clone(struct ovsdb_base_type *,
|
||||
@@ -180,21 +180,21 @@ ovsdb_atomic_type_is_valid(enum ovsdb_atomic_type atomic_type)
|
||||
static inline bool
|
||||
ovsdb_base_type_is_ref(const struct ovsdb_base_type *base)
|
||||
{
|
||||
return base->type == OVSDB_TYPE_UUID && base->u.uuid.refTableName;
|
||||
return base->type == OVSDB_TYPE_UUID && base->uuid.refTableName;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
ovsdb_base_type_is_strong_ref(const struct ovsdb_base_type *base)
|
||||
{
|
||||
return (ovsdb_base_type_is_ref(base)
|
||||
&& base->u.uuid.refType == OVSDB_REF_STRONG);
|
||||
&& base->uuid.refType == OVSDB_REF_STRONG);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
ovsdb_base_type_is_weak_ref(const struct ovsdb_base_type *base)
|
||||
{
|
||||
return (ovsdb_base_type_is_ref(base)
|
||||
&& base->u.uuid.refType == OVSDB_REF_WEAK);
|
||||
&& base->uuid.refType == OVSDB_REF_WEAK);
|
||||
}
|
||||
|
||||
static inline bool ovsdb_type_is_scalar(const struct ovsdb_type *type)
|
||||
|
Reference in New Issue
Block a user