All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: "Peter Crosthwaite" <peter.crosthwaite@xilinx.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	"Anthony Liguori" <anthony@codemonkey.ws>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH] qom: abort on error in property setter if caller passed errp == NULL
Date: Thu, 28 Nov 2013 14:41:31 +0100	[thread overview]
Message-ID: <5297480B.9050501@redhat.com> (raw)
In-Reply-To: <20131128142323.01a88c7e@nial.usersys.redhat.com>

Il 28/11/2013 14:23, Igor Mammedov ha scritto:
> > object_property_set(Foo, bar, "baz", &abort_on_err);
> 
> that is just another way to put burden on caller, instead of doing it
> in one place.

It's also much more self-documenting.

The problem is that there is one very good case where you want the
silent-don't-care behavior: when you don't care about the exact error,
and you can figure out whether there was an error from the returned
value of the function.  This doesn't apply to object_property_set of
course, but it is the reason why NULL Error* has silent-don't-care behavior.

Now, let's look at the alternatives:

* keep silent don't care
  + consistent
  + predictable
  - not always handy

* only modify object_property_set
  + mostly does the right thing
  - inconsistent with other Error* functions
  - inconsistent with _nofail functions

* Peter's alternative
  + self-documenting
  + consistent
  + predictable

* make Error* mandatory for all void functions
  + consistent
  + almost predictable (because in C you can ignore return values)
  - not necessarily does the right thing (e.g. cleanup functions)
  - requires manual effort to abide to the policy

I vote for Peter's proposal, or for adding object_property_set_nofail.
No particular preference.

Another variant: modify object_property_set to add a g_warning.  I think
it's fine.  It reduces the inconsistency, and still simplifies debugging.

Paolo

  reply	other threads:[~2013-11-28 13:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-28  1:24 [Qemu-devel] [PATCH] qom: abort on error in property setter if caller passed errp == NULL Igor Mammedov
2013-11-28  4:58 ` Eric Blake
2013-11-28 13:01   ` Igor Mammedov
2013-11-28  5:10 ` Peter Crosthwaite
2013-11-28  7:53   ` Markus Armbruster
2013-11-28 13:23   ` Igor Mammedov
2013-11-28 13:41     ` Paolo Bonzini [this message]
2013-11-28 15:03       ` Markus Armbruster
2013-11-29  0:21         ` Peter Crosthwaite
2013-11-29  7:56           ` Markus Armbruster
2013-12-03  5:51             ` Peter Crosthwaite
2013-11-28 15:00     ` Markus Armbruster
2013-11-28 13:42 ` Andreas Färber
2013-11-28 13:48   ` Igor Mammedov
2013-11-28 14:00     ` Andreas Färber

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=5297480B.9050501@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@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.