net: lwm2m: Remove lwm2m_path_to_string

This function had only one use in SenML CBOR formatter and it
contained some specific tweaks, so move the function to be a
static member of that module.

Fixes #53674

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit is contained in:
Seppo Takalo 2023-04-06 13:31:44 +03:00 committed by Carles Cufí
commit 3a241592b5
4 changed files with 57 additions and 88 deletions

View file

@ -54,9 +54,6 @@ static void assert_path_list_order(sys_slist_t *lwm2m_path_list)
uint16_t res_id_max;
uint16_t res_inst_id_max;
char next_path_str[LWM2M_MAX_PATH_STR_SIZE];
char prev_path_str[LWM2M_MAX_PATH_STR_SIZE];
if (sys_slist_is_empty(lwm2m_path_list)) {
return;
}
@ -65,11 +62,6 @@ static void assert_path_list_order(sys_slist_t *lwm2m_path_list)
if (prev) {
if (entry->path.level > prev->path.level) {
lwm2m_path_to_string(next_path_str, sizeof(next_path_str),
&entry->path, entry->path.level);
lwm2m_path_to_string(prev_path_str, sizeof(prev_path_str),
&prev->path, prev->path.level);
bool is_after = false;
if (prev->path.level >= LWM2M_PATH_LEVEL_OBJECT) {
@ -93,8 +85,8 @@ static void assert_path_list_order(sys_slist_t *lwm2m_path_list)
entry->path.res_inst_id >= prev->path.res_inst_id;
}
zassert_true(is_after, "Next element %s must be before previous %s",
next_path_str, prev_path_str);
zassert_true(is_after, "Next element %p must be before previous %p",
entry, prev);
} else if (entry->path.level == prev->path.level) {
if (entry->path.level >= LWM2M_PATH_LEVEL_OBJECT) {
@ -221,21 +213,6 @@ static void assert_path_list_order(sys_slist_t *lwm2m_path_list)
prev = entry;
}
}
static void print_path_list(sys_slist_t *lwm2m_path_list, const char *name)
{
struct lwm2m_obj_path_list *entry, *tmp;
if (name != NULL) {
TEST_VERBOSE_PRINT("Path List %s:\n", name);
}
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(lwm2m_path_list, entry, tmp, node) {
char buf[LWM2M_MAX_PATH_STR_SIZE];
lwm2m_path_to_string(buf, LWM2M_MAX_PATH_STR_SIZE, &entry->path, entry->path.level);
TEST_VERBOSE_PRINT("- %s\n", buf);
}
}
static void run_insertion_test(char const *insert_path_str[], int insertions_count,
char const *expected_path_str[])
@ -261,14 +238,11 @@ static void run_insertion_test(char const *insert_path_str[], int insertions_cou
&insert_path);
sprintf(name, "Insertion: %d", i);
print_path_list(&lwm2m_path_list, name);
zassert_true(ret >= 0, "Insertion #%d failed", i);
/* THEN: path order is maintained */
assert_path_list_order(&lwm2m_path_list);
}
print_path_list(&lwm2m_path_list, "Final");
/* AND: final list matches expectation */
struct lwm2m_obj_path_list *entry, *tmp;
int path_num = 0;