Skip to content

Commit fcea27b

Browse files
authored
Merge pull request #70 from ADTRAN/notification-after-leaf
Fix parsing for notification after leaf
2 parents 8f1d355 + bbab76f commit fcea27b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/messages_server.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <stdlib.h>
1717
#include <string.h>
1818
#include <stdarg.h>
19+
#include <stdbool.h>
1920

2021
#include <libyang/libyang.h>
2122

@@ -828,6 +829,7 @@ nc_server_notif_new(struct lyd_node* event, char *eventtime, NC_PARAMTYPE paramt
828829
{
829830
struct nc_server_notif *ntf;
830831
struct lyd_node *elem;
832+
bool found_notif = false;
831833

832834
if (!event) {
833835
ERRARG("event");
@@ -838,7 +840,7 @@ nc_server_notif_new(struct lyd_node* event, char *eventtime, NC_PARAMTYPE paramt
838840
}
839841

840842
/* check that there is a notification */
841-
for (elem = event; elem && (elem->schema->nodetype != LYS_NOTIF); elem = elem->child) {
843+
for (elem = event; elem && !found_notif; elem = elem->child) {
842844
next_node:
843845
switch (elem->schema->nodetype) {
844846
case LYS_LEAF:
@@ -852,16 +854,18 @@ nc_server_notif_new(struct lyd_node* event, char *eventtime, NC_PARAMTYPE paramt
852854
goto next_node;
853855
case LYS_CONTAINER:
854856
case LYS_LIST:
855-
case LYS_NOTIF:
856857
/* ok */
857858
break;
859+
case LYS_NOTIF:
860+
found_notif = true;
861+
break;
858862
default:
859863
/* error */
860864
ERRARG("event");
861865
return NULL;
862866
}
863867
}
864-
if (!elem) {
868+
if (!found_notif) {
865869
ERRARG("event");
866870
return NULL;
867871
}

0 commit comments

Comments
 (0)