> Date: Fri, 15 Aug 2025 22:42:29 +0200 > From: Mark Kettenis <mark.kette...@xs4all.nl> > > > Date: Fri, 15 Aug 2025 14:17:17 -0600 > > From: Tom Rini <tr...@konsulko.com> > > Hi Tom, > > > On Wed, Aug 06, 2025 at 12:30:00PM +0100, Andrew Goodbody wrote: > > > 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.goodb...@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; > > > > I don't think this is right because with this applied: > > apple_m1 : all -1425 rodata -101 text -1324 > > u-boot: add: 0/-3, grow: 0/-1 bytes: 0/-1324 (-1324) > > function old new > > delta > > gpio_request_by_name_nodev 12 - > > -12 > > devfdt_get_addr_name 80 - > > -80 > > _gpio_request_by_name_nodev 156 - > > -156 > > apple_pcie_probe 1204 128 > > -1076 > > > > So the probe becomes an almost nothing func (that I assume returns > > early) and we can discard some other functions. > > The i++ is in the wrong place. > > The variable is only really used to identify the port that is failing > to initialize. Doesn't happen under normal circumstances, and if it > happens it is probably better to identify the port by its "reg" > property. I'll try to come up with a diff for that.
Just sent a diff for that to the list.