From 965ab8a45a95c23362c2f15a3a35ecd5a999a780 Mon Sep 17 00:00:00 2001
From: "nevadita.chatterjee" <nevadita.chatterjee@iopsys.eu>
Date: Thu, 28 Sep 2023 14:24:23 +0530
Subject: [PATCH] map-topology: Fix compiler warnings

---
 src/ieee1905/topologyd.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/ieee1905/topologyd.c b/src/ieee1905/topologyd.c
index c626e1e..197b7c3 100644
--- a/src/ieee1905/topologyd.c
+++ b/src/ieee1905/topologyd.c
@@ -1508,6 +1508,7 @@ void topologyd_dump_node(struct blob_buf *bb, struct node *p, int is_self)
 	blobmsg_add_u32(bb, "l2_neighbor_num", p->l2_nbr_num);
 	l2_neighbor = blobmsg_open_array(bb, "l2_neighbor");
 	for (j = 0; j < p->l2_nbr_num; j++) {
+		int length = 0;
 		table = blobmsg_open_table(bb, NULL);
 		hwaddr_ntoa(p->l2_nbr[j].l2_intf_addr, mac_str);
 		blobmsg_add_string(bb, "local_intf_id", mac_str);
@@ -1524,6 +1525,10 @@ void topologyd_dump_node(struct blob_buf *bb, struct node *p, int is_self)
 
 			snprintf(behind_mac_str + len,  size - len , "%s,", mac_str);
 		}
+		length = strlen(behind_mac_str);
+		/*to overwrite the last comma*/
+		if (length > 0)
+			behind_mac_str[length - 1] = '\0';
 		blobmsg_add_string(bb, "behind_mac_id", behind_mac_str);
 		blobmsg_close_table(bb, table);
 	}
-- 
GitLab