On Mon, Sep 15, 2025 at 04:22:01PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Add a pair to &error_warn helper, to reduce the pattern like
> 
>     Error *local_err = NULL;
> 
>     ...
> 
>     if (!foo(..., &local_err)) {
>         error_report_err(local_err);
>         return false;
>     }
> 
> to simply
> 
>     if (!foo(..., &error_reporter)) {
>         return false;
>     }
> 
> Of course, for new interfaces, it's better to always support and handle
> errp argument. But when have to rework the old ones, it's not always
> feasible to convert everything to support/handle errp.
> 
> The new helper is used in following commits.

Could we add some explanation of why we need this if we already have
error_warn?

I don't see much difference except error_warn will prepend it with
"warning: ", but that doesn't sound like a real problem..

> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
> ---
>  include/qapi/error.h | 6 ++++++
>  util/error.c         | 3 +++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/include/qapi/error.h b/include/qapi/error.h
> index 41e3816380..cea95f5c36 100644
> --- a/include/qapi/error.h
> +++ b/include/qapi/error.h
> @@ -539,6 +539,12 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(ErrorPropagator, 
> error_propagator_cleanup);
>   */
>  extern Error *error_warn;
>  
> +/*
> + * Special error destination to report on error.
> + * See error_setg() and error_propagate() for details.
> + */
> +extern Error *error_reporter;
> +
>  /*
>   * Special error destination to abort on error.
>   * See error_setg() and error_propagate() for details.
> diff --git a/util/error.c b/util/error.c
> index daea2142f3..5160435c86 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -20,6 +20,7 @@
>  Error *error_abort;
>  Error *error_fatal;
>  Error *error_warn;
> +Error *error_reporter;
>  
>  static void error_handle(Error **errp, Error *err)
>  {
> @@ -43,6 +44,8 @@ static void error_handle(Error **errp, Error *err)
>      }
>      if (errp == &error_warn) {
>          warn_report_err(err);
> +    } else if (errp == &error_reporter) {
> +        error_report_err(err);
>      } else if (errp && !*errp) {
>          *errp = err;
>      } else {
> -- 
> 2.48.1
> 

-- 
Peter Xu


Reply via email to