From: Peter Maydell <peter.maydell@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrange" <berrange@redhat.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Brad Smith <brad@comstyle.com>
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 [thread overview]
Message-ID: <CAFEAcA8DDdPUZRoA0dRVpP1vr9f7VdLmbvr19Pu9kC67Hd2j9w@mail.gmail.com> (raw)
In-Reply-To: <7733d617-0e56-acdc-ad6d-aafce0c7160d@redhat.com>
On 6 November 2017 at 17:41, Paolo Bonzini <pbonzini@redhat.com> 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.
thanks
-- PMM
next prev parent reply other threads:[~2017-11-23 15:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 0:56 [Qemu-devel] [PATCH] osdep: Deal with TIME_MAX and OpenBSD 64-bit time_t Brad Smith
2017-11-06 10:51 ` Peter Maydell
2017-11-06 11:26 ` Daniel P. Berrange
2017-11-06 17:41 ` Paolo Bonzini
2017-11-23 15:31 ` Peter Maydell [this message]
2017-11-06 17:21 ` Kamil Rytarowski
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=CAFEAcA8DDdPUZRoA0dRVpP1vr9f7VdLmbvr19Pu9kC67Hd2j9w@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=berrange@redhat.com \
--cc=brad@comstyle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).