summaryrefslogtreecommitdiff
path: root/dtc-parser.y
diff options
context:
space:
mode:
authorJohn Bonesio <bones@secretlab.ca>2010-10-20 14:44:58 -0700
committerGrant Likely <grant.likely@secretlab.ca>2010-10-20 22:36:53 -0600
commitc0fa2e6d4e59e62f2e9f23db1a2d94532fa4ae98 (patch)
tree9e465279a18f3a05bc314a0d20db3b3605a17556 /dtc-parser.y
parent8773e12fa9f5109172a779aa2a83b4464e5273cc (diff)
downloaddtc-c0fa2e6d4e59e62f2e9f23db1a2d94532fa4ae98.tar.gz
Create new and use new print_error that uses printf style formatting.
yyerror is meant to be called by the parser internal code, and it's interface is limited. Instead create and call a new error message routine that allows formatted strings to be used. yyerror uses the new routine so error formatting remains consistent. Signed-of-by: John Bonesio <bones@secretlab.ca> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r--dtc-parser.y28
1 files changed, 18 insertions, 10 deletions
diff --git a/dtc-parser.y b/dtc-parser.y
index 0aaf8e8..b58ba8e 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -27,6 +27,7 @@
YYLTYPE yylloc;
extern int yylex(void);
+extern void print_error(char const *fmt, ...);
extern void yyerror(char const *s);
extern struct boot_info *the_boot_info;
@@ -136,8 +137,7 @@ devicetree:
if (target)
merge_nodes(target, $3);
else
- yyerror("label does not exist in "
- " node redefinition");
+ print_error("label, '%s' not found", $2);
$$ = $1;
}
;
@@ -200,8 +200,7 @@ propdata:
if ($6 != 0)
if (fseek(f, $6, SEEK_SET) != 0)
- srcpos_error(&yylloc,
- "Couldn't seek to offset %llu in \"%s\": %s",
+ print_error("Couldn't seek to offset %llu in \"%s\": %s",
(unsigned long long)$6,
$4.val,
strerror(errno));
@@ -295,7 +294,7 @@ subnodes:
}
| subnode propdef
{
- yyerror("syntax error: properties must precede subnodes");
+ print_error("syntax error: properties must precede subnodes");
YYERROR;
}
;
@@ -314,12 +313,21 @@ subnode:
%%
-void yyerror(char const *s)
+void print_error(char const *fmt, ...)
{
- srcpos_error(&yylloc, "%s", s);
+ va_list va;
+
+ va_start(va, fmt);
+ srcpos_verror(&yylloc, fmt, va);
+ va_end(va);
+
treesource_error = 1;
}
+void yyerror(char const *s) {
+ print_error("%s", s);
+}
+
static unsigned long long eval_literal(const char *s, int base, int bits)
{
unsigned long long val;
@@ -328,11 +336,11 @@ static unsigned long long eval_literal(const char *s, int base, int bits)
errno = 0;
val = strtoull(s, &e, base);
if (*e)
- yyerror("bad characters in literal");
+ print_error("bad characters in literal");
else if ((errno == ERANGE)
|| ((bits < 64) && (val >= (1ULL << bits))))
- yyerror("literal out of range");
+ print_error("literal out of range");
else if (errno != 0)
- yyerror("bad literal");
+ print_error("bad literal");
return val;
}