2018-07-12 03:05:06

by kernel test robot

[permalink] [raw]
Subject: drivers/pci/controller/pci-tegra.c:1132:1-3: WARNING: PTR_ERR_OR_ZERO can be used

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c25c74b7476e27180e9b76840e963e542023f118
commit: 6e0832fa432ec99c94caee733c8f5851cf85560b PCI: Collect all native drivers under drivers/pci/controller/
date: 5 weeks ago


coccinelle warnings: (new ones prefixed by >>)

>> drivers/pci/controller/pci-tegra.c:1132:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


2018-07-12 03:05:08

by Fengguang Wu

[permalink] [raw]
Subject: [PATCH] PCI: fix ptr_ret.cocci warnings

From: kbuild test robot <[email protected]>

drivers/pci/controller/pci-tegra.c:1132:1-3: WARNING: PTR_ERR_OR_ZERO can be used


Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

Fixes: 6e0832fa432e ("PCI: Collect all native drivers under drivers/pci/controller/")
CC: Shawn Lin <[email protected]>
Signed-off-by: kbuild test robot <[email protected]>
---

pci-tegra.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -1129,10 +1129,7 @@ static int tegra_pcie_resets_get(struct
return PTR_ERR(pcie->afi_rst);

pcie->pcie_xrst = devm_reset_control_get_exclusive(dev, "pcie_x");
- if (IS_ERR(pcie->pcie_xrst))
- return PTR_ERR(pcie->pcie_xrst);
-
- return 0;
+ return PTR_ERR_OR_ZERO(pcie->pcie_xrst);
}

static int tegra_pcie_phys_get_legacy(struct tegra_pcie *pcie)

2018-09-18 14:20:50

by Lorenzo Pieralisi

[permalink] [raw]
Subject: Re: [PATCH] PCI: fix ptr_ret.cocci warnings

On Thu, Jul 12, 2018 at 07:30:41AM +0800, kbuild test robot wrote:
> From: kbuild test robot <[email protected]>
>
> drivers/pci/controller/pci-tegra.c:1132:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>
>
> Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
>
> Generated by: scripts/coccinelle/api/ptr_ret.cocci
>
> Fixes: 6e0832fa432e ("PCI: Collect all native drivers under drivers/pci/controller/")
> CC: Shawn Lin <[email protected]>
> Signed-off-by: kbuild test robot <[email protected]>
> ---
>
> pci-tegra.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)

Thierry,

are you OK with this change ? I will remove the Fixes: tag since
this does not fix anything AFAICS.

Lorenzo

> --- a/drivers/pci/controller/pci-tegra.c
> +++ b/drivers/pci/controller/pci-tegra.c
> @@ -1129,10 +1129,7 @@ static int tegra_pcie_resets_get(struct
> return PTR_ERR(pcie->afi_rst);
>
> pcie->pcie_xrst = devm_reset_control_get_exclusive(dev, "pcie_x");
> - if (IS_ERR(pcie->pcie_xrst))
> - return PTR_ERR(pcie->pcie_xrst);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(pcie->pcie_xrst);
> }
>
> static int tegra_pcie_phys_get_legacy(struct tegra_pcie *pcie)

2018-09-18 14:48:40

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH] PCI: fix ptr_ret.cocci warnings

On Tue, Sep 18, 2018 at 03:18:38PM +0100, Lorenzo Pieralisi wrote:
> On Thu, Jul 12, 2018 at 07:30:41AM +0800, kbuild test robot wrote:
> > From: kbuild test robot <[email protected]>
> >
> > drivers/pci/controller/pci-tegra.c:1132:1-3: WARNING: PTR_ERR_OR_ZERO can be used
> >
> >
> > Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
> >
> > Generated by: scripts/coccinelle/api/ptr_ret.cocci
> >
> > Fixes: 6e0832fa432e ("PCI: Collect all native drivers under drivers/pci/controller/")
> > CC: Shawn Lin <[email protected]>
> > Signed-off-by: kbuild test robot <[email protected]>
> > ---
> >
> > pci-tegra.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
>
> Thierry,
>
> are you OK with this change ? I will remove the Fixes: tag since
> this does not fix anything AFAICS.

This has been proposed several times in the past and each time Bjorn and
I have agreed that we'd rather not merge that change. I think the
original is clearer and allows the code to be more easily extended.

I don't know if there's a way to "whitelist" certain drivers or sub-
systems where these kinds of changes are known not to be desired. Or
perhaps there's some way to trick coccinelle into not recognizing this
particular instance.

Then again, it seems wrong to have to work around over-ambitious
semantic patches...

Thierry


Attachments:
(No filename) (1.37 kB)
signature.asc (849.00 B)
Download all attachments

2018-09-18 16:31:26

by Lorenzo Pieralisi

[permalink] [raw]
Subject: Re: [PATCH] PCI: fix ptr_ret.cocci warnings

On Tue, Sep 18, 2018 at 04:47:37PM +0200, Thierry Reding wrote:
> On Tue, Sep 18, 2018 at 03:18:38PM +0100, Lorenzo Pieralisi wrote:
> > On Thu, Jul 12, 2018 at 07:30:41AM +0800, kbuild test robot wrote:
> > > From: kbuild test robot <[email protected]>
> > >
> > > drivers/pci/controller/pci-tegra.c:1132:1-3: WARNING: PTR_ERR_OR_ZERO can be used
> > >
> > >
> > > Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
> > >
> > > Generated by: scripts/coccinelle/api/ptr_ret.cocci
> > >
> > > Fixes: 6e0832fa432e ("PCI: Collect all native drivers under drivers/pci/controller/")
> > > CC: Shawn Lin <[email protected]>
> > > Signed-off-by: kbuild test robot <[email protected]>
> > > ---
> > >
> > > pci-tegra.c | 5 +----
> > > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > Thierry,
> >
> > are you OK with this change ? I will remove the Fixes: tag since
> > this does not fix anything AFAICS.
>
> This has been proposed several times in the past and each time Bjorn and
> I have agreed that we'd rather not merge that change. I think the
> original is clearer and allows the code to be more easily extended.
>
> I don't know if there's a way to "whitelist" certain drivers or sub-
> systems where these kinds of changes are known not to be desired. Or
> perhaps there's some way to trick coccinelle into not recognizing this
> particular instance.
>
> Then again, it seems wrong to have to work around over-ambitious
> semantic patches...

I agree with you and Bjorn, I will drop the patches but you have a
point. Certainly these patches aren't fixing anything unless I am
missing something obvious.

Lorenzo