* [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup
@ 2019-03-02 22:38 Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 1/2] util/error: Remove an unnecessary NULL check Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-03-02 22:38 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Markus Armbruster, Paolo Bonzini,
Daniel P . Berrangé, qemu-trivial,
Philippe Mathieu-Daudé, Michael Tokarev, Laurent Vivier
Trivial cleanups suggested by Daniel and Thomas.
Philippe Mathieu-Daudé (2):
util/error: Remove an unnecessary NULL check
util/error: Remove unnecessary saved_errno
util/error.c | 7 -------
1 file changed, 7 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] util/error: Remove an unnecessary NULL check
2019-03-02 22:38 [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Philippe Mathieu-Daudé
@ 2019-03-02 22:38 ` Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno Philippe Mathieu-Daudé
2019-03-04 15:36 ` [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Markus Armbruster
2 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-03-02 22:38 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Markus Armbruster, Paolo Bonzini,
Daniel P . Berrangé, qemu-trivial,
Philippe Mathieu-Daudé
This NULL check was required while introduced in 680d16dcb79f.
Later refactor added a NULL check in error_setv(), so this check
is now redundant.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
util/error.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/util/error.c b/util/error.c
index b5ccbd8eac..934a78e1b1 100644
--- a/util/error.c
+++ b/util/error.c
@@ -103,10 +103,6 @@ void error_setg_errno_internal(Error **errp,
va_list ap;
int saved_errno = errno;
- if (errp == NULL) {
- return;
- }
-
va_start(ap, fmt);
error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap,
os_errno != 0 ? strerror(os_errno) : NULL);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno
2019-03-02 22:38 [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 1/2] util/error: Remove an unnecessary NULL check Philippe Mathieu-Daudé
@ 2019-03-02 22:38 ` Philippe Mathieu-Daudé
2019-03-03 1:12 ` Eric Blake
2019-03-04 15:36 ` [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Markus Armbruster
2 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-03-02 22:38 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Markus Armbruster, Paolo Bonzini,
Daniel P . Berrangé, qemu-trivial,
Philippe Mathieu-Daudé
Since 552375088a8, error_set_errno() calls error_setv() which
already protect errno for clobbering.
Remove the now unnecessary saved_errno.
Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
util/error.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/util/error.c b/util/error.c
index 934a78e1b1..0402fa1b9d 100644
--- a/util/error.c
+++ b/util/error.c
@@ -101,14 +101,11 @@ void error_setg_errno_internal(Error **errp,
int os_errno, const char *fmt, ...)
{
va_list ap;
- int saved_errno = errno;
va_start(ap, fmt);
error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap,
os_errno != 0 ? strerror(os_errno) : NULL);
va_end(ap);
-
- errno = saved_errno;
}
void error_setg_file_open_internal(Error **errp,
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno
2019-03-02 22:38 ` [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno Philippe Mathieu-Daudé
@ 2019-03-03 1:12 ` Eric Blake
2019-03-03 2:00 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 6+ messages in thread
From: Eric Blake @ 2019-03-03 1:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Thomas Huth, qemu-trivial, Markus Armbruster, Paolo Bonzini
On 3/2/19 4:38 PM, Philippe Mathieu-Daudé wrote:
> Since 552375088a8, error_set_errno() calls error_setv() which
> already protect errno for clobbering.
> Remove the now unnecessary saved_errno.
>
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> util/error.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/util/error.c b/util/error.c
> index 934a78e1b1..0402fa1b9d 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -101,14 +101,11 @@ void error_setg_errno_internal(Error **errp,
> int os_errno, const char *fmt, ...)
> {
> va_list ap;
> - int saved_errno = errno;
>
> va_start(ap, fmt);
> error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap,
> os_errno != 0 ? strerror(os_errno) : NULL);
> va_end(ap);
> -
> - errno = saved_errno;
NACK. strerror() can clobber errno, so you still need to restore
saved_errno, regardless of what error_setv() does internally.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno
2019-03-03 1:12 ` Eric Blake
@ 2019-03-03 2:00 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-03-03 2:00 UTC (permalink / raw)
To: Eric Blake, qemu-devel
Cc: Thomas Huth, qemu-trivial, Markus Armbruster, Paolo Bonzini
On 3/3/19 2:12 AM, Eric Blake wrote:
> On 3/2/19 4:38 PM, Philippe Mathieu-Daudé wrote:
>> Since 552375088a8, error_set_errno() calls error_setv() which
>> already protect errno for clobbering.
>> Remove the now unnecessary saved_errno.
>>
>> Suggested-by: Thomas Huth <thuth@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> util/error.c | 3 ---
>> 1 file changed, 3 deletions(-)
>>
>> diff --git a/util/error.c b/util/error.c
>> index 934a78e1b1..0402fa1b9d 100644
>> --- a/util/error.c
>> +++ b/util/error.c
>> @@ -101,14 +101,11 @@ void error_setg_errno_internal(Error **errp,
>> int os_errno, const char *fmt, ...)
>> {
>> va_list ap;
>> - int saved_errno = errno;
>>
>> va_start(ap, fmt);
>> error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap,
>> os_errno != 0 ? strerror(os_errno) : NULL);
>> va_end(ap);
>> -
>> - errno = saved_errno;
>
> NACK. strerror() can clobber errno, so you still need to restore
> saved_errno, regardless of what error_setv() does internally.
Oops, I thought only strerror_r() would change errno, but checking the
man page I now see you are right:
POSIX.1-2001 and POSIX.1-2008 require that a successful call to
strerror() or strerror_l() shall leave errno unchanged, and note
that, since no function return value is reserved to indicate an
error, an application that wishes to check for errors should
initialize errno to zero before the call, and then check errno
after the call.
Thanks for catching that!
Phil.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup
2019-03-02 22:38 [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 1/2] util/error: Remove an unnecessary NULL check Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno Philippe Mathieu-Daudé
@ 2019-03-04 15:36 ` Markus Armbruster
2 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2019-03-04 15:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Thomas Huth, qemu-trivial, Michael Tokarev,
Laurent Vivier, Paolo Bonzini
Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> Trivial cleanups suggested by Daniel and Thomas.
>
> Philippe Mathieu-Daudé (2):
> util/error: Remove an unnecessary NULL check
> util/error: Remove unnecessary saved_errno
Queuing PATCH 1/2, thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-03-04 15:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-02 22:38 [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 1/2] util/error: Remove an unnecessary NULL check Philippe Mathieu-Daudé
2019-03-02 22:38 ` [Qemu-devel] [PATCH 2/2] util/error: Remove unnecessary saved_errno Philippe Mathieu-Daudé
2019-03-03 1:12 ` Eric Blake
2019-03-03 2:00 ` Philippe Mathieu-Daudé
2019-03-04 15:36 ` [Qemu-devel] [PATCH 0/2] util/error: Trivial cleanup Markus Armbruster
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).