mirror of https://github.com/xqemu/xqemu.git
error: Don't append a newline when printing the error hint
Since commit 50b7b00
, we have error_append_hint() to conveniently
accumulate Error member @hint. error_report_err() prints it with a
newline appended. Consequently, users of error_append_hint() need to
know whether theirs is the final line of the hint to decide whether it
needs a newline. Not a nice interface.
Change error_report_err() to print just the hint, and the (still few)
users of error_append_hint() to add the required newline.
Cc: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1450370121-5768-7-git-send-email-armbru@redhat.com>
This commit is contained in:
parent
9280eb34de
commit
543202c0dd
|
@ -304,6 +304,7 @@ static void qbus_list_bus(DeviceState *dev, Error **errp)
|
||||||
error_append_hint(errp, "%s\"%s\"", sep, child->name);
|
error_append_hint(errp, "%s\"%s\"", sep, child->name);
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
|
error_append_hint(errp, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qbus_list_dev(BusState *bus, Error **errp)
|
static void qbus_list_dev(BusState *bus, Error **errp)
|
||||||
|
@ -321,6 +322,7 @@ static void qbus_list_dev(BusState *bus, Error **errp)
|
||||||
}
|
}
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
|
error_append_hint(errp, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static BusState *qbus_find_bus(DeviceState *dev, char *elem)
|
static BusState *qbus_find_bus(DeviceState *dev, char *elem)
|
||||||
|
|
|
@ -204,7 +204,7 @@ void error_report_err(Error *err)
|
||||||
{
|
{
|
||||||
error_report("%s", error_get_pretty(err));
|
error_report("%s", error_get_pretty(err));
|
||||||
if (err->hint) {
|
if (err->hint) {
|
||||||
error_printf_unless_qmp("%s\n", err->hint->str);
|
error_printf_unless_qmp("%s", err->hint->str);
|
||||||
}
|
}
|
||||||
error_free(err);
|
error_free(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ void parse_option_size(const char *name, const char *value,
|
||||||
default:
|
default:
|
||||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
|
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
|
||||||
error_append_hint(errp, "You may use k, M, G or T suffixes for "
|
error_append_hint(errp, "You may use k, M, G or T suffixes for "
|
||||||
"kilobytes, megabytes, gigabytes and terabytes.");
|
"kilobytes, megabytes, gigabytes and terabytes.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -647,7 +647,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
|
||||||
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id",
|
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id",
|
||||||
"an identifier");
|
"an identifier");
|
||||||
error_append_hint(errp, "Identifiers consist of letters, digits, "
|
error_append_hint(errp, "Identifiers consist of letters, digits, "
|
||||||
"'-', '.', '_', starting with a letter.");
|
"'-', '.', '_', starting with a letter.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
opts = qemu_opts_find(list, id);
|
opts = qemu_opts_find(list, id);
|
||||||
|
|
Loading…
Reference in New Issue