summaryrefslogtreecommitdiff
path: root/lib/pvector.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2014-10-30 11:40:07 -0700
committerBen Pfaff <blp@nicira.com>2014-10-30 17:42:58 -0700
commiteb391b76aff9639547312ab93bdac9cc2e76c119 (patch)
tree74def014a95802688c356056eb00209d96e0e68d /lib/pvector.c
parentfa373af463a1421a1b55539911abf33a847bc9b1 (diff)
downloadopenvswitch-eb391b76aff9639547312ab93bdac9cc2e76c119.tar.gz
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>
Diffstat (limited to 'lib/pvector.c')
-rw-r--r--lib/pvector.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/pvector.c b/lib/pvector.c
index e6cb66444..3f2e9e885 100644
--- a/lib/pvector.c
+++ b/lib/pvector.c
@@ -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);