From cf5a65aaaf3e9382e50df550ba049a1c8691a5dd Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 18 Feb 2010 19:48:33 +0100 Subject: error: Track locations in configuration files New LOC_FILE. Use it for tracking file name and line number in qemu_config_parse(). We now report errors like qemu:foo.conf:42: Did not find I2C bus for smbus-eeprom In particular, gems like this message: -device: no driver specified become almost nice now: qemu:foo.conf:44: -device: no driver specified (A later commit will get rid of the bogus -device:) --- qemu-error.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'qemu-error.c') diff --git a/qemu-error.c b/qemu-error.c index 214e4481e2..23176e16a8 100644 --- a/qemu-error.c +++ b/qemu-error.c @@ -113,6 +113,19 @@ void loc_set_none(void) cur_loc->kind = LOC_NONE; } +/* + * Change the current location to file FNAME, line LNO. + */ +void loc_set_file(const char *fname, int lno) +{ + assert (fname || cur_loc->kind == LOC_FILE); + cur_loc->kind = LOC_FILE; + cur_loc->num = lno; + if (fname) { + cur_loc->ptr = fname; + } +} + static const char *progname; /* @@ -136,6 +149,13 @@ void error_print_loc(void) sep = " "; } switch (cur_loc->kind) { + case LOC_FILE: + error_printf("%s:", (const char *)cur_loc->ptr); + if (cur_loc->num) { + error_printf("%d:", cur_loc->num); + } + error_printf(" "); + break; default: error_printf(sep); } -- cgit v1.2.3-59-g8ed1b