checks.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*
  2. * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2007.
  3. *
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  18. * USA
  19. */
  20. #include "dtc.h"
  21. #ifdef TRACE_CHECKS
  22. #define TRACE(c, ...) \
  23. do { \
  24. fprintf(stderr, "=== %s: ", (c)->name); \
  25. fprintf(stderr, __VA_ARGS__); \
  26. fprintf(stderr, "\n"); \
  27. } while (0)
  28. #else
  29. #define TRACE(c, fmt, ...) do { } while (0)
  30. #endif
  31. enum checklevel {
  32. IGNORE = 0,
  33. WARN = 1,
  34. ERROR = 2,
  35. };
  36. enum checkstatus {
  37. UNCHECKED = 0,
  38. PREREQ,
  39. PASSED,
  40. FAILED,
  41. };
  42. struct check;
  43. typedef void (*tree_check_fn)(struct check *c, struct node *dt);
  44. typedef void (*node_check_fn)(struct check *c, struct node *dt, struct node *node);
  45. typedef void (*prop_check_fn)(struct check *c, struct node *dt,
  46. struct node *node, struct property *prop);
  47. struct check {
  48. const char *name;
  49. tree_check_fn tree_fn;
  50. node_check_fn node_fn;
  51. prop_check_fn prop_fn;
  52. void *data;
  53. enum checklevel level;
  54. enum checkstatus status;
  55. int inprogress;
  56. int num_prereqs;
  57. struct check **prereq;
  58. };
  59. #define CHECK(nm, tfn, nfn, pfn, d, lvl, ...) \
  60. static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \
  61. static struct check nm = { \
  62. .name = #nm, \
  63. .tree_fn = (tfn), \
  64. .node_fn = (nfn), \
  65. .prop_fn = (pfn), \
  66. .data = (d), \
  67. .level = (lvl), \
  68. .status = UNCHECKED, \
  69. .num_prereqs = ARRAY_SIZE(nm##_prereqs), \
  70. .prereq = nm##_prereqs, \
  71. };
  72. #define TREE_CHECK(nm, d, lvl, ...) \
  73. CHECK(nm, check_##nm, NULL, NULL, d, lvl, __VA_ARGS__)
  74. #define NODE_CHECK(nm, d, lvl, ...) \
  75. CHECK(nm, NULL, check_##nm, NULL, d, lvl, __VA_ARGS__)
  76. #define PROP_CHECK(nm, d, lvl, ...) \
  77. CHECK(nm, NULL, NULL, check_##nm, d, lvl, __VA_ARGS__)
  78. #define BATCH_CHECK(nm, lvl, ...) \
  79. CHECK(nm, NULL, NULL, NULL, NULL, lvl, __VA_ARGS__)
  80. #ifdef __GNUC__
  81. static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
  82. #endif
  83. static inline void check_msg(struct check *c, const char *fmt, ...)
  84. {
  85. va_list ap;
  86. va_start(ap, fmt);
  87. if ((c->level < WARN) || (c->level <= quiet))
  88. return; /* Suppress message */
  89. fprintf(stderr, "%s (%s): ",
  90. (c->level == ERROR) ? "ERROR" : "Warning", c->name);
  91. vfprintf(stderr, fmt, ap);
  92. fprintf(stderr, "\n");
  93. }
  94. #define FAIL(c, ...) \
  95. do { \
  96. TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
  97. (c)->status = FAILED; \
  98. check_msg((c), __VA_ARGS__); \
  99. } while (0)
  100. static void check_nodes_props(struct check *c, struct node *dt, struct node *node)
  101. {
  102. struct node *child;
  103. struct property *prop;
  104. TRACE(c, "%s", node->fullpath);
  105. if (c->node_fn)
  106. c->node_fn(c, dt, node);
  107. if (c->prop_fn)
  108. for_each_property(node, prop) {
  109. TRACE(c, "%s\t'%s'", node->fullpath, prop->name);
  110. c->prop_fn(c, dt, node, prop);
  111. }
  112. for_each_child(node, child)
  113. check_nodes_props(c, dt, child);
  114. }
  115. static int run_check(struct check *c, struct node *dt)
  116. {
  117. int error = 0;
  118. int i;
  119. assert(!c->inprogress);
  120. if (c->status != UNCHECKED)
  121. goto out;
  122. c->inprogress = 1;
  123. for (i = 0; i < c->num_prereqs; i++) {
  124. struct check *prq = c->prereq[i];
  125. error |= run_check(prq, dt);
  126. if (prq->status != PASSED) {
  127. c->status = PREREQ;
  128. check_msg(c, "Failed prerequisite '%s'",
  129. c->prereq[i]->name);
  130. }
  131. }
  132. if (c->status != UNCHECKED)
  133. goto out;
  134. if (c->node_fn || c->prop_fn)
  135. check_nodes_props(c, dt, dt);
  136. if (c->tree_fn)
  137. c->tree_fn(c, dt);
  138. if (c->status == UNCHECKED)
  139. c->status = PASSED;
  140. TRACE(c, "\tCompleted, status %d", c->status);
  141. out:
  142. c->inprogress = 0;
  143. if ((c->status != PASSED) && (c->level == ERROR))
  144. error = 1;
  145. return error;
  146. }
  147. /*
  148. * Utility check functions
  149. */
  150. static void check_is_string(struct check *c, struct node *root,
  151. struct node *node)
  152. {
  153. struct property *prop;
  154. char *propname = c->data;
  155. prop = get_property(node, propname);
  156. if (!prop)
  157. return; /* Not present, assumed ok */
  158. if (!data_is_one_string(prop->val))
  159. FAIL(c, "\"%s\" property in %s is not a string",
  160. propname, node->fullpath);
  161. }
  162. #define CHECK_IS_STRING(nm, propname, lvl) \
  163. CHECK(nm, NULL, check_is_string, NULL, (propname), (lvl))
  164. static void check_is_cell(struct check *c, struct node *root,
  165. struct node *node)
  166. {
  167. struct property *prop;
  168. char *propname = c->data;
  169. prop = get_property(node, propname);
  170. if (!prop)
  171. return; /* Not present, assumed ok */
  172. if (prop->val.len != sizeof(cell_t))
  173. FAIL(c, "\"%s\" property in %s is not a single cell",
  174. propname, node->fullpath);
  175. }
  176. #define CHECK_IS_CELL(nm, propname, lvl) \
  177. CHECK(nm, NULL, check_is_cell, NULL, (propname), (lvl))
  178. /*
  179. * Structural check functions
  180. */
  181. static void check_duplicate_node_names(struct check *c, struct node *dt,
  182. struct node *node)
  183. {
  184. struct node *child, *child2;
  185. for_each_child(node, child)
  186. for (child2 = child->next_sibling;
  187. child2;
  188. child2 = child2->next_sibling)
  189. if (streq(child->name, child2->name))
  190. FAIL(c, "Duplicate node name %s",
  191. child->fullpath);
  192. }
  193. NODE_CHECK(duplicate_node_names, NULL, ERROR);
  194. static void check_duplicate_property_names(struct check *c, struct node *dt,
  195. struct node *node)
  196. {
  197. struct property *prop, *prop2;
  198. for_each_property(node, prop)
  199. for (prop2 = prop->next; prop2; prop2 = prop2->next)
  200. if (streq(prop->name, prop2->name))
  201. FAIL(c, "Duplicate property name %s in %s",
  202. prop->name, node->fullpath);
  203. }
  204. NODE_CHECK(duplicate_property_names, NULL, ERROR);
  205. #define LOWERCASE "abcdefghijklmnopqrstuvwxyz"
  206. #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  207. #define DIGITS "0123456789"
  208. #define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-"
  209. static void check_node_name_chars(struct check *c, struct node *dt,
  210. struct node *node)
  211. {
  212. int n = strspn(node->name, c->data);
  213. if (n < strlen(node->name))
  214. FAIL(c, "Bad character '%c' in node %s",
  215. node->name[n], node->fullpath);
  216. }
  217. NODE_CHECK(node_name_chars, PROPNODECHARS "@", ERROR);
  218. static void check_node_name_format(struct check *c, struct node *dt,
  219. struct node *node)
  220. {
  221. if (strchr(get_unitname(node), '@'))
  222. FAIL(c, "Node %s has multiple '@' characters in name",
  223. node->fullpath);
  224. }
  225. NODE_CHECK(node_name_format, NULL, ERROR, &node_name_chars);
  226. static void check_property_name_chars(struct check *c, struct node *dt,
  227. struct node *node, struct property *prop)
  228. {
  229. int n = strspn(prop->name, c->data);
  230. if (n < strlen(prop->name))
  231. FAIL(c, "Bad character '%c' in property name \"%s\", node %s",
  232. prop->name[n], prop->name, node->fullpath);
  233. }
  234. PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR);
  235. #define DESCLABEL_FMT "%s%s%s%s%s"
  236. #define DESCLABEL_ARGS(node,prop,mark) \
  237. ((mark) ? "value of " : ""), \
  238. ((prop) ? "'" : ""), \
  239. ((prop) ? (prop)->name : ""), \
  240. ((prop) ? "' in " : ""), (node)->fullpath
  241. static void check_duplicate_label(struct check *c, struct node *dt,
  242. const char *label, struct node *node,
  243. struct property *prop, struct marker *mark)
  244. {
  245. struct node *othernode = NULL;
  246. struct property *otherprop = NULL;
  247. struct marker *othermark = NULL;
  248. othernode = get_node_by_label(dt, label);
  249. if (!othernode)
  250. otherprop = get_property_by_label(dt, label, &othernode);
  251. if (!othernode)
  252. othermark = get_marker_label(dt, label, &othernode,
  253. &otherprop);
  254. if (!othernode)
  255. return;
  256. if ((othernode != node) || (otherprop != prop) || (othermark != mark))
  257. FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT
  258. " and " DESCLABEL_FMT,
  259. label, DESCLABEL_ARGS(node, prop, mark),
  260. DESCLABEL_ARGS(othernode, otherprop, othermark));
  261. }
  262. static void check_duplicate_label_node(struct check *c, struct node *dt,
  263. struct node *node)
  264. {
  265. struct label *l;
  266. for_each_label(node->labels, l)
  267. check_duplicate_label(c, dt, l->label, node, NULL, NULL);
  268. }
  269. static void check_duplicate_label_prop(struct check *c, struct node *dt,
  270. struct node *node, struct property *prop)
  271. {
  272. struct marker *m = prop->val.markers;
  273. struct label *l;
  274. for_each_label(prop->labels, l)
  275. check_duplicate_label(c, dt, l->label, node, prop, NULL);
  276. for_each_marker_of_type(m, LABEL)
  277. check_duplicate_label(c, dt, m->ref, node, prop, m);
  278. }
  279. CHECK(duplicate_label, NULL, check_duplicate_label_node,
  280. check_duplicate_label_prop, NULL, ERROR);
  281. static void check_explicit_phandles(struct check *c, struct node *root,
  282. struct node *node, struct property *prop)
  283. {
  284. struct marker *m;
  285. struct node *other;
  286. cell_t phandle;
  287. if (!streq(prop->name, "phandle")
  288. && !streq(prop->name, "linux,phandle"))
  289. return;
  290. if (prop->val.len != sizeof(cell_t)) {
  291. FAIL(c, "%s has bad length (%d) %s property",
  292. node->fullpath, prop->val.len, prop->name);
  293. return;
  294. }
  295. m = prop->val.markers;
  296. for_each_marker_of_type(m, REF_PHANDLE) {
  297. assert(m->offset == 0);
  298. if (node != get_node_by_ref(root, m->ref))
  299. /* "Set this node's phandle equal to some
  300. * other node's phandle". That's nonsensical
  301. * by construction. */ {
  302. FAIL(c, "%s in %s is a reference to another node",
  303. prop->name, node->fullpath);
  304. return;
  305. }
  306. /* But setting this node's phandle equal to its own
  307. * phandle is allowed - that means allocate a unique
  308. * phandle for this node, even if it's not otherwise
  309. * referenced. The value will be filled in later, so
  310. * no further checking for now. */
  311. return;
  312. }
  313. phandle = propval_cell(prop);
  314. if ((phandle == 0) || (phandle == -1)) {
  315. FAIL(c, "%s has bad value (0x%x) in %s property",
  316. node->fullpath, phandle, prop->name);
  317. return;
  318. }
  319. if (node->phandle && (node->phandle != phandle))
  320. FAIL(c, "%s has %s property which replaces existing phandle information",
  321. node->fullpath, prop->name);
  322. other = get_node_by_phandle(root, phandle);
  323. if (other && (other != node)) {
  324. FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
  325. node->fullpath, phandle, other->fullpath);
  326. return;
  327. }
  328. node->phandle = phandle;
  329. }
  330. PROP_CHECK(explicit_phandles, NULL, ERROR);
  331. static void check_name_properties(struct check *c, struct node *root,
  332. struct node *node)
  333. {
  334. struct property **pp, *prop = NULL;
  335. for (pp = &node->proplist; *pp; pp = &((*pp)->next))
  336. if (streq((*pp)->name, "name")) {
  337. prop = *pp;
  338. break;
  339. }
  340. if (!prop)
  341. return; /* No name property, that's fine */
  342. if ((prop->val.len != node->basenamelen+1)
  343. || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
  344. FAIL(c, "\"name\" property in %s is incorrect (\"%s\" instead"
  345. " of base node name)", node->fullpath, prop->val.val);
  346. } else {
  347. /* The name property is correct, and therefore redundant.
  348. * Delete it */
  349. *pp = prop->next;
  350. free(prop->name);
  351. data_free(prop->val);
  352. free(prop);
  353. }
  354. }
  355. CHECK_IS_STRING(name_is_string, "name", ERROR);
  356. NODE_CHECK(name_properties, NULL, ERROR, &name_is_string);
  357. /*
  358. * Reference fixup functions
  359. */
  360. static void fixup_phandle_references(struct check *c, struct node *dt,
  361. struct node *node, struct property *prop)
  362. {
  363. struct marker *m = prop->val.markers;
  364. struct node *refnode;
  365. cell_t phandle;
  366. for_each_marker_of_type(m, REF_PHANDLE) {
  367. assert(m->offset + sizeof(cell_t) <= prop->val.len);
  368. refnode = get_node_by_ref(dt, m->ref);
  369. if (! refnode) {
  370. FAIL(c, "Reference to non-existent node or label \"%s\"\n",
  371. m->ref);
  372. continue;
  373. }
  374. phandle = get_node_phandle(dt, refnode);
  375. *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
  376. }
  377. }
  378. CHECK(phandle_references, NULL, NULL, fixup_phandle_references, NULL, ERROR,
  379. &duplicate_node_names, &explicit_phandles);
  380. static void fixup_path_references(struct check *c, struct node *dt,
  381. struct node *node, struct property *prop)
  382. {
  383. struct marker *m = prop->val.markers;
  384. struct node *refnode;
  385. char *path;
  386. for_each_marker_of_type(m, REF_PATH) {
  387. assert(m->offset <= prop->val.len);
  388. refnode = get_node_by_ref(dt, m->ref);
  389. if (!refnode) {
  390. FAIL(c, "Reference to non-existent node or label \"%s\"\n",
  391. m->ref);
  392. continue;
  393. }
  394. path = refnode->fullpath;
  395. prop->val = data_insert_at_marker(prop->val, m, path,
  396. strlen(path) + 1);
  397. }
  398. }
  399. CHECK(path_references, NULL, NULL, fixup_path_references, NULL, ERROR,
  400. &duplicate_node_names);
  401. /*
  402. * Semantic checks
  403. */
  404. CHECK_IS_CELL(address_cells_is_cell, "#address-cells", WARN);
  405. CHECK_IS_CELL(size_cells_is_cell, "#size-cells", WARN);
  406. CHECK_IS_CELL(interrupt_cells_is_cell, "#interrupt-cells", WARN);
  407. CHECK_IS_STRING(device_type_is_string, "device_type", WARN);
  408. CHECK_IS_STRING(model_is_string, "model", WARN);
  409. CHECK_IS_STRING(status_is_string, "status", WARN);
  410. static void fixup_addr_size_cells(struct check *c, struct node *dt,
  411. struct node *node)
  412. {
  413. struct property *prop;
  414. node->addr_cells = -1;
  415. node->size_cells = -1;
  416. prop = get_property(node, "#address-cells");
  417. if (prop)
  418. node->addr_cells = propval_cell(prop);
  419. prop = get_property(node, "#size-cells");
  420. if (prop)
  421. node->size_cells = propval_cell(prop);
  422. }
  423. CHECK(addr_size_cells, NULL, fixup_addr_size_cells, NULL, NULL, WARN,
  424. &address_cells_is_cell, &size_cells_is_cell);
  425. #define node_addr_cells(n) \
  426. (((n)->addr_cells == -1) ? 2 : (n)->addr_cells)
  427. #define node_size_cells(n) \
  428. (((n)->size_cells == -1) ? 1 : (n)->size_cells)
  429. static void check_reg_format(struct check *c, struct node *dt,
  430. struct node *node)
  431. {
  432. struct property *prop;
  433. int addr_cells, size_cells, entrylen;
  434. prop = get_property(node, "reg");
  435. if (!prop)
  436. return; /* No "reg", that's fine */
  437. if (!node->parent) {
  438. FAIL(c, "Root node has a \"reg\" property");
  439. return;
  440. }
  441. if (prop->val.len == 0)
  442. FAIL(c, "\"reg\" property in %s is empty", node->fullpath);
  443. addr_cells = node_addr_cells(node->parent);
  444. size_cells = node_size_cells(node->parent);
  445. entrylen = (addr_cells + size_cells) * sizeof(cell_t);
  446. if ((prop->val.len % entrylen) != 0)
  447. FAIL(c, "\"reg\" property in %s has invalid length (%d bytes) "
  448. "(#address-cells == %d, #size-cells == %d)",
  449. node->fullpath, prop->val.len, addr_cells, size_cells);
  450. }
  451. NODE_CHECK(reg_format, NULL, WARN, &addr_size_cells);
  452. static void check_ranges_format(struct check *c, struct node *dt,
  453. struct node *node)
  454. {
  455. struct property *prop;
  456. int c_addr_cells, p_addr_cells, c_size_cells, p_size_cells, entrylen;
  457. prop = get_property(node, "ranges");
  458. if (!prop)
  459. return;
  460. if (!node->parent) {
  461. FAIL(c, "Root node has a \"ranges\" property");
  462. return;
  463. }
  464. p_addr_cells = node_addr_cells(node->parent);
  465. p_size_cells = node_size_cells(node->parent);
  466. c_addr_cells = node_addr_cells(node);
  467. c_size_cells = node_size_cells(node);
  468. entrylen = (p_addr_cells + c_addr_cells + c_size_cells) * sizeof(cell_t);
  469. if (prop->val.len == 0) {
  470. if (p_addr_cells != c_addr_cells)
  471. FAIL(c, "%s has empty \"ranges\" property but its "
  472. "#address-cells (%d) differs from %s (%d)",
  473. node->fullpath, c_addr_cells, node->parent->fullpath,
  474. p_addr_cells);
  475. if (p_size_cells != c_size_cells)
  476. FAIL(c, "%s has empty \"ranges\" property but its "
  477. "#size-cells (%d) differs from %s (%d)",
  478. node->fullpath, c_size_cells, node->parent->fullpath,
  479. p_size_cells);
  480. } else if ((prop->val.len % entrylen) != 0) {
  481. FAIL(c, "\"ranges\" property in %s has invalid length (%d bytes) "
  482. "(parent #address-cells == %d, child #address-cells == %d, "
  483. "#size-cells == %d)", node->fullpath, prop->val.len,
  484. p_addr_cells, c_addr_cells, c_size_cells);
  485. }
  486. }
  487. NODE_CHECK(ranges_format, NULL, WARN, &addr_size_cells);
  488. /*
  489. * Style checks
  490. */
  491. static void check_avoid_default_addr_size(struct check *c, struct node *dt,
  492. struct node *node)
  493. {
  494. struct property *reg, *ranges;
  495. if (!node->parent)
  496. return; /* Ignore root node */
  497. reg = get_property(node, "reg");
  498. ranges = get_property(node, "ranges");
  499. if (!reg && !ranges)
  500. return;
  501. if ((node->parent->addr_cells == -1))
  502. FAIL(c, "Relying on default #address-cells value for %s",
  503. node->fullpath);
  504. if ((node->parent->size_cells == -1))
  505. FAIL(c, "Relying on default #size-cells value for %s",
  506. node->fullpath);
  507. }
  508. NODE_CHECK(avoid_default_addr_size, NULL, WARN, &addr_size_cells);
  509. static void check_obsolete_chosen_interrupt_controller(struct check *c,
  510. struct node *dt)
  511. {
  512. struct node *chosen;
  513. struct property *prop;
  514. chosen = get_node_by_path(dt, "/chosen");
  515. if (!chosen)
  516. return;
  517. prop = get_property(chosen, "interrupt-controller");
  518. if (prop)
  519. FAIL(c, "/chosen has obsolete \"interrupt-controller\" "
  520. "property");
  521. }
  522. TREE_CHECK(obsolete_chosen_interrupt_controller, NULL, WARN);
  523. static struct check *check_table[] = {
  524. &duplicate_node_names, &duplicate_property_names,
  525. &node_name_chars, &node_name_format, &property_name_chars,
  526. &name_is_string, &name_properties,
  527. &duplicate_label,
  528. &explicit_phandles,
  529. &phandle_references, &path_references,
  530. &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,
  531. &device_type_is_string, &model_is_string, &status_is_string,
  532. &addr_size_cells, &reg_format, &ranges_format,
  533. &avoid_default_addr_size,
  534. &obsolete_chosen_interrupt_controller,
  535. };
  536. void process_checks(int force, struct boot_info *bi)
  537. {
  538. struct node *dt = bi->dt;
  539. int i;
  540. int error = 0;
  541. for (i = 0; i < ARRAY_SIZE(check_table); i++) {
  542. struct check *c = check_table[i];
  543. if (c->level != IGNORE)
  544. error = error || run_check(c, dt);
  545. }
  546. if (error) {
  547. if (!force) {
  548. fprintf(stderr, "ERROR: Input tree has errors, aborting "
  549. "(use -f to force output)\n");
  550. exit(2);
  551. } else if (quiet < 3) {
  552. fprintf(stderr, "Warning: Input tree has errors, "
  553. "output forced\n");
  554. }
  555. }
  556. }