summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-08-20 13:59:07 -0500
committerDan Williams <dcbw@redhat.com>2014-08-20 14:18:14 -0500
commite7381662fe7b56b4725c10ea4cbd6c0cb455a400 (patch)
tree66e9a90f062e902cc18a8153ae078523438b51d0
parentb59a82d82ea55ee6b511e7c211572591e570efac (diff)
downloadNetworkManager-e7381662fe7b56b4725c10ea4cbd6c0cb455a400.tar.gz
trivial: don't shadow rand(3)
Reported by Jordan Messina (cherry picked from commit 365ca198c0d688e759cd2481d9446ba16f8e78ca)
-rw-r--r--libnm-util/tests/test-general.c10
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c14
-rw-r--r--src/tests/test-general.c24
3 files changed, 24 insertions, 24 deletions
diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c
index 468cdf21e8..87e29f5977 100644
--- a/libnm-util/tests/test-general.c
+++ b/libnm-util/tests/test-general.c
@@ -1830,9 +1830,9 @@ test_ip4_netmask_to_prefix (void)
{
int i, j;
- GRand *rand = g_rand_new ();
+ GRand *r = g_rand_new ();
- g_rand_set_seed (rand, 1);
+ g_rand_set_seed (r, 1);
for (i = 2; i<=32; i++) {
guint32 netmask = nm_utils_ip4_prefix_to_netmask (i);
@@ -1841,11 +1841,11 @@ test_ip4_netmask_to_prefix (void)
g_assert_cmpint (i, ==, nm_utils_ip4_netmask_to_prefix (netmask));
for (j = 0; j < 2*i; j++) {
- guint32 r = g_rand_int (rand);
+ guint32 n = g_rand_int (r);
guint32 netmask_holey;
guint32 prefix_holey;
- netmask_holey = (netmask & r) | netmask_lowest_bit;
+ netmask_holey = (netmask & n) | netmask_lowest_bit;
if (netmask_holey == netmask)
continue;
@@ -1858,7 +1858,7 @@ test_ip4_netmask_to_prefix (void)
}
}
- g_rand_free (rand);
+ g_rand_free (r);
}
#define ASSERT_CHANGED(statement) \
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index d2e8459326..8de6977fc9 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -14465,10 +14465,10 @@ static void
test_svUnescape ()
{
int len, repeat, i, k;
- GRand *rand = g_rand_new ();
+ GRand *r = g_rand_new ();
guint32 seed = g_random_int ();
- g_rand_set_seed (rand, seed);
+ g_rand_set_seed (r, seed);
test_svUnescape_assert ("");
test_svUnescape_assert ("'");
@@ -14489,16 +14489,16 @@ test_svUnescape ()
/* fill the entire string with random. */
for (i = 0; i < len; i++)
- s[i] = g_rand_int (rand);
+ s[i] = g_rand_int (r);
/* randomly place escape characters into the string */
- k = g_rand_int (rand) % (len);
+ k = g_rand_int (r) % (len);
while (k-- > 0)
- s[g_rand_int (rand) % len] = '\\';
+ s[g_rand_int (r) % len] = '\\';
if (len > 1) {
/* quote the string. */
- k = g_rand_int (rand) % (10);
+ k = g_rand_int (r) % (10);
if (k < 4) {
char quote = k < 2 ? '"' : '\'';
@@ -14514,7 +14514,7 @@ test_svUnescape ()
g_free (s);
}
- g_rand_free (rand);
+ g_rand_free (r);
}
diff --git a/src/tests/test-general.c b/src/tests/test-general.c
index 9da8c2da0e..0a969c89f4 100644
--- a/src/tests/test-general.c
+++ b/src/tests/test-general.c
@@ -179,51 +179,51 @@ ip6_address_clear_host_address_reference (struct in6_addr *dst, struct in6_addr
}
static void
-_randomize_in6_addr (struct in6_addr *addr, GRand *rand)
+_randomize_in6_addr (struct in6_addr *addr, GRand *r)
{
int i;
for (i=0; i < 4; i++)
- ((guint32 *)addr)[i] = g_rand_int (rand);
+ ((guint32 *)addr)[i] = g_rand_int (r);
}
static void
test_nm_utils_ip6_address_clear_host_address (void)
{
- GRand *rand = g_rand_new ();
+ GRand *r = g_rand_new ();
int plen, i;
- g_rand_set_seed (rand, 0);
+ g_rand_set_seed (r, 0);
for (plen = 0; plen <= 128; plen++) {
for (i =0; i<50; i++) {
struct in6_addr addr_src, addr_ref;
struct in6_addr addr1, addr2;
- _randomize_in6_addr (&addr_src, rand);
- _randomize_in6_addr (&addr_ref, rand);
- _randomize_in6_addr (&addr1, rand);
- _randomize_in6_addr (&addr2, rand);
+ _randomize_in6_addr (&addr_src, r);
+ _randomize_in6_addr (&addr_ref, r);
+ _randomize_in6_addr (&addr1, r);
+ _randomize_in6_addr (&addr2, r);
addr1 = addr_src;
ip6_address_clear_host_address_reference (&addr_ref, &addr1, plen);
- _randomize_in6_addr (&addr1, rand);
- _randomize_in6_addr (&addr2, rand);
+ _randomize_in6_addr (&addr1, r);
+ _randomize_in6_addr (&addr2, r);
addr1 = addr_src;
nm_utils_ip6_address_clear_host_address (&addr2, &addr1, plen);
g_assert_cmpint (memcmp (&addr1, &addr_src, sizeof (struct in6_addr)), ==, 0);
g_assert_cmpint (memcmp (&addr2, &addr_ref, sizeof (struct in6_addr)), ==, 0);
/* test for self assignment/inplace update. */
- _randomize_in6_addr (&addr1, rand);
+ _randomize_in6_addr (&addr1, r);
addr1 = addr_src;
nm_utils_ip6_address_clear_host_address (&addr1, &addr1, plen);
g_assert_cmpint (memcmp (&addr1, &addr_ref, sizeof (struct in6_addr)), ==, 0);
}
}
- g_rand_free (rand);
+ g_rand_free (r);
}
/*******************************************/