diff mbox series

[1/2] ipconfig: Expand and harmonize 'DBG' in '__connman_ipconfig_gateway_{add,remove}'

Message ID 20231128192304.1179479-2-gerickson@nuovations.com (mailing list archive)
State Not Applicable, archived
Headers show
Series ipconfig: Add DBG and Documentation to '__connman_ipconfig_gateway_{add,remove}' | expand

Commit Message

Grant Erickson Nov. 28, 2023, 7:23 p.m. UTC
This expands and aligns the initial 'DBG' statements in
'__connman_ipconfig_gateway_{add,remove}' to aid debugging in a
multi-technology environment with "EnableOnlineToReadyTransition"
asserted.
---
 src/ipconfig.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 25e86bca292b..7c3418d51982 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -103,6 +103,11 @@  static GHashTable *ipdevice_hash = NULL;
 static GList *ipconfig_list = NULL;
 static bool is_ipv6_supported = false;
 
+static const char *maybe_null(const void *pointer)
+{
+	return pointer ? pointer : "<null>";
+}
+
 static void store_set_str(struct ipconfig_store *store,
 			const char *key, const char *val)
 
@@ -1324,8 +1329,13 @@  void __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig,
 int __connman_ipconfig_gateway_add(const struct connman_ipconfig *ipconfig)
 {
 	struct connman_service *service;
+	g_autofree char *interface = NULL;
 
-	DBG("");
+	interface = connman_inet_ifname(ipconfig->index);
+
+	DBG("ipconfig %p type %d (%s) index %d (%s)", ipconfig,
+		ipconfig->type, __connman_ipconfig_type2string(ipconfig->type),
+		ipconfig->index, maybe_null(interface));
 
 	if (!ipconfig->address)
 		return -EINVAL;
@@ -1334,7 +1344,7 @@  int __connman_ipconfig_gateway_add(const struct connman_ipconfig *ipconfig)
 	if (!service)
 		return -EINVAL;
 
-	DBG("type %d gw %s peer %s", ipconfig->type,
+	DBG("gw %s peer %s",
 		ipconfig->address->gateway, ipconfig->address->peer);
 
 	if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6 ||
@@ -1350,8 +1360,13 @@  int __connman_ipconfig_gateway_add(const struct connman_ipconfig *ipconfig)
 void __connman_ipconfig_gateway_remove(const struct connman_ipconfig *ipconfig)
 {
 	struct connman_service *service;
+	g_autofree char *interface = NULL;
 
-	DBG("");
+	interface = connman_inet_ifname(ipconfig->index);
+
+	DBG("ipconfig %p type %d (%s) index %d (%s)", ipconfig,
+		ipconfig->type, __connman_ipconfig_type2string(ipconfig->type),
+		ipconfig->index, maybe_null(interface));
 
 	service = __connman_service_lookup_from_index(ipconfig->index);
 	if (service)