From: Jacob Keller <jacob.e.keller@intel.com>
To: Hongbo Li <lihongbo22@huawei.com>, <yisen.zhuang@huawei.com>,
<salil.mehta@huawei.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] net: hns: Use IS_ERR_OR_NULL() helper function
Date: Wed, 28 Aug 2024 15:14:51 -0700 [thread overview]
Message-ID: <e238122b-5df1-451b-905a-0dfbd457dd08@intel.com> (raw)
In-Reply-To: <20240828122336.3697176-1-lihongbo22@huawei.com>
On 8/28/2024 5:23 AM, Hongbo Li wrote:
> Use the IS_ERR_OR_NULL() helper instead of open-coding a
> NULL and an error pointer checks to simplify the code and
> improve readability.
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
> drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> index f75668c47935..53e0da0bfbed 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
> @@ -734,7 +734,7 @@ hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb,
> return -ENODATA;
>
> phy = get_phy_device(mdio, addr, is_c45);
> - if (!phy || IS_ERR(phy))
> + if (IS_ERR_OR_NULL(phy))
> return -EIO;
>
This does collapse any error from get_phy_device into -EIO, when you
should specifically check and return the PTR_ERR value. I'm not sure how
useful that is, and feels like a separate cleanup.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> phy->irq = mdio->irq[addr];
next prev parent reply other threads:[~2024-08-28 22:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 12:23 [PATCH net-next] net: hns: Use IS_ERR_OR_NULL() helper function Hongbo Li
2024-08-28 22:14 ` Jacob Keller [this message]
2024-08-29 19:00 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e238122b-5df1-451b-905a-0dfbd457dd08@intel.com \
--to=jacob.e.keller@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lihongbo22@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).