All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Christian Schoenebeck <qemu_oss@crudebyte.com>
Cc: qemu-devel@nongnu.org, "Nikita Ivanov" <nivanov@cloudlinux.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Greg Kurz" <groug@kaod.org>, "Jason Wang" <jasowang@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Konstantin Kostiuk" <kkostiuk@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v2 1/2] Refactoring: refactor TFR() macro to RETRY_ON_EINTR()
Date: Thu, 13 Oct 2022 08:33:13 +0200	[thread overview]
Message-ID: <87a6601bdi.fsf@pond.sub.org> (raw)
In-Reply-To: <3046525.4nXOIBtuzV@silver> (Christian Schoenebeck's message of "Wed, 12 Oct 2022 18:08:39 +0200")

Christian Schoenebeck <qemu_oss@crudebyte.com> writes:

> On Mittwoch, 12. Oktober 2022 14:28:23 CEST Nikita Ivanov wrote:
>> Rename macro name to more transparent one and refactor
>> it to expression.
>> 
>> Signed-off-by: Nikita Ivanov <nivanov@cloudlinux.com>

[...]

>> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
>> index b1c161c035..a470905475 100644
>> --- a/include/qemu/osdep.h
>> +++ b/include/qemu/osdep.h
>> @@ -243,7 +243,13 @@ void QEMU_ERROR("code path is reachable")
>>  #define ESHUTDOWN 4099
>>  #endif
>> 
>> -#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
>> +#define RETRY_ON_EINTR(expr) \
>> +    (__extension__                                          \
>> +        ({ typeof(expr) __result;                               \
>> +           do {                                             \
>> +                __result = (typeof(expr)) (expr);         \
>
> Not a big deal, but as Peter already pointed out in previous version: you 
> could drop the type cast in this particular form here.

Yes, please.

> glibc's TEMP_FAILURE_RETRY() version needs the cast as it uses `long int` as 
> hard coded type for the result variable, whereas this version here uses a 
> generic approach by declaring the result variable already exactly with the 
> type the passed expression evaluates to, so the cast is redundant in this 
> version here.
>
>> +           } while (__result == -1L && errno == EINTR);     \
>> +           __result; }))
>> 
>>  /* time_t may be either 32 or 64 bits depending on the host OS, and
>>   * can be either signed or unsigned, so we can't just hardcode a

[...]



      reply	other threads:[~2022-10-13  6:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12 12:28 [PATCH v2 1/2] Refactoring: refactor TFR() macro to RETRY_ON_EINTR() Nikita Ivanov
2022-10-12 14:21 ` Marc-André Lureau
2022-10-12 16:08 ` Christian Schoenebeck
2022-10-13  6:33   ` Markus Armbruster [this message]

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=87a6601bdi.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=groug@kaod.org \
    --cc=jasowang@redhat.com \
    --cc=kkostiuk@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=nivanov@cloudlinux.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    /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.