All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>,
	Leonardo Bras <leobras@redhat.com>
Subject: migration/rdma.c's macro ERROR()
Date: Fri, 05 May 2023 12:51:45 +0200	[thread overview]
Message-ID: <87sfcbuk3i.fsf@pond.sub.org> (raw)

migration/rdma.c has

    /*
     * Print and error on both the Monitor and the Log file.
     */
    #define ERROR(errp, fmt, ...) \
        do { \
            fprintf(stderr, "RDMA ERROR: " fmt "\n", ## __VA_ARGS__); \
            if (errp && (*(errp) == NULL)) { \
                error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \
            } \
        } while (0)

This is problematic.  The point of error_setg() & friends is detectin
errors from handling them.  error.h:

 * - Separation of concerns: the function is responsible for detecting
 *   errors and failing cleanly; handling the error is its caller's
 *   job.  [...]

Reporting the error to stderr violates this principle.  Consequences
include

* When the caller reports the error to stderr, it gets reported there
  twice, possibly in slightly different form.

* When the caller recovers from the error cleanly without reporting it,
  it is reported to stderr anyway, even though it is not actually an
  error.

Mind if I kill the macro?



             reply	other threads:[~2023-05-05 10:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 10:51 Markus Armbruster [this message]
2023-05-05 14:26 ` migration/rdma.c's macro ERROR() Peter Xu

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=87sfcbuk3i.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=leobras@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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.