Skip to content

Commit

Permalink
MI library: Add comments regarding a known issue
Browse files Browse the repository at this point in the history
Currently, MI arrays cannot contain objects with non-identical
"name" attributes.

This patch also quickfixes this issue in mi_list_all_profiles() by dropping
the array idea altogether, in favour of a top-most object.

(cherry picked from commit 6c10501)
  • Loading branch information
liviuchircu committed Apr 20, 2016
1 parent b9aa873 commit 4358451
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 14 additions & 0 deletions mi/tree.h
Expand Up @@ -47,6 +47,20 @@ struct mi_handler;
#define MI_DUP_VALUE (1<<1)
#define MI_NOT_COMPLETED (1<<2)
#define MI_WRITTEN (1<<3)
/*
* Known issue when building arrays into your modules' MI trees:
* +----------------------------------------------------+
* | only use MI_IS_ARRAY iff all "name" |
* | attributes of each array object are identical, |
* | see mi_ps() or mi_which() |
* +----------------------------------------------------+
*
* Why?
* commit 459dffba introduced a "common denominator" optimization:
* - [GOOD] reduces the amount of redundant data in all mi_json output
* - [BAD] breaks all code which builds arrays of items with
* non-identical "name" attributes
*/
#define MI_IS_ARRAY (1<<4)

#define MI_OK_S "OK"
Expand Down
1 change: 0 additions & 1 deletion modules/dialog/dlg_profile.c
Expand Up @@ -1236,7 +1236,6 @@ struct mi_root * mi_list_all_profiles(struct mi_root *cmd_tree, void *param )
return 0;

rpl = &rpl_tree->node;
rpl->flags |= MI_IS_ARRAY;

profile = profiles;
while (profile) {
Expand Down

0 comments on commit 4358451

Please sign in to comment.