Message ID | 20190816092437.31846-4-efremov@linux.com (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
Series | Add definition for the number of standard PCI BARs | expand |
On Fri, 16 Aug 2019, Denis Efremov wrote: > Refactor loops to use 'i < PCI_STD_NUM_BARS' instead of > 'i <= PCI_STD_RESOURCE_END'. Please describe the WHY not the WHAT. I can see the WHAT from the patch itself, but I can't figure out WHY. Thanks, tglx
On Fri, Aug 16, 2019 at 11:32:41AM +0200, Thomas Gleixner wrote: > On Fri, 16 Aug 2019, Denis Efremov wrote: > > > Refactor loops to use 'i < PCI_STD_NUM_BARS' instead of > > 'i <= PCI_STD_RESOURCE_END'. > > Please describe the WHY not the WHAT. I can see the WHAT from the patch > itself, but I can't figure out WHY. Good point; the WHY is to use idiomatic C style and avoid the fencepost error of using "i < PCI_STD_RESOURCE_END" when "i <= PCI_STD_RESOURCE_END" is required, e.g., 2f686f1d9bee ("PCI: Correct PCI_STD_RESOURCE_END usage") Denis, can you include something along those lines in the next version?
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 9acab6ac28f5..1e59df041456 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -135,7 +135,7 @@ static void pcibios_fixup_device_resources(struct pci_dev *dev) * resource so the kernel doesn't attempt to assign * it later on in pci_assign_unassigned_resources */ - for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) { + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { bar_r = &dev->resource[bar]; if (bar_r->start == 0 && bar_r->end != 0) { bar_r->flags = 0;
Refactor loops to use 'i < PCI_STD_NUM_BARS' instead of 'i <= PCI_STD_RESOURCE_END'. Signed-off-by: Denis Efremov <efremov@linux.com> --- arch/x86/pci/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)