mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 15:43:02 +02:00
confd: lyx: Allow diffs of NULL nodes
This makes the pattern
if (lydx_get_diff(lydx_get_child(diffnode, "attribute"), &nd)) {
/* Handle changes to "attribute" */
}
safe to use in the common case where "attribute" has not been
modified, and is therefore not present in `diffnode`.
This commit is contained in:
@@ -41,6 +41,9 @@ bool lydx_get_diff(struct lyd_node *node, struct lydx_diff *nd)
|
||||
|
||||
memset(nd, 0, sizeof(*nd));
|
||||
|
||||
if (!node)
|
||||
goto out;
|
||||
|
||||
nd->op = lydx_get_op(node);
|
||||
nd->val = lyd_get_value(node);
|
||||
|
||||
@@ -69,6 +72,7 @@ bool lydx_get_diff(struct lyd_node *node, struct lydx_diff *nd)
|
||||
(nd->old && !nd->was_default) ||
|
||||
(nd->new && !nd->is_default);
|
||||
|
||||
out:
|
||||
return nd->modified;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user