summaryrefslogtreecommitdiff
path: root/tests/test-hmap.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2013-06-25 09:22:11 -0700
committerBen Pfaff <blp@nicira.com>2013-06-28 16:09:39 -0700
commitb028db44ca684fbd5361001dc3ed543a37374fbb (patch)
treec0b0d66a5bea69c498efbbcd39b6eb24d3343a0c /tests/test-hmap.c
parent61d71ceb5d45e6caeaf08a63efeba931a10b32f3 (diff)
downloadopenvswitch-b028db44ca684fbd5361001dc3ed543a37374fbb.tar.gz
Use random_*() instead of rand(), for thread safety.
None of these test programs are threaded, but has little cost and means that "grep" doesn't turn up any instances of these thread-unsafe functions in our tree. Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'tests/test-hmap.c')
-rw-r--r--tests/test-hmap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/test-hmap.c b/tests/test-hmap.c
index c202eae14..6102be332 100644
--- a/tests/test-hmap.c
+++ b/tests/test-hmap.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
#include "hmap.h"
#include <string.h>
#include "hash.h"
+#include "random.h"
#include "util.h"
#undef NDEBUG
@@ -108,7 +109,7 @@ static void
shuffle(int *p, size_t n)
{
for (; n > 1; n--, p++) {
- int *q = &p[rand() % n];
+ int *q = &p[random_range(n)];
int tmp = *p;
*p = *q;
*q = tmp;