diff mbox series

[ovs-dev] ovsdb-types: Refactor structs so as to comply with C++ standard

Message ID 1538682141-28899-1-git-send-email-pkusunyifeng@gmail.com
State Accepted
Headers show
Series [ovs-dev] ovsdb-types: Refactor structs so as to comply with C++ standard | expand

Commit Message

Yifeng Sun Oct. 4, 2018, 7:42 p.m. UTC
C++ standard only accepts anonymous struct inside
anonymous union. This patch re-organized the structs so
that this header file can be used in C++ source files.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
---
Please backport to 2.10, thanks.

 lib/ovsdb-types.h | 46 +++++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

Comments

Ben Pfaff Oct. 4, 2018, 8:42 p.m. UTC | #1
On Thu, Oct 04, 2018 at 12:42:21PM -0700, Yifeng Sun wrote:
> C++ standard only accepts anonymous struct inside
> anonymous union. This patch re-organized the structs so
> that this header file can be used in C++ source files.
> 
> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
> ---
> Please backport to 2.10, thanks.

Applied to master and branch-2.10, thanks!
diff mbox series

Patch

diff --git a/lib/ovsdb-types.h b/lib/ovsdb-types.h
index 368c41617794..b9eb0928df6b 100644
--- a/lib/ovsdb-types.h
+++ b/lib/ovsdb-types.h
@@ -53,6 +53,27 @@  enum ovsdb_ref_type {
     OVSDB_REF_WEAK              /* Delete reference if target disappears. */
 };
 
+struct ovsdb_integer_constraints {
+    int64_t min;        /* minInteger or INT64_MIN. */
+    int64_t max;        /* maxInteger or INT64_MAX. */
+};
+
+struct ovsdb_real_constraints {
+    double min;         /* minReal or -DBL_MAX. */
+    double max;         /* minReal or DBL_MAX. */
+};
+
+struct ovsdb_string_constraints {
+    unsigned int minLen; /* minLength or 0. */
+    unsigned int maxLen; /* maxLength or UINT_MAX. */
+};
+
+struct ovsdb_uuid_constraints {
+    char *refTableName; /* Name of referenced table, or NULL. */
+    struct ovsdb_table *refTable; /* Referenced table, if available. */
+    enum ovsdb_ref_type refType;  /* Reference type. */
+};
+
 struct ovsdb_base_type {
     enum ovsdb_atomic_type type;
 
@@ -61,28 +82,11 @@  struct ovsdb_base_type {
     struct ovsdb_datum *enum_;
 
     union {
-        struct ovsdb_integer_constraints {
-            int64_t min;        /* minInteger or INT64_MIN. */
-            int64_t max;        /* maxInteger or INT64_MAX. */
-        } integer;
-
-        struct ovsdb_real_constraints {
-            double min;         /* minReal or -DBL_MAX. */
-            double max;         /* minReal or DBL_MAX. */
-        } real;
-
+        struct ovsdb_integer_constraints integer;
+        struct ovsdb_real_constraints real;
         /* No constraints for Boolean types. */
-
-        struct ovsdb_string_constraints {
-            unsigned int minLen; /* minLength or 0. */
-            unsigned int maxLen; /* maxLength or UINT_MAX. */
-        } string;
-
-        struct ovsdb_uuid_constraints {
-            char *refTableName; /* Name of referenced table, or NULL. */
-            struct ovsdb_table *refTable; /* Referenced table, if available. */
-            enum ovsdb_ref_type refType;  /* Reference type. */
-        } uuid;
+        struct ovsdb_string_constraints string;
+        struct ovsdb_uuid_constraints uuid;
     };
 };