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