From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baHX8-0004KE-SF for qemu-devel@nongnu.org; Thu, 18 Aug 2016 03:14:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1baHX3-00051m-RQ for qemu-devel@nongnu.org; Thu, 18 Aug 2016 03:14:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baHX3-00051i-MN for qemu-devel@nongnu.org; Thu, 18 Aug 2016 03:14:29 -0400 From: Markus Armbruster References: <1471444747-6277-1-git-send-email-caoj.fnst@cn.fujitsu.com> <1471444747-6277-2-git-send-email-caoj.fnst@cn.fujitsu.com> Date: Thu, 18 Aug 2016 09:14:27 +0200 In-Reply-To: <1471444747-6277-2-git-send-email-caoj.fnst@cn.fujitsu.com> (Cao jin's message of "Wed, 17 Aug 2016 22:39:02 +0800") Message-ID: <87h9aift0s.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/6] msix_init: assert programming error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cao jin Cc: qemu-devel@nongnu.org, Marcel Apfelbaum , "Michael S. Tsirkin" Cao jin writes: > CC: Markus Armbruster > CC: Marcel Apfelbaum > CC: Michael S. Tsirkin > Signed-off-by: Cao jin > --- > hw/pci/msix.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/hw/pci/msix.c b/hw/pci/msix.c > index 0ec1cb1..384a29d 100644 > --- a/hw/pci/msix.c > +++ b/hw/pci/msix.c > @@ -253,9 +253,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries, > return -ENOTSUP; > } > > - if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1) { > - return -EINVAL; > - } > + assert(nentries >= 1 && nentries <= PCI_MSIX_FLAGS_QSIZE + 1); > > table_size = nentries * PCI_MSIX_ENTRY_SIZE; > pba_size = QEMU_ALIGN_UP(nentries, 64) / 8; > @@ -266,7 +264,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries, > table_offset + table_size > memory_region_size(table_bar) || > pba_offset + pba_size > memory_region_size(pba_bar) || > (table_offset | pba_offset) & PCI_MSIX_FLAGS_BIRMASK) { > - return -EINVAL; > + assert(0); > } > > cap = pci_add_capability(dev, PCI_CAP_ID_MSIX, cap_pos, MSIX_CAP_LENGTH); Please explain in the commit message why these are programming errors. If you're unsure how, give it a try in a reply to this message, and we'll hammer out something together.