All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: pbonzini@redhat.com, mst@redhat.com, lersek@redhat.com,
	qemu-devel@nongnu.org, dgilbert@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/7] error: De-duplicate code creating Error objects
Date: Fri, 24 Jul 2015 10:59:54 +0200	[thread overview]
Message-ID: <87oaj2c4mt.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <55B0FC5A.9010906@redhat.com> (Eric Blake's message of "Thu, 23 Jul 2015 08:38:18 -0600")

Eric Blake <eblake@redhat.com> writes:

> On 07/23/2015 08:01 AM, Markus Armbruster wrote:
>> Duplicated when commit 680d16d added error_set_errno(), and again when
>> commit 20840d4 added error_set_win32().
>> 
>> Make the original copy in error_set() reusable by factoring out
>> error_setv(), then rewrite error_set_errno() and error_set_win32() on
>> top of it.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>  util/error.c | 70 ++++++++++++++++++++++--------------------------------------
>>  1 file changed, 26 insertions(+), 44 deletions(-)
>> 
>
>>      if (os_errno != 0) {
>> -        err->msg = g_strdup_printf("%s: %s", msg1, strerror(os_errno));
>> -        g_free(msg1);
>> -    } else {
>> -        err->msg = msg1;
>> +        msg = (*errp)->msg;
>> +        (*errp)->msg = g_strdup_printf("%s: %s", msg, strerror(os_errno));
>
> Unrelated comment, so doesn't change R-b:
>
> strerror() is not required to be thread-safe, and can return NULL on
> error.  Do we care?

Quoting strerror(3):

       POSIX.1-2001 permits strerror() to set errno if the call
       encounters an error, but does not specify what value should be
       returned as the function result in the event of an error.  On
       some systems, strerror() returns NULL if the error number is
       unknown.  On other systems, strerror() returns a string something
       like "Error nnn occurred" and sets errno to EINVAL if the error
       number is unknown.  C99 and POSIX.1-2008 require the return value
       to be non-NULL.

We already rely on strerror() behaving nicely in many, many places.

Let's not start worrying about rotten, NULL-returning implementations
until we run into one.

I don't want to hand-wave thread safety worries away similarly.
However, this patch doesn't add strerror() uses.  If we want to discuss
the existing potential problems, I feel we should start a new thread.

  reply	other threads:[~2015-07-24  8:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23 14:01 [Qemu-devel] [PATCH v2 0/7] error: On abort, report where the error was created Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 1/7] error: De-duplicate code creating Error objects Markus Armbruster
2015-07-23 14:38   ` Eric Blake
2015-07-24  8:59     ` Markus Armbruster [this message]
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 2/7] error: Make error_setg() a function Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 3/7] qga: Clean up unnecessarily dirty casts Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 4/7] qga/vss-win32: Document the DLL requires non-null errp Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 5/7] error: error_set_errno() is unused, drop Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 6/7] error: Revamp interface documentation Markus Armbruster
2015-07-28 11:31   ` Dr. David Alan Gilbert
2015-07-29  7:23     ` Markus Armbruster
2015-07-29 18:32       ` Dr. David Alan Gilbert
2015-07-30  6:58         ` Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 7/7] error: On abort, report where the error was created Markus Armbruster
2015-07-23 14:47   ` Eric Blake
2015-07-24  8:14     ` Laszlo Ersek
2015-07-24  9:02     ` Markus Armbruster

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=87oaj2c4mt.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --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.