aboutsummaryrefslogtreecommitdiff
path: root/checks.c
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2018-11-24 14:47:56 -0600
committerDavid Gibson <david@gibson.dropbear.id.au>2018-11-25 18:24:00 +1100
commit3616b9a811b66744b4b818c2930462b480ddae44 (patch)
tree6511f6bab120f69f301c42eb27473edb75ae84b7 /checks.c
parent2bdbd07a1223e26c73caccb54f9af51f958c5b8f (diff)
downloaddtc-3616b9a811b66744b4b818c2930462b480ddae44.zip
dtc-3616b9a811b66744b4b818c2930462b480ddae44.tar.gz
dtc-3616b9a811b66744b4b818c2930462b480ddae44.tar.bz2
checks: Use source position information for check failures
Now that we retain source position information of nodes and properties, make that the preferred file name (and position) to print out in check failures. This will greatly simplify finding and fixing check errors because most errors are in included source .dtsi files and they get duplicated every time the source file is included. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'checks.c')
-rw-r--r--checks.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/checks.c b/checks.c
index 32e0d7a..4dfdf48 100644
--- a/checks.c
+++ b/checks.c
@@ -19,6 +19,7 @@
*/
#include "dtc.h"
+#include "srcpos.h"
#ifdef TRACE_CHECKS
#define TRACE(c, ...) \
@@ -79,13 +80,30 @@ static inline void PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti,
{
va_list ap;
char *str = NULL;
+ struct srcpos *pos = NULL;
+ char *file_str;
if (!(c->warn && (quiet < 1)) && !(c->error && (quiet < 2)))
return;
- xasprintf(&str, "%s: %s (%s): ",
- strcmp(dti->outname, "-") ? dti->outname : "<stdout>",
- (c->error) ? "ERROR" : "Warning", c->name);
+ if (prop && prop->srcpos)
+ pos = prop->srcpos;
+ else if (node && node->srcpos)
+ pos = node->srcpos;
+
+ if (pos) {
+ file_str = srcpos_string(pos);
+ xasprintf(&str, "%s", file_str);
+ free(file_str);
+ } else if (streq(dti->outname, "-")) {
+ xasprintf(&str, "<stdout>");
+ } else {
+ xasprintf(&str, "%s", dti->outname);
+ }
+
+ xasprintf_append(&str, ": %s (%s): ",
+ (c->error) ? "ERROR" : "Warning", c->name);
+
if (node) {
if (prop)
xasprintf_append(&str, "%s:%s: ", node->fullpath, prop->name);
@@ -99,6 +117,17 @@ static inline void PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti,
xasprintf_append(&str, "\n");
+ if (!prop && pos) {
+ pos = node->srcpos;
+ while (pos->next) {
+ pos = pos->next;
+
+ file_str = srcpos_string(pos);
+ str += xasprintf_append(&str, " also defined at %s\n", file_str);
+ free(file_str);
+ }
+ }
+
fputs(str, stderr);
}