From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agA0a-00049E-26 for qemu-devel@nongnu.org; Wed, 16 Mar 2016 07:53:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agA0W-0008MX-0r for qemu-devel@nongnu.org; Wed, 16 Mar 2016 07:52:59 -0400 Sender: Paolo Bonzini References: <1455152067-19900-1-git-send-email-richard.weiyang@gmail.com> <56E9433C.1040503@msgid.tls.msk.ru> From: Paolo Bonzini Message-ID: <56E94914.1040803@redhat.com> Date: Wed, 16 Mar 2016 12:52:52 +0100 MIME-Version: 1.0 In-Reply-To: <56E9433C.1040503@msgid.tls.msk.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vfio/pci: replace 1 with PCI_CAP_LIST_NEXT to make code self-explain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev , Wei Yang , alex.williamson@redhat.com Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org On 16/03/2016 12:27, Michael Tokarev wrote: >> > for (tmp = pdev->config[PCI_CAPABILITY_LIST]; tmp; >> > - tmp = pdev->config[tmp + 1]) { >> > + tmp = pdev->config[tmp + PCI_CAP_LIST_NEXT]) { >> > - next = pdev->config[pos + 1]; >> > + next = pdev->config[pos + PCI_CAP_LIST_NEXT]; > Hmm. I'm not sure the new version is better, to me "+1" reads > easier than the new symbolic constant variant. > > If it were something like pdev->config[PCI_CAP_LIST_NEXT], that'd be > nice, but not "pos + PCI_CAP_LIST_NEXT". > > But again, I'm not pci config space expert and don't understand > the basics :) Each capability is a node of a linked list, and the position of the next capability is at offset 1 inside the capability (here it is at offset 1 from the tmp or pos base). I think the patch is an improvement. Paolo