Skip to content

Commit

Permalink
Strip temporary NULL values from apteryx_query tree
Browse files Browse the repository at this point in the history
  • Loading branch information
blairsteven authored and carlgsmith committed Oct 25, 2023
1 parent 204d80a commit aede812
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions apteryx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,6 @@ apteryx_query_full (GNode *root)
rpc_msg_encode_uint8 (&msg, MODE_QUERY);
rpc_msg_encode_tree (&msg, root);

/* Now that the node has been encoded, strip the NULL nodes back off again */
g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_LEAVES, -1, remove_null_data, NULL);

if (!rpc_msg_send (rpc_client, &msg))
{
ERROR ("QUERY: No response Path(%s)\n", path);
Expand Down Expand Up @@ -1740,13 +1737,19 @@ apteryx_query_full (GNode *root)
GNode *
apteryx_query (GNode *root)
{
GNode *query_result;
/* the g_node tree that gets passed in here it different from an apteryx tree
* used for get / set tree operations - value leaf nodes don't get created.
* We need them for the encode tree, so add them now.
*/
ASSERT (root, return NULL, "QUERY: Invalid parameters\n");
g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_LEAVES, -1, add_null_data, NULL);
return apteryx_query_full (root);

query_result = apteryx_query_full (root);

/* Now that the node has been encoded, strip the NULL nodes back off again */
g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_LEAVES, -1, remove_null_data, NULL);
return query_result;
}

GList *
Expand Down

0 comments on commit aede812

Please sign in to comment.