From: Amos Kong <kongjianjun@gmail.com>
To: Eric Blake <eblake@redhat.com>
Cc: Paolo Bonzini <bonzini@gnu.org>,
paolo.bonzini@gmail.com, armbru@redhat.com,
qemu-devel@nongnu.org, SeokYeon Hwang <syeon.hwang@samsung.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] error: fixed error_set_errno() to deal with a negative type of os_error.
Date: Thu, 6 Nov 2014 12:49:03 +0800 [thread overview]
Message-ID: <20141106044903.GA8764@air.redhat.com> (raw)
In-Reply-To: <545A07C6.1020001@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]
On Wed, Nov 05, 2014 at 12:19:34PM +0100, Eric Blake wrote:
> On 11/05/2014 12:11 PM, Max Reitz wrote:
>
> >>>> + err->msg = g_strdup_printf("%s: %s", msg1,
> >>>> strerror(abs(os_errno)));
>
> >> I don't, we really should fix the callers.
> >
> > Of course I understand, but this patch doesn't make matters worse, as
> > long as there are not systems which have negative values for errno
>
> POSIX requires all defined errno values to be positive; negative errno
> values are unambiguous as values that will cause strerror() to have to
> generate a message about an unknown value.
>
> > (which I think we generally assume not to exist throughout qemu). That's
> > why I'm fine with it. We should fix the callers but I don't see why we
> > shouldn't apply this patch as well.
>
> This patch is a bandaid; it makes it harder to find callers that need to
> be fixed. I'd almost argue the exact opposite - add an assert(os_errno
> > 0). Then we'd loudly break on broken callers, making them easier to find.
Agree! use an assert to teach the caller ;)
> > A similar issue already came up and led to commit b276d2499, where
> > callers of error_setg_errno() assumed that it would not clobber errno,
> > so we fixed some of the callers but also applied that commit which just
> > saves errno because there's no reason not to.
>
> If we're willing to accept the convenience so that callers can be lazy,
> then I like this patch. If we want to fix bugs in the callers, then
> this patch makes it harder to find those bugs.
>
> I'm actually 60:40 in favor of this patch (I think the convenience
> outweighs an audit of fixing all callers); but if we do that, then we
> might also want to intentionally switch existing callers to pass
> negative values rather than declaring that passing a negative value is a
> bug.
--
Amos.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2014-11-06 4:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-05 8:09 [Qemu-devel] [PATCH] error: fixed error_set_errno() to deal with a negative type of os_error SeokYeon Hwang
2014-11-05 8:12 ` Max Reitz
2014-11-05 10:57 ` Paolo Bonzini
2014-11-05 11:11 ` Max Reitz
2014-11-05 11:19 ` Eric Blake
2014-11-06 4:49 ` Amos Kong [this message]
2014-11-05 12:44 ` Paolo Bonzini
2014-11-05 13:13 ` SeokYeon Hwang
2014-11-05 13:29 ` Markus Armbruster
2014-11-06 2:02 ` SeokYeon Hwang
2014-11-06 9:25 ` Markus Armbruster
2014-11-07 2:26 ` SeokYeon Hwang
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=20141106044903.GA8764@air.redhat.com \
--to=kongjianjun@gmail.com \
--cc=armbru@redhat.com \
--cc=bonzini@gnu.org \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=paolo.bonzini@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=syeon.hwang@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).