Looks Good.
On Fri, Apr 15, 2011 at 9:41 AM, Ben Pfaff <[email protected]> wrote: > The range of "enum" types varies from one ABI to another. If the enums > being tested in these functions happen to be 16 bits wide, then GCC may > issue a warning because, in such a case, the comparison is always true. > > Using an int instead of a uint16_t avoids that particular problem and > should suppress the warning. > > Fixes the following reported warnings: > > lib/ofp-print.c:240: warning: comparison is always true due to limited > range of data type > lib/ofp-util.c:1973: warning: comparison is always false due to limited > range of data type > > Reported-by: YAMAMOTO Takashi <[email protected]> > --- > lib/ofp-print.c | 4 ++-- > lib/ofp-util.c | 7 +++---- > 2 files changed, 5 insertions(+), 6 deletions(-) > > diff --git a/lib/ofp-print.c b/lib/ofp-print.c > index 6560f32..30f6d37 100644 > --- a/lib/ofp-print.c > +++ b/lib/ofp-print.c > @@ -227,7 +227,7 @@ nx_action_len(enum nx_action_subtype subtype) > static void > ofp_print_nx_action(struct ds *string, const struct nx_action_header *nah) > { > - uint16_t subtype = ntohs(nah->subtype); > + int subtype = ntohs(nah->subtype); > int required_len = nx_action_len(subtype); > int len = ntohs(nah->len); > > @@ -312,7 +312,7 @@ ofp_print_nx_action(struct ds *string, const struct > nx_action_header *nah) > } > } > > - ds_put_format(string, "***unknown Nicira action:%"PRIu16"***", subtype); > + ds_put_format(string, "***unknown Nicira action:%d***", subtype); > } > > static int > diff --git a/lib/ofp-util.c b/lib/ofp-util.c > index c49b079..bcaf3dd 100644 > --- a/lib/ofp-util.c > +++ b/lib/ofp-util.c > @@ -1959,7 +1959,7 @@ check_nicira_action(const union ofp_action *a, unsigned > int len, > const struct flow *flow) > { > const struct nx_action_header *nah; > - uint16_t subtype; > + int subtype; > int error; > > if (len < 16) { > @@ -1971,7 +1971,7 @@ check_nicira_action(const union ofp_action *a, unsigned > int len, > > subtype = ntohs(nah->subtype); > if (subtype > TYPE_MAXIMUM(enum nx_action_subtype)) { > - /* This is necessary because enum nx_action_subtype is probably an > + /* This is necessary because enum nx_action_subtype may be an > * 8-bit type, so the cast below throws away the top 8 bits. */ > return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_VENDOR_TYPE); > } > @@ -2026,8 +2026,7 @@ check_nicira_action(const union ofp_action *a, unsigned > int len, > case NXAST_SNAT__OBSOLETE: > default: > VLOG_WARN_RL(&bad_ofmsg_rl, > - "unknown Nicira vendor action subtype %"PRIu16, > - ntohs(nah->subtype)); > + "unknown Nicira vendor action subtype %d", subtype); > return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_VENDOR_TYPE); > } > } > -- > 1.7.1 > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
