summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xutil/sconfig/main.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/util/sconfig/main.c b/util/sconfig/main.c
index 40a220aa44..4abfd2c3bb 100755
--- a/util/sconfig/main.c
+++ b/util/sconfig/main.c
@@ -89,7 +89,9 @@ int yywrap(void) {
void yyerror (char const *str)
{
- fprintf (stderr, "line %d: %s\n", linenum, str);
+ extern char *yytext;
+ fprintf (stderr, "line %d: %s: %s\n", linenum + 1, yytext, str);
+ exit(1);
}
void postprocess_devtree(void) {
@@ -408,12 +410,18 @@ int main(int argc, char** argv) {
sprintf(headers.next->name, "mainboard/%s", mainboard);
FILE *filec = fopen(devtree, "r");
- yyrestart(filec);
+ if (!filec) {
+ fprintf(stderr, "Could not open file '%s' for reading: ", devtree);
+ perror(NULL);
+ exit(1);
+ }
- FILE *staticc = fopen(outputc, "w");
+ yyrestart(filec);
lastdev = head = &root;
+
yyparse();
+
fclose(filec);
if ((head->type == chip) && (!head->chiph_exists)) {
@@ -422,6 +430,13 @@ int main(int argc, char** argv) {
while (head->next != tmp) head = head->next;
}
+ FILE *staticc = fopen(outputc, "w");
+ if (!staticc) {
+ fprintf(stderr, "Could not open file '%s' for writing: ", outputc);
+ perror(NULL);
+ exit(1);
+ }
+
fprintf(staticc, "#include <device/device.h>\n");
fprintf(staticc, "#include <device/pci.h>\n");
struct header *h = &headers;
@@ -435,5 +450,6 @@ int main(int argc, char** argv) {
walk_device_tree(staticc, &root, pass1, NULL);
fclose(staticc);
+
return 0;
}