qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 1/2] Refactoring: refactor TFR() macro to RETRY_ON_EINTR()


From: Markus Armbruster
Subject: Re: [PATCH v2 1/2] Refactoring: refactor TFR() macro to RETRY_ON_EINTR()
Date: Thu, 13 Oct 2022 08:33:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

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 via email to

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