summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-03-24 11:27:41 +0100
committerThomas Haller <thaller@redhat.com>2017-03-24 11:28:57 +0100
commit0a34ae55a23248f3a96d9a468527e9465dd148e7 (patch)
tree41ae7543892583741672eb198b9d70269f91406b
parent29a47f40f8d438595c14b15e5456bf42f7e0804c (diff)
downloadNetworkManager-0a34ae55a23248f3a96d9a468527e9465dd148e7.tar.gz
core/trivial: rename nm_utils_10pow() to nm_utils_exp10()
nm_utils_exp10() is a better name, because it reminds of the function exp10() from <math.h> which has a similar purpose (but whose argument is double, not gint16).
-rw-r--r--src/nm-core-utils.c14
-rw-r--r--src/nm-core-utils.h2
-rw-r--r--src/platform/wifi/wifi-utils-wext.c2
-rw-r--r--src/tests/test-general.c48
4 files changed, 33 insertions, 33 deletions
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
index 11b2085b2c..6853a3bdde 100644
--- a/src/nm-core-utils.c
+++ b/src/nm-core-utils.c
@@ -156,14 +156,14 @@ _nm_singleton_instance_register_destruction (GObject *instance)
/*****************************************************************************/
static double
-_10pow (guint16 ex)
+_exp10 (guint16 ex)
{
double v;
if (ex == 0)
return 1.0;
- v = _10pow (ex / 2);
+ v = _exp10 (ex / 2);
v = v * v;
if (ex % 2)
v *= 10;
@@ -171,17 +171,17 @@ _10pow (guint16 ex)
}
/*/
- * nm_utils_10pow:
+ * nm_utils_exp10:
* @ex: the exponent
*
- * Returns: 10^ex or pow(10, ex)
+ * Returns: 10^ex, or pow(10, ex), or exp10(ex).
*/
double
-nm_utils_10pow (gint16 ex)
+nm_utils_exp10 (gint16 ex)
{
if (ex >= 0)
- return _10pow (ex);
- return 1.0 / _10pow (- ((gint32) ex));
+ return _exp10 (ex);
+ return 1.0 / _exp10 (- ((gint32) ex));
}
/*****************************************************************************/
diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
index fbeecf7a21..832d0dc760 100644
--- a/src/nm-core-utils.h
+++ b/src/nm-core-utils.h
@@ -97,7 +97,7 @@ in_addr_t nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen);
const struct in6_addr *nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen);
gboolean nm_utils_ip6_address_same_prefix (const struct in6_addr *addr_a, const struct in6_addr *addr_b, guint8 plen);
-double nm_utils_10pow (gint16 e);
+double nm_utils_exp10 (gint16 e);
/**
* nm_utils_ip6_route_metric_normalize:
diff --git a/src/platform/wifi/wifi-utils-wext.c b/src/platform/wifi/wifi-utils-wext.c
index 4250bc9e6c..4475453dc6 100644
--- a/src/platform/wifi/wifi-utils-wext.c
+++ b/src/platform/wifi/wifi-utils-wext.c
@@ -89,7 +89,7 @@ iw_freq_to_uint32 (const struct iw_freq *freq)
else if (freq->m == 14)
return 2484;
}
- return (guint32) ((((double) freq->m) * nm_utils_10pow (freq->e)) / 1000000.0);
+ return (guint32) ((((double) freq->m) * nm_utils_exp10 (freq->e)) / 1000000.0);
}
static void
diff --git a/src/tests/test-general.c b/src/tests/test-general.c
index abc1534003..cd1c9a9346 100644
--- a/src/tests/test-general.c
+++ b/src/tests/test-general.c
@@ -1657,7 +1657,7 @@ test_stable_id_generated_complete (void)
/*****************************************************************************/
static void
-test_nm_utils_10pow (void)
+test_nm_utils_exp10 (void)
{
#define FLOAT_CMP(a, b) \
G_STMT_START { \
@@ -1677,28 +1677,28 @@ test_nm_utils_10pow (void)
} \
} G_STMT_END
- FLOAT_CMP (nm_utils_10pow (G_MININT16), 0.0);
- FLOAT_CMP (nm_utils_10pow (-310), 0.0);
- FLOAT_CMP (nm_utils_10pow (-309), 0.0);
- FLOAT_CMP (nm_utils_10pow (-308), 1e-308);
- FLOAT_CMP (nm_utils_10pow (-307), 1e-307);
- FLOAT_CMP (nm_utils_10pow (-1), 1e-1);
- FLOAT_CMP (nm_utils_10pow (-2), 1e-2);
- FLOAT_CMP (nm_utils_10pow (0), 1e0);
- FLOAT_CMP (nm_utils_10pow (1), 1e1);
- FLOAT_CMP (nm_utils_10pow (2), 1e2);
- FLOAT_CMP (nm_utils_10pow (3), 1e3);
- FLOAT_CMP (nm_utils_10pow (4), 1e4);
- FLOAT_CMP (nm_utils_10pow (5), 1e5);
- FLOAT_CMP (nm_utils_10pow (6), 1e6);
- FLOAT_CMP (nm_utils_10pow (7), 1e7);
- FLOAT_CMP (nm_utils_10pow (122), 1e122);
- FLOAT_CMP (nm_utils_10pow (200), 1e200);
- FLOAT_CMP (nm_utils_10pow (307), 1e307);
- FLOAT_CMP (nm_utils_10pow (308), 1e308);
- FLOAT_CMP (nm_utils_10pow (309), INFINITY);
- FLOAT_CMP (nm_utils_10pow (310), INFINITY);
- FLOAT_CMP (nm_utils_10pow (G_MAXINT16), INFINITY);
+ FLOAT_CMP (nm_utils_exp10 (G_MININT16), 0.0);
+ FLOAT_CMP (nm_utils_exp10 (-310), 0.0);
+ FLOAT_CMP (nm_utils_exp10 (-309), 0.0);
+ FLOAT_CMP (nm_utils_exp10 (-308), 1e-308);
+ FLOAT_CMP (nm_utils_exp10 (-307), 1e-307);
+ FLOAT_CMP (nm_utils_exp10 (-1), 1e-1);
+ FLOAT_CMP (nm_utils_exp10 (-2), 1e-2);
+ FLOAT_CMP (nm_utils_exp10 (0), 1e0);
+ FLOAT_CMP (nm_utils_exp10 (1), 1e1);
+ FLOAT_CMP (nm_utils_exp10 (2), 1e2);
+ FLOAT_CMP (nm_utils_exp10 (3), 1e3);
+ FLOAT_CMP (nm_utils_exp10 (4), 1e4);
+ FLOAT_CMP (nm_utils_exp10 (5), 1e5);
+ FLOAT_CMP (nm_utils_exp10 (6), 1e6);
+ FLOAT_CMP (nm_utils_exp10 (7), 1e7);
+ FLOAT_CMP (nm_utils_exp10 (122), 1e122);
+ FLOAT_CMP (nm_utils_exp10 (200), 1e200);
+ FLOAT_CMP (nm_utils_exp10 (307), 1e307);
+ FLOAT_CMP (nm_utils_exp10 (308), 1e308);
+ FLOAT_CMP (nm_utils_exp10 (309), INFINITY);
+ FLOAT_CMP (nm_utils_exp10 (310), INFINITY);
+ FLOAT_CMP (nm_utils_exp10 (G_MAXINT16), INFINITY);
}
/*****************************************************************************/
@@ -1716,7 +1716,7 @@ main (int argc, char **argv)
g_test_add_func ("/general/nm_utils_ip6_address_same_prefix", test_nm_utils_ip6_address_same_prefix);
g_test_add_func ("/general/nm_utils_log_connection_diff", test_nm_utils_log_connection_diff);
- g_test_add_func ("/general/10pow", test_nm_utils_10pow);
+ g_test_add_func ("/general/exp10", test_nm_utils_exp10);
g_test_add_func ("/general/connection-match/basic", test_connection_match_basic);
g_test_add_func ("/general/connection-match/ip6-method", test_connection_match_ip6_method);