summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-11-21 17:44:07 +0100
committerThomas Haller <thaller@redhat.com>2022-11-21 17:56:48 +0100
commit48d7d1d78eb27a7fb35ff84d9d208e5122a93940 (patch)
tree70875a8b896cce88d1807acb65c8ccfa77b0b1bd
parent8cc41d41feca14563ea1bbd755c46c6495ba6e0f (diff)
downloadNetworkManager-ff/platform_ecmp.tar.gz
platform: drop inline cmp() wrappers around "full" versionsff/platform_ecmp
We sometimes have functions foo() and foo_full(), in which case foo() has fewer arguments and just calls foo_full(). The "full" function here is the more powerful one, and foo() is implemented in terms of the former. nm_platform_ip4_route_cmp_full() and m_platform_ip4_route_cmp() inverted that pattern. The "_full" there stands for the full comparison, to not allowing to select the comparison type. That inconsistency is ugly. Also, these wrappers were used at only few places. Let's drop them. While at it, also drop nm_platform_qdisc_cmp() and rename nm_platform_qdisc_cmp_full(). Here cmp()/cmp_full() followed the common pattern foo()/foo_full(), but it's still hardly used and unnecessary.
-rw-r--r--src/core/nm-test-utils-core.h14
-rw-r--r--src/libnm-platform/nm-platform.c10
-rw-r--r--src/libnm-platform/nm-platform.h23
-rw-r--r--src/libnm-platform/nmp-object.c32
4 files changed, 40 insertions, 39 deletions
diff --git a/src/core/nm-test-utils-core.h b/src/core/nm-test-utils-core.h
index 725f58d2ce..e341d62f13 100644
--- a/src/core/nm-test-utils-core.h
+++ b/src/core/nm-test-utils-core.h
@@ -178,8 +178,9 @@ nmtst_platform_ip6_route_full(const char *network,
static inline int
_nmtst_platform_ip4_routes_equal_sort(gconstpointer a, gconstpointer b, gpointer user_data)
{
- return nm_platform_ip4_route_cmp_full((const NMPlatformIP4Route *) a,
- (const NMPlatformIP4Route *) b);
+ return nm_platform_ip4_route_cmp((const NMPlatformIP4Route *) a,
+ (const NMPlatformIP4Route *) b,
+ NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL);
}
static inline void
@@ -210,7 +211,7 @@ nmtst_platform_ip4_routes_equal(const NMPlatformIP4Route *a,
}
for (i = 0; i < len; i++) {
- if (nm_platform_ip4_route_cmp_full(&a[i], &b[i]) != 0) {
+ if (nm_platform_ip4_route_cmp(&a[i], &b[i], NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) != 0) {
char buf1[NM_UTILS_TO_STRING_BUFFER_SIZE];
char buf2[NM_UTILS_TO_STRING_BUFFER_SIZE];
@@ -248,8 +249,9 @@ nmtst_platform_ip4_routes_equal_aptr(const NMPObject *const *a,
static inline int
_nmtst_platform_ip6_routes_equal_sort(gconstpointer a, gconstpointer b, gpointer user_data)
{
- return nm_platform_ip6_route_cmp_full((const NMPlatformIP6Route *) a,
- (const NMPlatformIP6Route *) b);
+ return nm_platform_ip6_route_cmp((const NMPlatformIP6Route *) a,
+ (const NMPlatformIP6Route *) b,
+ NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL);
}
static inline void
@@ -280,7 +282,7 @@ nmtst_platform_ip6_routes_equal(const NMPlatformIP6Route *a,
}
for (i = 0; i < len; i++) {
- if (nm_platform_ip6_route_cmp_full(&a[i], &b[i]) != 0) {
+ if (nm_platform_ip6_route_cmp(&a[i], &b[i], NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) != 0) {
char buf1[NM_UTILS_TO_STRING_BUFFER_SIZE];
char buf2[NM_UTILS_TO_STRING_BUFFER_SIZE];
diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c
index c5fcf50bc4..d28e8771f0 100644
--- a/src/libnm-platform/nm-platform.c
+++ b/src/libnm-platform/nm-platform.c
@@ -7316,9 +7316,7 @@ nm_platform_qdisc_hash_update(const NMPlatformQdisc *obj, NMHashState *h)
}
int
-nm_platform_qdisc_cmp_full(const NMPlatformQdisc *a,
- const NMPlatformQdisc *b,
- gboolean compare_handle)
+nm_platform_qdisc_cmp(const NMPlatformQdisc *a, const NMPlatformQdisc *b, gboolean compare_handle)
{
NM_CMP_SELF(a, b);
NM_CMP_FIELD(a, b, ifindex);
@@ -7355,12 +7353,6 @@ nm_platform_qdisc_cmp_full(const NMPlatformQdisc *a,
return 0;
}
-int
-nm_platform_qdisc_cmp(const NMPlatformQdisc *a, const NMPlatformQdisc *b)
-{
- return nm_platform_qdisc_cmp_full(a, b, TRUE);
-}
-
const char *
nm_platform_tfilter_to_string(const NMPlatformTfilter *tfilter, char *buf, gsize len)
{
diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h
index b4bbc64e2b..32773b67ad 100644
--- a/src/libnm-platform/nm-platform.h
+++ b/src/libnm-platform/nm-platform.h
@@ -2341,32 +2341,13 @@ int nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a,
const NMPlatformIP6Route *b,
NMPlatformIPRouteCmpType cmp_type);
-static inline int
-nm_platform_ip4_route_cmp_full(const NMPlatformIP4Route *a, const NMPlatformIP4Route *b)
-{
- return nm_platform_ip4_route_cmp(a, b, NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL);
-}
-
-static inline int
-nm_platform_ip6_route_cmp_full(const NMPlatformIP6Route *a, const NMPlatformIP6Route *b)
-{
- return nm_platform_ip6_route_cmp(a, b, NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL);
-}
-
int nm_platform_routing_rule_cmp(const NMPlatformRoutingRule *a,
const NMPlatformRoutingRule *b,
NMPlatformRoutingRuleCmpType cmp_type);
-static inline int
-nm_platform_routing_rule_cmp_full(const NMPlatformRoutingRule *a, const NMPlatformRoutingRule *b)
-{
- return nm_platform_routing_rule_cmp(a, b, NM_PLATFORM_ROUTING_RULE_CMP_TYPE_FULL);
-}
+int
+nm_platform_qdisc_cmp(const NMPlatformQdisc *a, const NMPlatformQdisc *b, gboolean compare_handle);
-int nm_platform_qdisc_cmp(const NMPlatformQdisc *a, const NMPlatformQdisc *b);
-int nm_platform_qdisc_cmp_full(const NMPlatformQdisc *a,
- const NMPlatformQdisc *b,
- gboolean compare_handle);
int nm_platform_tfilter_cmp(const NMPlatformTfilter *a, const NMPlatformTfilter *b);
int nm_platform_mptcp_addr_cmp(const NMPlatformMptcpAddr *a, const NMPlatformMptcpAddr *b);
diff --git a/src/libnm-platform/nmp-object.c b/src/libnm-platform/nmp-object.c
index 06457e3927..c95dd6ed34 100644
--- a/src/libnm-platform/nmp-object.c
+++ b/src/libnm-platform/nmp-object.c
@@ -1795,6 +1795,14 @@ _vt_cmd_plobj_hash_update_ip6_route(const NMPlatformObject *obj, NMHashState *h)
h);
}
+static int
+_vt_cmd_plobj_cmp_ip6_route(const NMPlatformObject *obj1, const NMPlatformObject *obj2)
+{
+ return nm_platform_ip6_route_cmp((const NMPlatformIP6Route *) obj1,
+ (const NMPlatformIP6Route *) obj2,
+ NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL);
+}
+
static void
_vt_cmd_plobj_hash_update_routing_rule(const NMPlatformObject *obj, NMHashState *h)
{
@@ -1803,6 +1811,24 @@ _vt_cmd_plobj_hash_update_routing_rule(const NMPlatformObject *obj, NMHashState
h);
}
+static inline int
+_vt_cmd_plobj_cmp_routing_rule(const NMPlatformObject *obj1, const NMPlatformObject *obj2)
+{
+ return nm_platform_routing_rule_cmp((const NMPlatformRoutingRule *) obj1,
+ (const NMPlatformRoutingRule *) obj2,
+ NM_PLATFORM_ROUTING_RULE_CMP_TYPE_FULL);
+}
+
+static int
+_vt_cmd_plobj_cmp_qdisc(const NMPlatformObject *obj1, const NMPlatformObject *obj2)
+{
+ return nm_platform_qdisc_cmp((const NMPlatformQdisc *) obj1,
+ (const NMPlatformQdisc *) obj2,
+ TRUE);
+}
+
+/*****************************************************************************/
+
guint
nmp_object_indirect_id_hash(gconstpointer a)
{
@@ -3333,7 +3359,7 @@ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = {
.cmd_plobj_to_string_id = (CmdPlobjToStringIdFunc) nm_platform_ip6_route_to_string,
.cmd_plobj_to_string = (CmdPlobjToStringFunc) nm_platform_ip6_route_to_string,
.cmd_plobj_hash_update = _vt_cmd_plobj_hash_update_ip6_route,
- .cmd_plobj_cmp = (CmdPlobjCmpFunc) nm_platform_ip6_route_cmp_full,
+ .cmd_plobj_cmp = _vt_cmd_plobj_cmp_ip6_route,
},
[NMP_OBJECT_TYPE_ROUTING_RULE - 1] =
{
@@ -3352,7 +3378,7 @@ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = {
.cmd_plobj_to_string_id = (CmdPlobjToStringIdFunc) nm_platform_routing_rule_to_string,
.cmd_plobj_to_string = (CmdPlobjToStringFunc) nm_platform_routing_rule_to_string,
.cmd_plobj_hash_update = _vt_cmd_plobj_hash_update_routing_rule,
- .cmd_plobj_cmp = (CmdPlobjCmpFunc) nm_platform_routing_rule_cmp_full,
+ .cmd_plobj_cmp = _vt_cmd_plobj_cmp_routing_rule,
},
[NMP_OBJECT_TYPE_QDISC - 1] =
{
@@ -3371,7 +3397,7 @@ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = {
.cmd_plobj_to_string_id = _vt_cmd_plobj_to_string_id_qdisc,
.cmd_plobj_to_string = (CmdPlobjToStringFunc) nm_platform_qdisc_to_string,
.cmd_plobj_hash_update = (CmdPlobjHashUpdateFunc) nm_platform_qdisc_hash_update,
- .cmd_plobj_cmp = (CmdPlobjCmpFunc) nm_platform_qdisc_cmp,
+ .cmd_plobj_cmp = _vt_cmd_plobj_cmp_qdisc,
},
[NMP_OBJECT_TYPE_TFILTER - 1] =
{