Skip to content

Commit

Permalink
ofp-actions: Add casts to placate C++ compilers.
Browse files Browse the repository at this point in the history
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>
Acked-by: Russell Bryant <russell@ovn.org>
  • Loading branch information
blp committed Jul 31, 2017
1 parent af0e972 commit 9965bc0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/openvswitch/ofp-actions.h
Expand Up @@ -195,15 +195,16 @@ 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 *);

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 *
Expand Down Expand Up @@ -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 \
Expand All @@ -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
Expand Down

0 comments on commit 9965bc0

Please sign in to comment.