All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: Halil Pasic <pasic@linux.vnet.ibm.com>,
	qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open
Date: Wed, 27 Jul 2016 09:55:27 +0200	[thread overview]
Message-ID: <87twfbwm4w.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <5fd0b60a-4d31-d949-9f9b-934b228b2e4e@redhat.com> (Max Reitz's message of "Tue, 26 Jul 2016 19:54:13 +0200")

Max Reitz <mreitz@redhat.com> writes:

> On 26.07.2016 19:18, Halil Pasic wrote:
>> 
>> 
>> On 07/26/2016 05:42 PM, Max Reitz wrote:
>>>> +++ b/block/raw-posix.c
>>>>> @@ -485,6 +485,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
>>>>>      s->fd = -1;
>>>>>      fd = qemu_open(filename, s->open_flags, 0644);
>>>>>      if (fd < 0) {
>>>>> +        error_setg_errno(errp, errno, "Could not open file");
>>> We don't guarantee that error_setg_errno() does not modify errno. (In
>>> practice it should not, but we don't guarantee that.)
>>>
>> 
>> 
>> Thank you very much for your review. I have double checked, and I
>> remembered correctly: error_setg_errno saves and restores the original
>> errno, so that is why I assumed it does not. 
>
> Oh, and about this: Yes, I remember, this was introduced after we had
> noticed that we had some old code that assumed that error_setg() would
> not modify errno. We had to decide between making error_setg*() save and
> restore errno (which we deemed a bit ugly) and fixing all of that old
> code (which we deemed hard). So we want for the former, but I don't
> think we actually guarantee that behavior (because you should never rely
> on any function not to modify errno).

Since we rely on this behavior, we should definitely spell it out in the
function contract.

> (The difference between us saving/restoring errno in practice and
> guaranteeing that feature is the lack of documentation thereof, i.e.,
> the comment for error_setg() in include/qapi/error.h doesn't mention
> this :-))

Let's fix it.

  reply	other threads:[~2016-07-27  7:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 12:30 [Qemu-devel] [PATCH 1/1] block: improve error handling in raw_open Halil Pasic
2016-07-18 14:41 ` [Qemu-devel] [Qemu-block] " Max Reitz
2016-07-18 15:48   ` Halil Pasic
2016-07-18 15:57     ` Max Reitz
2016-07-18 17:04       ` Halil Pasic
2016-07-22 22:01         ` Max Reitz
2016-07-26 11:34 ` [Qemu-devel] [PATCH v2 " Halil Pasic
2016-07-26 15:42   ` Max Reitz
2016-07-26 17:18     ` Halil Pasic
2016-07-26 17:47       ` Max Reitz
2016-07-27 12:40         ` Halil Pasic
2016-07-27 14:37           ` Max Reitz
2016-07-27 15:46             ` Halil Pasic
2016-07-27 12:59         ` Markus Armbruster
2016-07-27 14:33           ` Max Reitz
2016-07-26 17:54       ` Max Reitz
2016-07-27  7:55         ` Markus Armbruster [this message]
2016-07-26 18:03     ` Sascha Silbe
2016-07-26 18:06       ` Max Reitz
2016-07-26 18:46         ` Sascha Silbe
2016-07-26 18:08   ` [Qemu-devel] [Qemu-block] " John Snow

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=87twfbwm4w.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=qemu-block@nongnu.org \
    --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.