All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
	Peter Xu <peterx@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/2] qemu-error: make use of {error, warn}_report_once_cond
Date: Fri, 31 Aug 2018 08:01:39 +0200	[thread overview]
Message-ID: <87tvnbvzuk.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20180830145902.27376-3-cohuck@redhat.com> (Cornelia Huck's message of "Thu, 30 Aug 2018 16:59:02 +0200")

Cornelia Huck <cohuck@redhat.com> writes:

> {error,warn}_report_once() are a special case of the new functions
> and can simply switch to them.
>
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> ---
>  include/qemu/error-report.h | 34 ++++++++++++++--------------------
>  1 file changed, 14 insertions(+), 20 deletions(-)
>
> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
> index e415128ac4..918cb936d8 100644
> --- a/include/qemu/error-report.h
> +++ b/include/qemu/error-report.h
> @@ -53,32 +53,26 @@ bool warn_report_once_cond(bool *printed, const char *fmt, ...)
>   * Similar to error_report(), except it prints the message just once.
>   * Return true when it prints, false otherwise.
>   */
> -#define error_report_once(fmt, ...)             \
> -    ({                                          \
> -        static bool print_once_;                \
> -        bool ret_print_once_ = !print_once_;    \
> -                                                \
> -        if (!print_once_) {                     \
> -            print_once_ = true;                 \
> -            error_report(fmt, ##__VA_ARGS__);   \
> -        }                                       \
> -        unlikely(ret_print_once_);              \
> +#define error_report_once(fmt, ...)                     \
> +    ({                                                  \
> +        static bool print_once_;                        \
> +        bool ret_print_once_ =                          \
> +            error_report_once_cond(&print_once_,        \
> +                                   fmt, ##__VA_ARGS__); \
> +        unlikely(ret_print_once_);                      \
>      })

Do we still need @ret_print_once_?

   #define error_report_once(fmt, ...)                     \
       ({                                                  \
           static bool print_once_;                        \
           unlikely(error_report_once_cond(&print_once_,   \
                                   fmt, ##__VA_ARGS__));   \
       })

Or dispense with the unlikely:

   #define error_report_once(fmt, ...)                     \
       ({                                                  \
           static bool print_once_;                        \
           error_report_once_cond(&print_once_,            \
                                  fmt, ##__VA_ARGS__);     \
       })

Got a preference?

>  
>  /*
>   * Similar to warn_report(), except it prints the message just once.
>   * Return true when it prints, false otherwise.
>   */
> -#define warn_report_once(fmt, ...)              \
> -    ({                                          \
> -        static bool print_once_;                \
> -        bool ret_print_once_ = !print_once_;    \
> -                                                \
> -        if (!print_once_) {                     \
> -            print_once_ = true;                 \
> -            warn_report(fmt, ##__VA_ARGS__);    \
> -        }                                       \
> -        unlikely(ret_print_once_);              \
> +#define warn_report_once(fmt, ...)                      \
> +    ({                                                  \
> +        static bool print_once_;                        \
> +        bool ret_print_once_ =                          \
> +            warn_report_once_cond(&print_once_,         \
> +                                  fmt, ##__VA_ARGS__);  \
> +        unlikely(ret_print_once_);                      \
>      })
>  
>  const char *error_get_progname(void);

      reply	other threads:[~2018-08-31  6:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 14:59 [Qemu-devel] [PATCH v2 0/2] qemu-error: advanced report_once handling Cornelia Huck
2018-08-30 14:59 ` [Qemu-devel] [PATCH v2 1/2] qemu-error: add {error, warn}_report_once_cond Cornelia Huck
2018-08-31  5:57   ` Markus Armbruster
2018-08-30 14:59 ` [Qemu-devel] [PATCH v2 2/2] qemu-error: make use of " Cornelia Huck
2018-08-31  6:01   ` Markus Armbruster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tvnbvzuk.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.