mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 13:58:14 +00:00
Avoid warnings about comparisons that are always true.
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 <yamamoto@valinux.co.jp>
This commit is contained in:
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user