qemu-stable
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-stable] [PATCH] nbd/trivial: fix type cast for ioctl


From: Michael Tokarev
Subject: Re: [Qemu-stable] [PATCH] nbd/trivial: fix type cast for ioctl
Date: Fri, 03 Apr 2015 17:44:31 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0

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.

So much for trivial... ;)

Thanks,

/mjt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]