| 219 | } |
| 220 | |
| 221 | static void sym_check_prop(struct symbol *sym) |
| 222 | { |
| 223 | struct property *prop; |
| 224 | struct symbol *sym2; |
| 225 | char *use; |
| 226 | |
| 227 | for (prop = sym->prop; prop; prop = prop->next) { |
| 228 | switch (prop->type) { |
| 229 | case P_DEFAULT: |
| 230 | if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) && |
| 231 | prop->expr->type != E_SYMBOL) |
| 232 | prop_warn(prop, |
| 233 | "default for config symbol '%s'" |
| 234 | " must be a single symbol", sym->name); |
| 235 | if (prop->expr->type != E_SYMBOL) |
| 236 | break; |
| 237 | sym2 = prop_get_symbol(prop); |
| 238 | if (sym->type == S_HEX || sym->type == S_INT) { |
| 239 | if (!menu_validate_number(sym, sym2)) |
| 240 | prop_warn(prop, |
| 241 | "'%s': number is invalid", |
| 242 | sym->name); |
| 243 | } |
| 244 | if (sym_is_choice(sym)) { |
| 245 | struct property *choice_prop = |
| 246 | sym_get_choice_prop(sym2); |
| 247 | |
| 248 | if (!choice_prop || |
| 249 | prop_get_symbol(choice_prop) != sym) |
| 250 | prop_warn(prop, |
| 251 | "choice default symbol '%s' is not contained in the choice", |
| 252 | sym2->name); |
| 253 | } |
| 254 | break; |
| 255 | case P_SELECT: |
| 256 | case P_IMPLY: |
| 257 | use = prop->type == P_SELECT ? "select" : "imply"; |
| 258 | sym2 = prop_get_symbol(prop); |
| 259 | if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) |
| 260 | prop_warn(prop, |
| 261 | "config symbol '%s' uses %s, but is " |
| 262 | "not bool or tristate", sym->name, use); |
| 263 | else if (sym2->type != S_UNKNOWN && |
| 264 | sym2->type != S_BOOLEAN && |
| 265 | sym2->type != S_TRISTATE) |
| 266 | prop_warn(prop, |
| 267 | "'%s' has wrong type. '%s' only " |
| 268 | "accept arguments of bool and " |
| 269 | "tristate type", sym2->name, use); |
| 270 | break; |
| 271 | case P_RANGE: |
| 272 | if (sym->type != S_INT && sym->type != S_HEX) |
| 273 | prop_warn(prop, "range is only allowed " |
| 274 | "for int or hex symbols"); |
| 275 | if (!menu_validate_number(sym, prop->expr->left.sym) || |
| 276 | !menu_validate_number(sym, prop->expr->right.sym)) |
| 277 | prop_warn(prop, "range is invalid"); |
| 278 | break; |
no test coverage detected