From 5340cb31f759301f5aca3fd848fc3a63b0b4663f Mon Sep 17 00:00:00 2001
From: Vivek Kumar Dutta <vivek.dutta@iopsys.eu>
Date: Mon, 16 Sep 2024 14:53:40 +0530
Subject: [PATCH] Fix datamodel path

---
 bbf_plugin/atm.c    | 9 +++++++--
 bbf_plugin/fast.c   | 5 +++--
 bbf_plugin/plugin.c | 4 ++--
 bbf_plugin/ptm.c    | 9 +++++++--
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/bbf_plugin/atm.c b/bbf_plugin/atm.c
index 56d4bf4..b3da116 100644
--- a/bbf_plugin/atm.c
+++ b/bbf_plugin/atm.c
@@ -369,7 +369,6 @@ DMLEAF tATMLinkParams[] = {
 {"Status", &DMREAD, DMT_STRING, get_atm_status, NULL, BBFDM_BOTH},
 {"LowerLayers", &DMWRITE, DMT_STRING, get_atm_lower_layer, set_atm_lower_layer, BBFDM_BOTH, DM_FLAG_REFERENCE},
 {"LinkType", &DMWRITE, DMT_STRING, get_atm_link_type, set_atm_link_type, BBFDM_BOTH},
-{"LinkNumberOfEntries", &DMREAD, DMT_UNINT, get_atm_LinkNumberOfEntries, NULL, BBFDM_BOTH},
 {"DestinationAddress", &DMWRITE, DMT_STRING, get_atm_destination_address, set_atm_destination_address, BBFDM_BOTH},
 {"Encapsulation", &DMWRITE, DMT_STRING, get_atm_encapsulation, set_atm_encapsulation, BBFDM_BOTH},
 {0}
@@ -399,7 +398,13 @@ DMOBJ tATMObj[] = {
 {0}
 };
 
+DMLEAF tATMParams[] = {
+/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
+{"LinkNumberOfEntries", &DMREAD, DMT_UNINT, get_atm_LinkNumberOfEntries, NULL, BBFDM_BOTH},
+{0}
+};
+
 DMOBJ tDeviceATMObj[] = {
-{"ATM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH, NULL},
+{"ATM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tATMObj, tATMParams, NULL, BBFDM_BOTH, NULL},
 {0}
 };
diff --git a/bbf_plugin/fast.c b/bbf_plugin/fast.c
index 7ec5514..85a2c36 100644
--- a/bbf_plugin/fast.c
+++ b/bbf_plugin/fast.c
@@ -162,7 +162,8 @@ static int get_FASTLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void
 {
 	json_object *res = NULL, *allowed_profiles = NULL;
 	char list_profile[16], *profile = NULL;
-	unsigned pos = 0, idx = 0;
+	size_t pos = 0;
+	int idx = 0;
 
 	res = ((struct dm_data *)data)->json_object;
 	DM_ASSERT(res, *value = "");
@@ -170,7 +171,7 @@ static int get_FASTLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void
 	list_profile[0] = 0;
 	dmjson_foreach_value_in_array(res, allowed_profiles, profile, idx, 1, "allowed_profiles") {
 		if (profile && (DM_LSTRCMP(profile, "106a") == 0 || DM_LSTRCMP(profile, "212a") == 0))
-			pos += snprintf(&list_profile[pos], sizeof(list_profile) - pos, "%s,", profile);
+			pos += (size_t)snprintf(&list_profile[pos], sizeof(list_profile) - pos, "%s,", profile);
 	}
 
 	/* cut tailing ',' */
diff --git a/bbf_plugin/plugin.c b/bbf_plugin/plugin.c
index 3b80002..93e2850 100644
--- a/bbf_plugin/plugin.c
+++ b/bbf_plugin/plugin.c
@@ -36,7 +36,7 @@ void remove_device_from_interface(struct uci_section *interface_s, char *device)
 {
 	char *curr_device  = NULL;
 	char new_device[64] = {0};
-	unsigned pos = 0;
+	size_t pos = 0;
 
 	if (!interface_s || !device)
 		return;
@@ -53,7 +53,7 @@ void remove_device_from_interface(struct uci_section *interface_s, char *device)
 		if (strcmp(pch, device) == 0)
 			continue;
 
-		pos += snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
+		pos += (size_t)snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
 	}
 
 	if (pos)
diff --git a/bbf_plugin/ptm.c b/bbf_plugin/ptm.c
index f71c768..118639a 100644
--- a/bbf_plugin/ptm.c
+++ b/bbf_plugin/ptm.c
@@ -268,7 +268,6 @@ DMLEAF tPTMLinkParams[] = {
 {"Alias", &DMWRITE, DMT_STRING, get_ptm_alias, set_ptm_alias, BBFDM_BOTH, DM_FLAG_UNIQUE},
 {"Name", &DMREAD, DMT_STRING, get_ptm_link_name, NULL, BBFDM_BOTH, DM_FLAG_UNIQUE|DM_FLAG_LINKER},
 {"LowerLayers", &DMWRITE, DMT_STRING, get_ptm_lower_layer, set_ptm_lower_layer, BBFDM_BOTH, DM_FLAG_REFERENCE},
-{"LinkNumberOfEntries", &DMREAD, DMT_UNINT, get_ptm_LinkNumberOfEntries, NULL, BBFDM_BOTH},
 {0}
 };
 
@@ -286,7 +285,13 @@ DMOBJ tPTMObj[] = {
 {0}
 };
 
+DMLEAF tPTMParams[] = {
+/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
+{"LinkNumberOfEntries", &DMREAD, DMT_UNINT, get_ptm_LinkNumberOfEntries, NULL, BBFDM_BOTH},
+{0}
+};
+
 DMOBJ tDevicePTMObj[] = {
-{"PTM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tPTMObj, NULL, NULL, BBFDM_BOTH, NULL},
+{"PTM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tPTMObj, tPTMParams, NULL, BBFDM_BOTH, NULL},
 {0}
 };
-- 
GitLab