* [PATCH] IB/usnic: delete unneeded IS_ERR test
@ 2015-12-19 20:48 Julia Lawall
2015-12-22 15:29 ` Dave Goodell
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2015-12-19 20:48 UTC (permalink / raw)
To: Christian Benvenuti
Cc: kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Dave Goodell,
Doug Ledford, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
kzalloc doesn't return ERR_PTR, so there is no need to test for it.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression x,e;
@@
* x = kzalloc(...)
... when != x = e
* IS_ERR_OR_NULL(x)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
---
drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
index f8e3211..20f53e5 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -625,8 +625,8 @@ struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,
virt_addr, length);
mr = kzalloc(sizeof(*mr), GFP_KERNEL);
- if (IS_ERR_OR_NULL(mr))
- return ERR_PTR(mr ? PTR_ERR(mr) : -ENOMEM);
+ if (!mr)
+ return ERR_PTR(-ENOMEM);
mr->umem = usnic_uiom_reg_get(to_upd(pd)->umem_pd, start, length,
access_flags, 0);
--
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/usnic: delete unneeded IS_ERR test
2015-12-19 20:48 [PATCH] IB/usnic: delete unneeded IS_ERR test Julia Lawall
@ 2015-12-22 15:29 ` Dave Goodell
2015-12-23 16:11 ` Doug Ledford
0 siblings, 1 reply; 3+ messages in thread
From: Dave Goodell @ 2015-12-22 15:29 UTC (permalink / raw)
To: Julia Lawall
Cc: Christian Benvenuti, kernel-janitors, Doug Ledford, Sean Hefty,
Hal Rosenstock, linux-rdma, linux-kernel, Nelson Escobar
[copying Nelson too]
On Sat, Dec 19, 2015 at 09:48:59PM +0100, Julia Lawall wrote:
> kzalloc doesn't return ERR_PTR, so there is no need to test for it.
>
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression x,e;
> @@
>
> * x = kzalloc(...)
> ... when != x = e
> * IS_ERR_OR_NULL(x)
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Dave Goodell <dgoodell@cisco.com>
-Dave
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/usnic: delete unneeded IS_ERR test
2015-12-22 15:29 ` Dave Goodell
@ 2015-12-23 16:11 ` Doug Ledford
0 siblings, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2015-12-23 16:11 UTC (permalink / raw)
To: Dave Goodell, Julia Lawall
Cc: Christian Benvenuti, kernel-janitors, Sean Hefty, Hal Rosenstock,
linux-rdma, linux-kernel, Nelson Escobar
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
On 12/22/2015 10:29 AM, Dave Goodell wrote:
> [copying Nelson too]
>
> On Sat, Dec 19, 2015 at 09:48:59PM +0100, Julia Lawall wrote:
>> kzalloc doesn't return ERR_PTR, so there is no need to test for it.
>>
>> The semantic match that finds this problem is as follows:
>> (http://coccinelle.lip6.fr/)
>>
>> // <smpl>
>> @@
>> expression x,e;
>> @@
>>
>> * x = kzalloc(...)
>> ... when != x = e
>> * IS_ERR_OR_NULL(x)
>> // </smpl>
>>
>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Reviewed-by: Dave Goodell <dgoodell@cisco.com>
>
> -Dave
>
Thanks, applied.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: 0E572FDD
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-23 16:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-19 20:48 [PATCH] IB/usnic: delete unneeded IS_ERR test Julia Lawall
2015-12-22 15:29 ` Dave Goodell
2015-12-23 16:11 ` Doug Ledford
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).