The function name is not available in Rust, so make it optional.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
util/error.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/util/error.c b/util/error.c
index 6c1033eaba5..b977007faaf 100644
--- a/util/error.c
+++ b/util/error.c
@@ -29,8 +29,12 @@ static void error_handle(Error **errp, Error *err)
/* No need to free it, the program will abort very soon... */
src = g_strndup(err->src, err->src_len);
}
- fprintf(stderr, "Unexpected error in %s() at %s:%d:\n",
- err->func, src, err->line);
+ if (err->func) {
+ fprintf(stderr, "Unexpected error in %s() at %s:%d:\n",
+ err->func, src, err->line);
+ } else {
+ fprintf(stderr, "Unexpected error at %s:%d:\n", src, err->line);
+ }
error_report("%s", error_get_pretty(err));
if (err->hint) {
error_printf("%s", err->hint->str);
--
2.49.0