mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
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:)
This commit is contained in:
parent
65abca0a34
commit
cf5a65aaaf
5 changed files with 49 additions and 18 deletions
20
qemu-error.c
20
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue