From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yf1GT-0000mI-NY for qemu-devel@nongnu.org; Mon, 06 Apr 2015 03:16:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yf1GQ-00083x-J6 for qemu-devel@nongnu.org; Mon, 06 Apr 2015 03:16:09 -0400 Received: from mail-bn1on0143.outbound.protection.outlook.com ([157.56.110.143]:33466 helo=na01-bn1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yf1GQ-00083j-Bx for qemu-devel@nongnu.org; Mon, 06 Apr 2015 03:16:06 -0400 Message-ID: <55223284.3090501@freescale.com> Date: Mon, 6 Apr 2015 10:15:16 +0300 From: Purcareata Bogdan MIME-Version: 1.0 References: <1428058914-32050-1-git-send-email-bogdan.purcareata@freescale.com> <551EA099.4070702@redhat.com> <551EA74F.5030906@msgid.tls.msk.ru> In-Reply-To: <551EA74F.5030906@msgid.tls.msk.ru> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] nbd/trivial: fix type cast for ioctl List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev , Paolo Bonzini , Bogdan Purcareata , qemu-devel@nongnu.org, qemu-stable 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 >