diff mbox

[ovs-dev,1/5] ofp-actions: Add casts to placate C++ compilers.

Message ID 20170731025500.16294-1-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff July 31, 2017, 2:54 a.m. UTC
C++ does not allow for an implicit conversion from void * to pointer to
object or incomplete type.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 include/openvswitch/ofp-actions.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Russell Bryant July 31, 2017, 7:44 p.m. UTC | #1
On Sun, Jul 30, 2017 at 10:54 PM, Ben Pfaff <blp@ovn.org> wrote:
> C++ does not allow for an implicit conversion from void * to pointer to
> object or incomplete type.
>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---
>  include/openvswitch/ofp-actions.h | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)

Acked-by: Russell Bryant <russell@ovn.org>
diff mbox

Patch

diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h
index 7b4aa9201d9b..00dde7c89e8d 100644
--- a/include/openvswitch/ofp-actions.h
+++ b/include/openvswitch/ofp-actions.h
@@ -195,7 +195,8 @@  BUILD_ASSERT_DECL(sizeof(struct ofpact) == 4);
 static inline struct ofpact *
 ofpact_next(const struct ofpact *ofpact)
 {
-    return (void *) ((uint8_t *) ofpact + OFPACT_ALIGN(ofpact->len));
+    return ALIGNED_CAST(struct ofpact *,
+                        (uint8_t *) ofpact + OFPACT_ALIGN(ofpact->len));
 }
 
 struct ofpact *ofpact_next_flattened(const struct ofpact *);
@@ -203,7 +204,7 @@  struct ofpact *ofpact_next_flattened(const struct ofpact *);
 static inline struct ofpact *
 ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len)
 {
-    return (void *) ((uint8_t *) ofpacts + ofpacts_len);
+    return ALIGNED_CAST(struct ofpact *, (uint8_t *) ofpacts + ofpacts_len);
 }
 
 static inline const struct ofpact *
@@ -1103,8 +1104,8 @@  void *ofpact_finish(struct ofpbuf *, struct ofpact *);
     static inline struct STRUCT *                                       \
     ofpact_put_##ENUM(struct ofpbuf *ofpacts)                           \
     {                                                                   \
-        return ofpact_put(ofpacts, OFPACT_##ENUM,                       \
-                          OFPACT_##ENUM##_SIZE);                        \
+        return (struct STRUCT *) ofpact_put(ofpacts, OFPACT_##ENUM,     \
+                                            OFPACT_##ENUM##_SIZE);      \
     }                                                                   \
                                                                         \
     static inline void                                                  \
@@ -1119,7 +1120,7 @@  void *ofpact_finish(struct ofpbuf *, struct ofpact *);
     {                                                                   \
         struct ofpact *ofpact = &(*ofpactp)->ofpact;                    \
         ovs_assert(ofpact->type == OFPACT_##ENUM);                      \
-        *ofpactp = ofpact_finish(ofpbuf, ofpact);                       \
+        *ofpactp = (struct STRUCT *) ofpact_finish(ofpbuf, ofpact);     \
     }
 OFPACTS
 #undef OFPACT