| 1013 | } |
| 1014 | |
| 1015 | static bool check_node(struct children *parent_child, |
| 1016 | struct tal_hdr *t, const char *errorstr) |
| 1017 | { |
| 1018 | struct prop_hdr *prop; |
| 1019 | char *p; |
| 1020 | struct name *name = NULL; |
| 1021 | struct children *children = NULL; |
| 1022 | |
| 1023 | if (!in_bounds(t)) |
| 1024 | return check_err(t, errorstr, "invalid pointer"); |
| 1025 | |
| 1026 | if (ignore_destroying_bit(t->parent_child) != parent_child) |
| 1027 | return check_err(t, errorstr, "incorrect parent"); |
| 1028 | |
| 1029 | for (p = t->prop; p; p = prop->next) { |
| 1030 | prop = is_prop_hdr(p); |
| 1031 | if (!prop) { |
| 1032 | if (name) |
| 1033 | return check_err(t, errorstr, |
| 1034 | "has extra literal"); |
| 1035 | break; |
| 1036 | } |
| 1037 | if (!in_bounds(prop)) |
| 1038 | return check_err(t, errorstr, |
| 1039 | "has bad property pointer"); |
| 1040 | |
| 1041 | switch (prop->type) { |
| 1042 | case CHILDREN: |
| 1043 | if (children) |
| 1044 | return check_err(t, errorstr, |
| 1045 | "has two child nodes"); |
| 1046 | children = (struct children *)prop; |
| 1047 | break; |
| 1048 | case NOTIFIER: |
| 1049 | break; |
| 1050 | case NAME: |
| 1051 | if (name) |
| 1052 | return check_err(t, errorstr, |
| 1053 | "has two names"); |
| 1054 | name = (struct name *)prop; |
| 1055 | break; |
| 1056 | default: |
| 1057 | return check_err(t, errorstr, "has unknown property"); |
| 1058 | } |
| 1059 | } |
| 1060 | if (children) { |
| 1061 | struct tal_hdr *i; |
| 1062 | |
| 1063 | if (!list_check(&children->children, errorstr)) |
| 1064 | return false; |
| 1065 | list_for_each(&children->children, i, list) { |
| 1066 | if (!check_node(children, i, errorstr)) |
| 1067 | return false; |
| 1068 | } |
| 1069 | } |
| 1070 | return true; |
| 1071 | } |
| 1072 |
no test coverage detected