qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/3] int128.h: Avoid undefined behaviours involving signed arithmetic
Date: Sun, 06 Apr 2014 11:09:23 +0400	[thread overview]
Message-ID: <5340FDA3.1080902@msgid.tls.msk.ru> (raw)
In-Reply-To: <1396019577-2013-3-git-send-email-peter.maydell@linaro.org>

28.03.2014 19:12, Peter Maydell wrote:
> Add casts when we're performing arithmetic on the .hi parts of an
> Int128, to avoid undefined behaviour.
[]
>  static inline Int128 int128_sub(Int128 a, Int128 b)
>  {
> -    return (Int128){ a.lo - b.lo, a.hi - b.hi - (a.lo < b.lo) };
> +    return (Int128){ a.lo - b.lo, (uint64_t)a.hi - b.hi - (a.lo < b.lo) };

What was wrong with this one?  I don't think casting to unsigned here is
a good idea.

Thanks,

/mjt

  reply	other threads:[~2014-04-06  7:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28 15:12 [Qemu-devel] [PATCH 0/3] More fixes for undefined behaviour Peter Maydell
2014-03-28 15:12 ` [Qemu-devel] [PATCH 1/3] hw/ide/ahci.c: Avoid shift left into sign bit Peter Maydell
2014-04-06  7:10   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-03-28 15:12 ` [Qemu-devel] [PATCH 2/3] int128.h: Avoid undefined behaviours involving signed arithmetic Peter Maydell
2014-04-06  7:09   ` Michael Tokarev [this message]
2014-04-06 10:18     ` [Qemu-devel] [Qemu-trivial] " Peter Maydell
2014-04-06 14:13       ` Michael Tokarev
2014-04-06 14:58         ` Peter Maydell
2014-04-06 15:27         ` Peter Maydell
2014-04-07 14:25           ` Richard Henderson
2014-04-07 14:47             ` Peter Maydell
2014-04-07 15:49               ` Markus Armbruster
2014-04-07 14:56       ` Avi Kivity
2014-04-07 15:17         ` Peter Maydell
2014-04-07 15:22           ` Avi Kivity
2014-03-28 15:12 ` [Qemu-devel] [PATCH 3/3] xbzrle.c: Avoid undefined behaviour with " Peter Maydell
2014-04-06 14:15   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev

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=5340FDA3.1080902@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).