Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file tree_data_helpers.c |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief Parsing and validation helper functions for data trees |
| 5 | * |
| 6 | * Copyright (c) 2015 - 2018 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * https://opensource.org/licenses/BSD-3-Clause |
| 13 | */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 14 | |
| 15 | #include <assert.h> |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 16 | #include <stdint.h> |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 17 | #include <stdlib.h> |
Radek Krejci | ad97c5f | 2020-06-30 09:19:28 +0200 | [diff] [blame] | 18 | #include <string.h> |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 19 | |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 20 | #include "common.h" |
| 21 | #include "context.h" |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame^] | 22 | #include "dict.h" |
Radek Krejci | ad97c5f | 2020-06-30 09:19:28 +0200 | [diff] [blame] | 23 | #include "hash_table.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 24 | #include "log.h" |
Radek Krejci | ad97c5f | 2020-06-30 09:19:28 +0200 | [diff] [blame] | 25 | #include "lyb.h" |
Radek Krejci | 7931b19 | 2020-06-25 17:05:03 +0200 | [diff] [blame] | 26 | #include "parser_data.h" |
Radek Krejci | ad97c5f | 2020-06-30 09:19:28 +0200 | [diff] [blame] | 27 | #include "set.h" |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 28 | #include "tree.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 29 | #include "tree_data.h" |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 30 | #include "tree_data_internal.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 31 | #include "tree_schema.h" |
| 32 | |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 33 | struct lyd_node * |
| 34 | lys_getnext_data(const struct lyd_node *last, const struct lyd_node *sibling, const struct lysc_node **slast, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 35 | const struct lysc_node *parent, const struct lysc_module *module) |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 36 | { |
| 37 | const struct lysc_node *siter = NULL; |
| 38 | struct lyd_node *match = NULL; |
| 39 | |
| 40 | assert(parent || module); |
| 41 | assert(!last || (slast && *slast)); |
| 42 | |
| 43 | if (slast) { |
| 44 | siter = *slast; |
| 45 | } |
| 46 | |
| 47 | if (last && last->next && (last->next->schema == siter)) { |
| 48 | /* return next data instance */ |
| 49 | return last->next; |
| 50 | } |
| 51 | |
| 52 | /* find next schema node data instance */ |
| 53 | while ((siter = lys_getnext(siter, parent, module, 0))) { |
| 54 | if (!lyd_find_sibling_val(sibling, siter, NULL, 0, &match)) { |
| 55 | break; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | if (slast) { |
| 60 | *slast = siter; |
| 61 | } |
| 62 | return match; |
| 63 | } |
| 64 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 65 | struct lyd_node ** |
| 66 | lyd_node_children_p(struct lyd_node *node) |
| 67 | { |
| 68 | assert(node); |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 69 | |
| 70 | if (!node->schema) { |
| 71 | return &((struct lyd_node_opaq *)node)->child; |
| 72 | } else { |
| 73 | switch (node->schema->nodetype) { |
| 74 | case LYS_CONTAINER: |
| 75 | case LYS_LIST: |
Michal Vasko | 1bf0939 | 2020-03-27 12:38:10 +0100 | [diff] [blame] | 76 | case LYS_RPC: |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 77 | case LYS_ACTION: |
| 78 | case LYS_NOTIF: |
| 79 | return &((struct lyd_node_inner *)node)->child; |
| 80 | default: |
| 81 | return NULL; |
| 82 | } |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | |
Radek Krejci | dae0ee8 | 2020-05-06 16:53:24 +0200 | [diff] [blame] | 86 | API struct lyd_node * |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 87 | lyd_parent(const struct lyd_node *node) |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 88 | { |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 89 | if (!node) { |
| 90 | return NULL; |
| 91 | } |
| 92 | |
| 93 | return (struct lyd_node *)(node)->parent; |
| 94 | } |
| 95 | |
| 96 | API struct lyd_node * |
| 97 | lyd_child(const struct lyd_node *node) |
| 98 | { |
| 99 | struct lyd_node **children; |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 100 | |
| 101 | if (!node) { |
| 102 | return NULL; |
| 103 | } |
| 104 | |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 105 | if (!node->schema) { |
| 106 | /* opaq node */ |
| 107 | return ((struct lyd_node_opaq *)(node))->child; |
| 108 | } |
| 109 | |
Michal Vasko | 5bfd4be | 2020-06-23 13:26:19 +0200 | [diff] [blame] | 110 | children = lyd_node_children_p((struct lyd_node *)node); |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 111 | if (children) { |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 112 | return *children; |
| 113 | } else { |
| 114 | return NULL; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | API struct lyd_node * |
| 119 | lyd_child_no_keys(const struct lyd_node *node) |
| 120 | { |
| 121 | struct lyd_node **children; |
| 122 | |
| 123 | if (!node) { |
| 124 | return NULL; |
| 125 | } |
| 126 | |
| 127 | if (!node->schema) { |
| 128 | /* opaq node */ |
| 129 | return ((struct lyd_node_opaq *)(node))->child; |
| 130 | } |
| 131 | |
| 132 | children = lyd_node_children_p((struct lyd_node *)node); |
| 133 | if (children) { |
| 134 | struct lyd_node *child = *children; |
| 135 | while (child && child->schema && (child->schema->flags & LYS_KEY)) { |
| 136 | child = child->next; |
Michal Vasko | 5bfd4be | 2020-06-23 13:26:19 +0200 | [diff] [blame] | 137 | } |
| 138 | return child; |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 139 | } else { |
| 140 | return NULL; |
| 141 | } |
| 142 | } |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 143 | |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 144 | API const struct lys_module * |
| 145 | lyd_owner_module(const struct lyd_node *node) |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 146 | { |
| 147 | const struct lysc_node *schema; |
| 148 | |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 149 | if (!node || !node->schema) { |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 150 | return NULL; |
| 151 | } |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 152 | |
Radek Krejci | 1e008d2 | 2020-08-17 11:37:37 +0200 | [diff] [blame] | 153 | for (schema = node->schema; schema->parent; schema = schema->parent) {} |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 154 | return schema->module; |
| 155 | } |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 156 | |
| 157 | const struct lys_module * |
Michal Vasko | 26e8001 | 2020-07-08 10:55:46 +0200 | [diff] [blame] | 158 | lyd_mod_next_module(struct lyd_node *tree, const struct lys_module *module, const struct ly_ctx *ctx, uint32_t *i, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 159 | struct lyd_node **first) |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 160 | { |
| 161 | struct lyd_node *iter; |
| 162 | const struct lys_module *mod; |
| 163 | |
| 164 | /* get the next module */ |
Michal Vasko | 26e8001 | 2020-07-08 10:55:46 +0200 | [diff] [blame] | 165 | if (module) { |
| 166 | if (*i) { |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 167 | mod = NULL; |
Michal Vasko | 26e8001 | 2020-07-08 10:55:46 +0200 | [diff] [blame] | 168 | } else { |
| 169 | mod = module; |
| 170 | ++(*i); |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 171 | } |
| 172 | } else { |
| 173 | do { |
| 174 | mod = ly_ctx_get_module_iter(ctx, i); |
| 175 | } while (mod && !mod->implemented); |
| 176 | } |
| 177 | |
| 178 | /* find its data */ |
| 179 | *first = NULL; |
| 180 | if (mod) { |
| 181 | LY_LIST_FOR(tree, iter) { |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 182 | if (lyd_owner_module(iter) == mod) { |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 183 | *first = iter; |
| 184 | break; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | return mod; |
| 190 | } |
| 191 | |
| 192 | const struct lys_module * |
| 193 | lyd_data_next_module(struct lyd_node **next, struct lyd_node **first) |
| 194 | { |
| 195 | const struct lys_module *mod; |
| 196 | |
| 197 | if (!*next) { |
| 198 | /* all data traversed */ |
| 199 | *first = NULL; |
| 200 | return NULL; |
| 201 | } |
| 202 | |
| 203 | *first = *next; |
| 204 | |
| 205 | /* prepare next */ |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 206 | mod = lyd_owner_module(*next); |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 207 | LY_LIST_FOR(*next, *next) { |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 208 | if (lyd_owner_module(*next) != mod) { |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 209 | break; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | return mod; |
| 214 | } |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 215 | |
| 216 | LY_ERR |
| 217 | lyd_parse_check_keys(struct lyd_node *node) |
| 218 | { |
| 219 | const struct lysc_node *skey = NULL; |
| 220 | const struct lyd_node *key; |
| 221 | |
| 222 | assert(node->schema->nodetype == LYS_LIST); |
| 223 | |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 224 | key = lyd_child(node); |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 225 | while ((skey = lys_getnext(skey, node->schema, NULL, 0)) && (skey->flags & LYS_KEY)) { |
| 226 | if (!key || (key->schema != skey)) { |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 227 | LOGVAL(LYD_CTX(node), LY_VLOG_LYD, node, LY_VCODE_NOKEY, skey->name); |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 228 | return LY_EVALID; |
| 229 | } |
| 230 | |
| 231 | key = key->next; |
| 232 | } |
| 233 | |
| 234 | return LY_SUCCESS; |
| 235 | } |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 236 | |
| 237 | void |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 238 | lyd_parse_set_data_flags(struct lyd_node *node, struct ly_set *when_check, struct lyd_meta **meta, uint32_t options) |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 239 | { |
| 240 | struct lyd_meta *meta2, *prev_meta = NULL; |
| 241 | |
| 242 | if (!(node->schema->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && node->schema->when) { |
Radek Krejci | 7931b19 | 2020-06-25 17:05:03 +0200 | [diff] [blame] | 243 | if (options & LYD_PARSE_TRUSTED) { |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 244 | /* just set it to true */ |
| 245 | node->flags |= LYD_WHEN_TRUE; |
| 246 | } else { |
| 247 | /* remember we need to evaluate this node's when */ |
Radek Krejci | 3d92e44 | 2020-10-12 12:48:13 +0200 | [diff] [blame] | 248 | LY_CHECK_RET(ly_set_add(when_check, node, 1, NULL), ); |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 249 | } |
| 250 | } |
| 251 | |
Radek Krejci | 7931b19 | 2020-06-25 17:05:03 +0200 | [diff] [blame] | 252 | if (options & LYD_PARSE_TRUSTED) { |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 253 | /* node is valid */ |
| 254 | node->flags &= ~LYD_NEW; |
| 255 | } |
| 256 | |
| 257 | LY_LIST_FOR(*meta, meta2) { |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 258 | if (!strcmp(meta2->name, "default") && !strcmp(meta2->annotation->module->name, "ietf-netconf-with-defaults") && |
| 259 | meta2->value.boolean) { |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 260 | /* node is default according to the metadata */ |
| 261 | node->flags |= LYD_DEFAULT; |
| 262 | |
| 263 | /* delete the metadata */ |
| 264 | if (prev_meta) { |
| 265 | prev_meta->next = meta2->next; |
| 266 | } else { |
| 267 | *meta = (*meta)->next; |
| 268 | } |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 269 | lyd_free_meta_single(meta2); |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 270 | break; |
| 271 | } |
| 272 | |
| 273 | prev_meta = meta2; |
| 274 | } |
| 275 | } |
| 276 | |
Michal Vasko | c000427 | 2020-08-06 08:32:34 +0200 | [diff] [blame] | 277 | API LY_ERR |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 278 | lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value, LYD_ANYDATA_VALUETYPE value_type) |
| 279 | { |
| 280 | struct lyd_node_any *t; |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 281 | |
| 282 | assert(trg->schema->nodetype & LYS_ANYDATA); |
| 283 | |
| 284 | t = (struct lyd_node_any *)trg; |
| 285 | |
| 286 | /* free trg */ |
| 287 | switch (t->value_type) { |
| 288 | case LYD_ANYDATA_DATATREE: |
| 289 | lyd_free_all(t->value.tree); |
| 290 | break; |
| 291 | case LYD_ANYDATA_STRING: |
| 292 | case LYD_ANYDATA_XML: |
| 293 | case LYD_ANYDATA_JSON: |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 294 | FREE_STRING(LYD_CTX(trg), t->value.str); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 295 | break; |
| 296 | case LYD_ANYDATA_LYB: |
| 297 | free(t->value.mem); |
| 298 | break; |
| 299 | } |
| 300 | t->value.str = NULL; |
| 301 | |
| 302 | if (!value) { |
| 303 | /* only free value in this case */ |
| 304 | return LY_SUCCESS; |
| 305 | } |
| 306 | |
| 307 | /* copy src */ |
| 308 | t->value_type = value_type; |
| 309 | switch (value_type) { |
| 310 | case LYD_ANYDATA_DATATREE: |
| 311 | if (value->tree) { |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 312 | LY_CHECK_RET(lyd_dup_siblings(value->tree, NULL, LYD_DUP_RECURSIVE, &t->value.tree)); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 313 | } |
| 314 | break; |
| 315 | case LYD_ANYDATA_STRING: |
| 316 | case LYD_ANYDATA_XML: |
| 317 | case LYD_ANYDATA_JSON: |
| 318 | if (value->str) { |
Radek Krejci | 011e4aa | 2020-09-04 15:22:31 +0200 | [diff] [blame] | 319 | LY_CHECK_RET(lydict_insert(LYD_CTX(trg), value->str, 0, &t->value.str)); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 320 | } |
| 321 | break; |
| 322 | case LYD_ANYDATA_LYB: |
| 323 | if (value->mem) { |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 324 | int len = lyd_lyb_data_length(value->mem); |
Radek Krejci | 82fa8d4 | 2020-07-11 22:00:59 +0200 | [diff] [blame] | 325 | LY_CHECK_RET(len == -1, LY_EINVAL); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 326 | t->value.mem = malloc(len); |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 327 | LY_CHECK_ERR_RET(!t->value.mem, LOGMEM(LYD_CTX(trg)), LY_EMEM); |
Michal Vasko | 61551fa | 2020-07-09 15:45:45 +0200 | [diff] [blame] | 328 | memcpy(t->value.mem, value->mem, len); |
| 329 | } |
| 330 | break; |
| 331 | } |
| 332 | |
| 333 | return LY_SUCCESS; |
| 334 | } |
| 335 | |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 336 | LYB_HASH |
| 337 | lyb_hash(struct lysc_node *sibling, uint8_t collision_id) |
| 338 | { |
| 339 | const struct lys_module *mod; |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 340 | uint32_t full_hash; |
| 341 | LYB_HASH hash; |
| 342 | |
| 343 | if ((collision_id < LYS_NODE_HASH_COUNT) && sibling->hash[collision_id]) { |
| 344 | return sibling->hash[collision_id]; |
| 345 | } |
| 346 | |
| 347 | mod = sibling->module; |
| 348 | |
| 349 | full_hash = dict_hash_multi(0, mod->name, strlen(mod->name)); |
| 350 | full_hash = dict_hash_multi(full_hash, sibling->name, strlen(sibling->name)); |
| 351 | if (collision_id) { |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 352 | size_t ext_len; |
| 353 | |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 354 | if (collision_id > strlen(mod->name)) { |
| 355 | /* fine, we will not hash more bytes, just use more bits from the hash than previously */ |
| 356 | ext_len = strlen(mod->name); |
| 357 | } else { |
| 358 | /* use one more byte from the module name than before */ |
| 359 | ext_len = collision_id; |
| 360 | } |
| 361 | full_hash = dict_hash_multi(full_hash, mod->name, ext_len); |
| 362 | } |
| 363 | full_hash = dict_hash_multi(full_hash, NULL, 0); |
| 364 | |
| 365 | /* use the shortened hash */ |
| 366 | hash = full_hash & (LYB_HASH_MASK >> collision_id); |
| 367 | /* add colision identificator */ |
| 368 | hash |= LYB_HASH_COLLISION_ID >> collision_id; |
| 369 | |
| 370 | /* save this hash */ |
| 371 | if (collision_id < LYS_NODE_HASH_COUNT) { |
| 372 | sibling->hash[collision_id] = hash; |
| 373 | } |
| 374 | |
| 375 | return hash; |
| 376 | } |
| 377 | |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 378 | ly_bool |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 379 | lyb_has_schema_model(const struct lysc_node *sibling, const struct lys_module **models) |
| 380 | { |
Michal Vasko | fd69e1d | 2020-07-03 11:57:17 +0200 | [diff] [blame] | 381 | LY_ARRAY_COUNT_TYPE u; |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 382 | |
| 383 | LY_ARRAY_FOR(models, u) { |
| 384 | if (sibling->module == models[u]) { |
| 385 | return 1; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | return 0; |
| 390 | } |