qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] block: improve error handli


From: Max Reitz
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open
Date: Tue, 26 Jul 2016 19:54:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

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).

(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 :-))

Max

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]