From: Max Reitz <mreitz@redhat.com>
To: Paolo Bonzini <bonzini@gnu.org>,
SeokYeon Hwang <syeon.hwang@samsung.com>,
qemu-devel@nongnu.org
Cc: paolo.bonzini@gmail.com, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH] error: fixed error_set_errno() to deal with a negative type of os_error.
Date: Wed, 05 Nov 2014 12:11:08 +0100 [thread overview]
Message-ID: <545A05CC.4050109@redhat.com> (raw)
In-Reply-To: <545A0288.4010905@gnu.org>
On 2014-11-05 at 11:57, Paolo Bonzini wrote:
> On 05/11/2014 09:12, Max Reitz wrote:
>> On 2014-11-05 at 09:09, SeokYeon Hwang wrote:
>>> Negative type of errno like -ERRNO is used a lot by developers.
>>> Therefore, error_set_errno() is modified to deal with a negative type
>>> of os_error.
>>> (Negative type is used at pcie_cap_slot_hotplug_common() in
>>> hw/pci/pcie.c)
>>>
>>> Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
>>> ---
>>> util/error.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/util/error.c b/util/error.c
>>> index 2ace0d8..5db00c9 100644
>>> --- a/util/error.c
>>> +++ b/util/error.c
>>> @@ -68,7 +68,7 @@ void error_set_errno(Error **errp, int os_errno,
>>> ErrorClass err_class,
>>> va_start(ap, fmt);
>>> msg1 = g_strdup_vprintf(fmt, ap);
>>> if (os_errno != 0) {
>>> - err->msg = g_strdup_printf("%s: %s", msg1, strerror(os_errno));
>>> + err->msg = g_strdup_printf("%s: %s", msg1,
>>> strerror(abs(os_errno)));
>>> g_free(msg1);
>>> } else {
>>> err->msg = msg1;
>> This is utterly broken and we should fix all callers instead.
>>
>> ...But I like it.
> 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
(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.
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.
Max
> Paolo
>
>> Reviewed-by: Max Reitz <mreitz@redhat.com>
next prev parent reply other threads:[~2014-11-05 11:11 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 [this message]
2014-11-05 11:19 ` Eric Blake
2014-11-06 4:49 ` Amos Kong
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=545A05CC.4050109@redhat.com \
--to=mreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=bonzini@gnu.org \
--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 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.