[Top][All Lists]

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

Re: [Qemu-devel] [PATCH] osdep: Deal with TIME_MAX and OpenBSD 64-bit ti

From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] osdep: Deal with TIME_MAX and OpenBSD 64-bit time_t
Date: Thu, 23 Nov 2017 15:31:14 +0000

On 6 November 2017 at 17:41, Paolo Bonzini <address@hidden> wrote:
> What about
> #define type_max(t)                   \
>     ((t) -1 > 0                       \
>      ? (t)~0                          \
>      : (((t)1) <<                     \
>          (sizeof(t) * 8 - 1)) - 1)    \
> #define TIME_MAX type_max(time_t)
> ?  We don't need it to be a cpp constant, do we?  Or if we did, we could
> assume it to be signed, it's enough for the three users.

GCC doesn't like this phrasing, it complains
qmp.c: In function ‘qmp_expire_password’:
qmp.c:334:89: error: integer overflow in expression [-Werror=overflow]

because of the shift into the sign bit. Instead we can borrow the
TYPE_MAXIMUM macro from gnulib, which uses basically the same
approach but avoids the UB and the compiler warning. I'll send
a patch in a bit.

-- PMM

reply via email to

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