2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00

classifier: Change type used for priorities from 'unsigned int' to 'int'.

OpenFlow has priorities in the 16-bit unsigned range, from 0 to 65535.
In the classifier, it is sometimes useful to be able to have values below
and above this range.  With the 'unsigned int' type used for priorities
until now, there were no values below the range, so some code worked
around it by converting priorities to 64-bit signed integers.  This didn't
seem so great to me given that a plain 'int' also had the needed range.
This commit therefore changes the type used for priorities to int.

The interesting parts of this change are in pvector.h and classifier.c,
where one can see the elimination of the use of int64_t.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
This commit is contained in:
Ben Pfaff
2014-10-30 11:40:07 -07:00
parent fa373af463
commit eb391b76af
13 changed files with 68 additions and 76 deletions

View File

@@ -69,8 +69,10 @@ pvector_destroy(struct pvector *pvec)
static int
pvector_entry_cmp(const void *a_, const void *b_)
{
unsigned int a = ((const struct pvector_entry *)a_)->priority;
unsigned int b = ((const struct pvector_entry *)b_)->priority;
const struct pvector_entry *ap = a_;
const struct pvector_entry *bp = b_;
int a = ap->priority;
int b = bp->priority;
return a > b ? -1 : a < b;
}
@@ -85,7 +87,7 @@ pvector_impl_sort(struct pvector_impl *impl)
* which will be one past the vector if none exists. */
static int
pvector_impl_find_priority(struct pvector_impl *impl,
unsigned int target_priority)
int target_priority)
{
const struct pvector_entry *entry;
int index;
@@ -114,7 +116,7 @@ pvector_impl_find(struct pvector_impl *impl, void *target)
}
void
pvector_insert(struct pvector *pvec, void *ptr, unsigned int priority)
pvector_insert(struct pvector *pvec, void *ptr, int priority)
{
struct pvector_impl *old, *new;
int index;
@@ -182,7 +184,7 @@ pvector_remove(struct pvector *pvec, void *ptr)
/* Change entry's 'priority' and keep the vector ordered. */
void
pvector_change_priority(struct pvector *pvec, void *ptr, unsigned int priority)
pvector_change_priority(struct pvector *pvec, void *ptr, int priority)
{
struct pvector_impl *old = pvector_impl_get(pvec);
int index = pvector_impl_find(old, ptr);