From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: Upinder Malhi <umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH for-next 4/9] IB/usnic: Fix error handling with IS_ERR_OR_NULL
Date: Sat, 21 Dec 2013 11:00:09 +0100 [thread overview]
Message-ID: <52B566A9.1080908@acm.org> (raw)
In-Reply-To: <1387298917-7365-5-git-send-email-umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
On 12/17/13 17:48, Upinder Malhi wrote:
> Errors with IS_ERR_OR_NULL are not handleded correctly in few places
> in usNIC. This patch remedies that.
>
> Signed-off-by: Upinder Malhi <umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
> ---
> drivers/infiniband/hw/usnic/usnic_ib_main.c | 10 ++++++----
> drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 2 +-
> 2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/infiniband/hw/usnic/usnic_ib_main.c b/drivers/infiniband/hw/usnic/usnic_ib_main.c
> index 4d8cadc..7200861 100644
> --- a/drivers/infiniband/hw/usnic/usnic_ib_main.c
> +++ b/drivers/infiniband/hw/usnic/usnic_ib_main.c
> @@ -398,13 +398,14 @@ static struct usnic_ib_dev *usnic_ib_discover_pf(struct usnic_vnic *vnic)
>
> us_ibdev = usnic_ib_device_add(parent_pci);
> if (IS_ERR_OR_NULL(us_ibdev)) {
> - us_ibdev = ERR_PTR(-EINVAL);
> + us_ibdev = (us_ibdev) ? us_ibdev : ERR_PTR(-EFAULT);
> goto out;
> }
>
> err = usnic_ib_sysfs_register_usdev(us_ibdev);
> if (err) {
> usnic_ib_device_remove(us_ibdev);
> + us_ibdev = ERR_PTR(err);
> goto out;
> }
>
> @@ -459,9 +460,10 @@ int usnic_ib_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> }
>
> pf = usnic_ib_discover_pf(vf->vnic);
> - if (!pf) {
> - usnic_err("Failed to discover pf of vnic %s with err%d\n",
> - pci_name(pdev), err);
> + if (IS_ERR_OR_NULL(pf)) {
> + usnic_err("Failed to discover pf of vnic %s with err%ld\n",
> + pci_name(pdev), PTR_ERR(pf));
> + err = (pf ? PTR_ERR(pf) : -EFAULT);
> goto out_clean_vnic;
> }
>
> diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> index d305e4e..e19ca90 100644
> --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
> @@ -574,7 +574,7 @@ struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,
> mr->umem = usnic_uiom_reg_get(to_upd(pd)->umem_pd, start, length,
> access_flags, 0);
> if (IS_ERR_OR_NULL(mr->umem)) {
> - err = PTR_ERR(mr->umem);
> + err = (mr->umem) ? PTR_ERR(mr->umem) : -EFAULT;
> goto err_free;
> }
Three out of four of the above changes introduce superfluous
parentheses. Please do not introduce superfluous parentheses that do not
improve readability.
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-12-21 10:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-17 16:48 [PATCH for-next 0/9] IB/usnic: Fix kbuild robot, sparse and smatch errs Upinder Malhi
[not found] ` <1387298917-7365-1-git-send-email-umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2013-12-17 16:48 ` [PATCH for-next 1/9] IB/usnic: Fix stack frame size exceed warnings Upinder Malhi
2013-12-17 16:48 ` [PATCH for-next 2/9] IB/usnic: Fix format not a string literal warnings Upinder Malhi
[not found] ` <1387298917-7365-3-git-send-email-umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2013-12-21 9:58 ` Bart Van Assche
[not found] ` <52B56634.1020300-HInyCGIudOg@public.gmane.org>
2014-01-07 22:03 ` Upinder Malhi (umalhi)
2013-12-17 16:48 ` [PATCH for-next 3/9] IB/usnic: Make usNIC built depend on Intel IOMMU Upinder Malhi
2013-12-17 16:48 ` [PATCH for-next 4/9] IB/usnic: Fix error handling with IS_ERR_OR_NULL Upinder Malhi
[not found] ` <1387298917-7365-5-git-send-email-umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2013-12-21 10:00 ` Bart Van Assche [this message]
[not found] ` <52B566A9.1080908-HInyCGIudOg@public.gmane.org>
2014-01-07 22:03 ` Upinder Malhi (umalhi)
[not found] ` <3A32A946-EB43-4609-A04A-3BB846C442DB-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2014-01-08 0:11 ` Upinder Malhi (umalhi)
2013-12-17 16:48 ` [PATCH for-next 5/9] IB/usnic: Change BUG_ON to WARN_ON Upinder Malhi
[not found] ` <1387298917-7365-6-git-send-email-umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2013-12-21 10:04 ` Bart Van Assche
[not found] ` <52B56799.2010306-HInyCGIudOg@public.gmane.org>
2014-01-07 22:05 ` Upinder Malhi (umalhi)
2013-12-17 16:48 ` [PATCH for-next 6/9] IB/usnic: Initialize all of the data returned to userspace Upinder Malhi
2013-12-17 16:48 ` [PATCH for-next 7/9] IB/usnic: Fix printk format warnings Upinder Malhi
[not found] ` <1387298917-7365-8-git-send-email-umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2013-12-21 10:07 ` Bart Van Assche
[not found] ` <52B56847.5070209-HInyCGIudOg@public.gmane.org>
2014-01-07 22:07 ` Upinder Malhi (umalhi)
2013-12-17 16:48 ` [PATCH for-next 8/9] IB/usnic: Remove duplicate and unnecessary consts Upinder Malhi
2013-12-17 16:48 ` [PATCH for-next 9/9] IB/usnic: Fix sparse should be static warnings Upinder Malhi
[not found] ` <1387298917-7365-10-git-send-email-umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2013-12-21 10:09 ` Bart Van Assche
[not found] ` <52B568CB.2070804-HInyCGIudOg@public.gmane.org>
2014-01-07 22:14 ` Upinder Malhi (umalhi)
2013-12-20 20:28 ` [PATCH for-next 0/9] IB/usnic: Fix kbuild robot, sparse and smatch errs Upinder Malhi (umalhi)
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=52B566A9.1080908@acm.org \
--to=bvanassche-hinycgiudog@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
/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