diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-02-18 19:48:33 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2010-03-16 16:58:32 +0100 |
commit | cf5a65aaaf3e9382e50df550ba049a1c8691a5dd (patch) | |
tree | cefb10d2cab499ba0d7c76682503a309c187dc4a /qemu-error.c | |
parent | 65abca0a3441fb47024553e7676f6f3eef685a32 (diff) |
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:)
Diffstat (limited to 'qemu-error.c')
-rw-r--r-- | qemu-error.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/qemu-error.c b/qemu-error.c index 214e4481e..23176e16a 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); } |