summaryrefslogtreecommitdiff
path: root/lib/northbound_cli.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-10-14 22:20:24 -0300
committerRenato Westphal <renato@opensourcerouting.org>2019-10-14 22:34:33 -0300
commitb83d7134264089ed0c6b52b4df3dde840c15056b (patch)
treec813eefebed7759435ed67da2d6be91b6725d42f /lib/northbound_cli.c
parent890b7a3c7760b0465ade73eb493a9079d933c38d (diff)
lib: fix harmless lyd_schema_sort() warning
The dnode member of the nb_config structure can be null on daemons that don't implement any YANG module. As such, update the nb_cli_show_config_prepare() function to always check if the libyang data node that is going to be displayed is null or not before operating on it. This fixes the following warning (introduced by commit 5e6a9350c1): libyang: Invalid arguments (lyd_schema_sort()) Reported-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/northbound_cli.c')
-rw-r--r--lib/northbound_cli.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index 07e8c9dff9..61919f0229 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -424,6 +424,10 @@ static struct lyd_node *ly_iter_next_up(const struct lyd_node *elem)
/* Prepare the configuration for display. */
void nb_cli_show_config_prepare(struct nb_config *config, bool with_defaults)
{
+ /* Nothing to do for daemons that don't implement any YANG module. */
+ if (config->dnode == NULL)
+ return;
+
lyd_schema_sort(config->dnode, 1);
/*