2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +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:
Ben Pfaff
2011-04-15 09:39:08 -07:00
parent 858f285284
commit 5160ab34f8
2 changed files with 5 additions and 6 deletions

View File

@@ -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