[PATCH] pci: apple: i needs to be initialised and used

Andrew Goodbody andrew.goodbody at linaro.org
Wed Aug 6 13:30:00 CEST 2025


In apple_pcie_probe the variable 'i' is declared and then its value
printed on an error but 'i' is not initialised nor is it made use of.
Add an initial value for 'i' and have it incremented in the for loop.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
 drivers/pci/pcie_apple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pcie_apple.c b/drivers/pci/pcie_apple.c
index 6a8e715d4b6..216b6512af1 100644
--- a/drivers/pci/pcie_apple.c
+++ b/drivers/pci/pcie_apple.c
@@ -335,7 +335,7 @@ static int apple_pcie_probe(struct udevice *dev)
 	struct apple_pcie_priv *pcie = dev_get_priv(dev);
 	fdt_addr_t addr;
 	ofnode of_port;
-	int i, ret;
+	int i = 0, ret;
 
 	pcie->hw = (struct reg_info *)dev_get_driver_data(dev);
 
@@ -353,7 +353,7 @@ static int apple_pcie_probe(struct udevice *dev)
 	INIT_LIST_HEAD(&pcie->ports);
 
 	for (of_port = ofnode_first_subnode(dev_ofnode(dev));
-	     ofnode_valid(of_port);
+	     ofnode_valid(of_port), i++;
 	     of_port = ofnode_next_subnode(of_port)) {
 		if (!ofnode_is_enabled(of_port))
 			continue;

---
base-commit: 007610da2cca405ea7739fc120d90085be4b6ac2
change-id: 20250806-pcie_apple-41863e56f57a

Best regards,
-- 
Andrew Goodbody <andrew.goodbody at linaro.org>



More information about the U-Boot mailing list