From: Peter Maydell <peter.maydell@linaro.org>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] bitops: fix types
Date: Sun, 8 Jul 2012 20:32:59 +0100 [thread overview]
Message-ID: <CAFEAcA_oTrA2Z+W2PVY40CA=rM_+=Ru+knbEQPWMrPnq4OmmHw@mail.gmail.com> (raw)
In-Reply-To: <CAAu8pHtSBvN6fjgTUh=y1niR_r0tZJoA1qssgt8Byb6UUEUmjw@mail.gmail.com>
On 8 July 2012 20:12, Blue Swirl <blauwirbel@gmail.com> wrote:
> On Sun, Jul 8, 2012 at 6:54 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 8 July 2012 19:32, Blue Swirl <blauwirbel@gmail.com> wrote:
>>> On Sun, Jul 8, 2012 at 2:04 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>>>> On 8 July 2012 13:12, <blauwirbel@gmail.com> wrote:
>>>>> -static inline uint64_t deposit64(uint64_t value, int start, int length,
>>>>> - uint64_t fieldval)
>>>>> +static inline uint64_t deposit64(uint64_t value, unsigned int start,
>>>>> + unsigned int length, uint64_t fieldval)
>>>>> {
>>>>> uint64_t mask;
>>>>> - assert(start >= 0 && length > 0 && length <= 64 - start);
>>>>> + assert(length > 0 && length <= 64 - start);
>>>>
>>>> This breaks the assertion (consider the case of start == UINT_MAX
>>>> and length == 64).
>>>
>>> The original is equally buggy in other cases since there is no bound
>>> check for the upper limit.
>>
>> For what upper limit? Overlong length or start should both be caught
>> by the third condition in the signed case.
>
> Nice. Why is it written like that, I'd use
> start + length <= 64?
That would fail to handle the case of start == length == INT_MAX.
-- PMM
next prev parent reply other threads:[~2012-07-08 19:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-08 12:12 [Qemu-devel] [PATCH] bitops: fix types blauwirbel
2012-07-08 14:04 ` Peter Maydell
2012-07-08 18:32 ` Blue Swirl
2012-07-08 18:54 ` Peter Maydell
2012-07-08 19:12 ` Blue Swirl
2012-07-08 19:32 ` Peter Maydell [this message]
2012-07-08 19:39 ` Blue Swirl
2012-07-08 19:51 ` Peter Maydell
2012-07-08 22:41 ` Peter Maydell
2012-07-09 7:38 ` Markus Armbruster
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='CAFEAcA_oTrA2Z+W2PVY40CA=rM_+=Ru+knbEQPWMrPnq4OmmHw@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=blauwirbel@gmail.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).