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