From 2027c10a9f0847ad0fd49ae6ca39c8346c3a5126 Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Mon, 7 May 2018 13:59:11 -0700 Subject: [PATCH] net: lwm2m: remove "path" from object and resource instances The path member of the object instance and resource instance structures can easily be removed to save several bytes per instance over the entire LwM2M subsystem. So let's remove it. Example savings when building for nrf52_blenano: SRAM usage before patch: 37952 B SRAM usage after patch: 36576 B Signed-off-by: Michael Scott --- subsys/net/lib/lwm2m/lwm2m_engine.c | 14 +++----------- subsys/net/lib/lwm2m/lwm2m_object.h | 3 --- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index 87fdcde25af..8829e96532a 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -668,7 +668,6 @@ next_engine_obj_inst(struct lwm2m_engine_obj_inst *last, int lwm2m_create_obj_inst(u16_t obj_id, u16_t obj_inst_id, struct lwm2m_engine_obj_inst **obj_inst) { - int i; struct lwm2m_engine_obj *obj; *obj_inst = NULL; @@ -702,14 +701,6 @@ int lwm2m_create_obj_inst(u16_t obj_id, u16_t obj_inst_id, obj->instance_count++; (*obj_inst)->obj = obj; (*obj_inst)->obj_inst_id = obj_inst_id; - snprintk((*obj_inst)->path, MAX_RESOURCE_LEN, "%u/%u", - obj_id, obj_inst_id); - for (i = 0; i < (*obj_inst)->resource_count; i++) { - snprintk((*obj_inst)->resources[i].path, MAX_RESOURCE_LEN, - "%u/%u/%u", obj_id, obj_inst_id, - (*obj_inst)->resources[i].res_id); - } - engine_register_obj_inst(*obj_inst); #ifdef CONFIG_LWM2M_RD_CLIENT_SUPPORT engine_trigger_update(); @@ -1121,9 +1112,10 @@ u16_t lwm2m_get_rd_data(u8_t *client_data, u16_t size) obj_inst, node) { if (obj_inst->obj->obj_id == obj->obj_id) { len = snprintk(temp, sizeof(temp), - "%s", + "%s", (pos > 0) ? "," : "", - obj_inst->path); + obj_inst->obj->obj_id, + obj_inst->obj_inst_id); /* * TODO: iterate through resources once block * transfer is handled correctly diff --git a/subsys/net/lib/lwm2m/lwm2m_object.h b/subsys/net/lib/lwm2m/lwm2m_object.h index 4b15232bf08..046b26df72c 100644 --- a/subsys/net/lib/lwm2m/lwm2m_object.h +++ b/subsys/net/lib/lwm2m/lwm2m_object.h @@ -211,8 +211,6 @@ struct lwm2m_attr { }; struct lwm2m_engine_res_inst { - char path[MAX_RESOURCE_LEN]; /* 3/0/0 */ - /* runtime field attributes (lwm2m_attr) */ sys_slist_t attr_list; @@ -232,7 +230,6 @@ struct lwm2m_engine_obj_inst { /* instance list */ sys_snode_t node; - char path[MAX_RESOURCE_LEN]; /* 3/0 */ struct lwm2m_engine_obj *obj; struct lwm2m_engine_res_inst *resources;