Christian Schoenebeck <[email protected]> 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 <[email protected]>
[...]
>> 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
[...]