[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 20:06:01 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
On 26.07.2016 20:03, Sascha Silbe wrote:
> Dear Max,
>
> Max Reitz <address@hidden> writes:
>
>> We don't guarantee that error_setg_errno() does not modify errno. (In
>> practice it should not, but we don't guarantee that.)
>
> I agree it's a good general policy to _not_ rely on the callee
> explicitly saving and restoring errno. Especially since C11 pretty much
> allows any "library function" (including e.g. va_start()) to clobber
> errno...
>
> In the case of error_setg_errno() it would be helpful to mention that in
> the API docs. The current implementation goes out of its way to preserve
> errno, so callers might come to rely on it.
>
> So how about:
>
> /*
> * Just like error_setg(), with @os_error info added to the message.
> * If @os_error is non-zero, ": " + strerror(os_error) is appended to
> * the human-readable error message.
> + *
> + * Reminder: errno may get clobbered by almost any function call. If
> + * you need the value of errno for another purpose, save it before
> + * invoking error_setg_errno() (or any other function for that
> + * matter).
> */
> #define error_setg_errno(errp, os_error, fmt, ...) \
> error_setg_errno_internal((errp), __FILE__, __LINE__, __func__, \
> (os_error), (fmt), ## __VA_ARGS__)
>
> (I can prepare a proper patch if you agree with the above.)
Thanks, that sounds good to me.
Max
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-block] [PATCH v2 1/1] block: improve error handling in raw_open, (continued)
- Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open, Max Reitz, 2016/07/26
- Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open, Markus Armbruster, 2016/07/27
- Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open, Sascha Silbe, 2016/07/26
- Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open,
Max Reitz <=
- Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open, Sascha Silbe, 2016/07/26
Re: [Qemu-block] [PATCH v2 1/1] block: improve error handling in raw_open, John Snow, 2016/07/26
[Qemu-block] [PATCH 1/1] block: improve error handling in raw_open, Halil Pasic, 2016/07/27