Skip to contentSkip to conversation

PCI: apple: Remove redundant initialization of pointer port_pdev

PATCH In review Colin King 4 participants 7 messages Oct 12, 2021 – Oct 13, 2021

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 PCI: apple: Remove redundant initialization of pointer port_pdev

From: Colin Ian King <[email protected]>

The pointer port_pdev is being initialized with a value that is never read, it is being updated later on. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/pci/controller/pcie-apple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-apple.c +1 -1
index b4db7a065553..19fd2d38aaab 100644
@@ -634,7 +634,7 @@ static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
 {
 	struct pci_config_window *cfg = pdev->sysdata;
 	struct apple_pcie *pcie = cfg->priv;
-	struct pci_dev *port_pdev = pdev;
+	struct pci_dev *port_pdev;
 	struct apple_pcie_port *port;
 
 	/* Find the root port this device is on */
Signature · 1 line
2.32.0
#1 lore raw

It looks like

        port_pdev = pcie_find_root_port(pdev);

might've meant to read

        port_pdev = pcie_find_root_port(port_pdev);

in which case the assignment would be used. I have no strong opinions either way.

Full context for those following along at home:

```
static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
{
        struct pci_config_window *cfg = pdev->sysdata;
        struct apple_pcie *pcie = cfg->priv;
        struct pci_dev *port_pdev = pdev;
        struct apple_pcie_port *port;

        /* Find the root port this device is on */
        port_pdev = pcie_find_root_port(pdev);

        /* If finding the port itself, nothing to do */
        if (WARN_ON(!port_pdev) || pdev == port_pdev)
                return NULL;

        list_for_each_entry(port, &pcie->ports, entry) {
                if (port->idx == PCI_SLOT(port_pdev->devfn))
                        return port;
        }

        return NULL;
}
```
Quoted 28 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer port_pdev is being initialized with a value that is never read, it is being updated later on. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/pci/controller/pcie-apple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-apple.c +1 -1
index b4db7a065553..19fd2d38aaab 100644
@@ -634,7 +634,7 @@ static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
 {
 	struct pci_config_window *cfg = pdev->sysdata;
 	struct apple_pcie *pcie = cfg->priv;
-	struct pci_dev *port_pdev = pdev;
+	struct pci_dev *port_pdev;
 	struct apple_pcie_port *port;
 
 	/* Find the root port this device is on */
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Colin King

Hi Colin!

Quoted 15 lines

The pointer port_pdev is being initialized with a value that is never read, it is being updated later on. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/pci/controller/pcie-apple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-apple.c +0 -0
index b4db7a065553..19fd2d38aaab 100644

drivers/pci/controller/pcie-apple.c static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev) · line 637

Quoted 5 lines
drivers/pci/controller/pcie-apple.c +1 -1
@@ -634,7 +634,7 @@ static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
 {
 	struct pci_config_window *cfg = pdev->sysdata;
 	struct apple_pcie *pcie = cfg->priv;
-	struct pci_dev *port_pdev = pdev;
+	struct pci_dev *port_pdev;

Thank you!

Krzysztof

#3 lore raw
In reply to Colin King
Quoted 11 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer port_pdev is being initialized with a value that is never read, it is being updated later on. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/pci/controller/pcie-apple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Squashed into the commit it is fixing.

Thanks !
Lorenzo

Quoted 16 lines
drivers/pci/controller/pcie-apple.c +1 -1
index b4db7a065553..19fd2d38aaab 100644
@@ -634,7 +634,7 @@ static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
 {
 	struct pci_config_window *cfg = pdev->sysdata;
 	struct apple_pcie *pcie = cfg->priv;
-	struct pci_dev *port_pdev = pdev;
+	struct pci_dev *port_pdev;
 	struct apple_pcie_port *port;
 
 	/* Find the root port this device is on */
Signature · 1 line
2.32.0
#4 lore raw

Hi Lorenzo,

Quoted 11 lines
Quoted 9 lines

The pointer port_pdev is being initialized with a value that is never read, it is being updated later on. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/pci/controller/pcie-apple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Squashed into the commit it is fixing.

It seems the commit already landed in linux-next? [1]

[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=00723f494020aceb92f789af634fecba1477fc01

Alyssa

#5 lore raw
Quoted 12 lines · Alyssa Rosenzweig

Hi Lorenzo,

Quoted 10 lines
Quoted 9 lines

The pointer port_pdev is being initialized with a value that is never read, it is being updated later on. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/pci/controller/pcie-apple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines
Quoted 1 line

Squashed into the commit it is fixing.

It seems the commit already landed in linux-next? [1]

[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=00723f494020aceb92f789af634fecba1477fc01

I know thanks. The updated one will land in next shortly.

Lorenzo

#6 lore raw
In reply to Lorenzo Pieralisi
Quoted 7 lines · Lorenzo Pieralisi
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer port_pdev is being initialized with a value that is never read, it is being updated later on. The assignment is redundant and can be removed.

Quoted 8 lines
Quoted 5 lines

Addresses-Coverity: ("Unused value")

---
  drivers/pci/controller/pcie-apple.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Squashed into the commit it is fixing.

Thanks. Much appreciated.

Quoted 19 lines

Thanks !
Lorenzo

Quoted 16 lines
drivers/pci/controller/pcie-apple.c +1 -1
index b4db7a065553..19fd2d38aaab 100644
@@ -634,7 +634,7 @@ static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
  {
  	struct pci_config_window *cfg = pdev->sysdata;
  	struct apple_pcie *pcie = cfg->priv;
-	struct pci_dev *port_pdev = pdev;
+	struct pci_dev *port_pdev;
  	struct apple_pcie_port *port;
 
  	/* Find the root port this device is on */
Signature · 1 line
2.32.0