From: Purcareata Bogdan <b43198@freescale.com>
To: Michael Tokarev <mjt@tls.msk.ru>,
Paolo Bonzini <pbonzini@redhat.com>,
Bogdan Purcareata <bogdan.purcareata@freescale.com>,
qemu-devel@nongnu.org, qemu-stable <qemu-stable@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] nbd/trivial: fix type cast for ioctl
Date: Mon, 6 Apr 2015 10:15:16 +0300 [thread overview]
Message-ID: <55223284.3090501@freescale.com> (raw)
In-Reply-To: <551EA74F.5030906@msgid.tls.msk.ru>
On 03.04.2015 17:44, Michael Tokarev wrote:
> 03.04.2015 17:15, Paolo Bonzini wrote:
>> On 03/04/2015 13:01, Bogdan Purcareata wrote:
> ...
>>> - if (ioctl(fd, NBD_SET_SIZE_BLOCKS, size / (size_t)BDRV_SECTOR_SIZE) < 0) {
>>> + if (ioctl(fd, NBD_SET_SIZE_BLOCKS, (size_t)(size / BDRV_SECTOR_SIZE) < 0)) {
>>> int serrno = errno;
>
> Hmm.. I don't think this is right at all. Now we compare size_t with zero,
> the result is always false, and set error if ioctl return anything other than 0,
> including any positive value.
>
> Compare:
>
> if (ioctl(fd, NBD_SET_SIZE_BLOCKS, (size_t)(size / BDRV_SECTOR_SIZE) < 0))
> if (ioctl(fd, NBD_SET_SIZE_BLOCKS, (size_t)(size / BDRV_SECTOR_SIZE)) < 0)
>
> I think the latter is the right version.
Yes, the latter is indeed the right version. Great catch!
> So much for trivial... ;)
Me and my slippery fingers. Sorry for the mishap.
Bogdan P.
> Thanks,
>
> /mjt
>
prev parent reply other threads:[~2015-04-06 7:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 11:01 [Qemu-devel] [PATCH] nbd/trivial: fix type cast for ioctl Bogdan Purcareata
2015-04-03 14:15 ` Paolo Bonzini
2015-04-03 14:44 ` Michael Tokarev
2015-04-06 7:15 ` Purcareata Bogdan [this message]
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=55223284.3090501@freescale.com \
--to=b43198@freescale.com \
--cc=bogdan.purcareata@freescale.com \
--cc=mjt@tls.msk.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).