qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 05/14] util/error: make func optional


From: Markus Armbruster
Subject: Re: [PATCH 05/14] util/error: make func optional
Date: Mon, 02 Jun 2025 12:52:34 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Paolo Bonzini <pbonzini@redhat.com> writes:

> The function name is not available in Rust, so make it optional.
>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  util/error.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/util/error.c b/util/error.c
> index 3449ecc0b92..daea2142f30 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -24,8 +24,13 @@ Error *error_warn;
>  static void error_handle(Error **errp, Error *err)
>  {
>      if (errp == &error_abort) {
> -        fprintf(stderr, "Unexpected error in %s() at %.*s:%d:\n",
> -                err->func, err->src_len, err->src, err->line);
> +        if (err->func) {
> +            fprintf(stderr, "Unexpected error in %s() at %.*s:%d:\n",
> +                    err->func, err->src_len, err->src, err->line);
> +        } else {
> +            fprintf(stderr, "Unexpected error at %.*s:%d:\n",
> +                 err->src_len, err->src, err->line);
> +        }
>          error_report("%s", error_get_pretty(err));
>          if (err->hint) {
>              error_printf("%s", err->hint->str);

This changes struct Error member @func from non-null to maybe-null.  An
argument could be made for a comment there.  But since "can this be
null" questions are *everywhere* in C, it would be a rather weak
argument: competent programmers are unlikely to be misled.

Reviewed-by: Markus Armbruster <armbru@redhat.com>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]