2017-11-17 07:39:06

by Vasyl Gomonovych

[permalink] [raw]
Subject: [PATCH] qed: fix unnecessary call to memset cocci warnings

Use kzalloc rather than kmalloc followed by memset with 0

drivers/net/ethernet/qlogic/qed/qed_dcbx.c:1280:13-20: WARNING:
kzalloc should be used for dcbx_info, instead of kmalloc/memset
Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Signed-off-by: Vasyl Gomonovych <[email protected]>
---
drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
index 8f6ccc0c39e5..cc9e0dfcee48 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
@@ -1277,11 +1277,10 @@ static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn,
{
struct qed_dcbx_get *dcbx_info;

- dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_ATOMIC);
+ dcbx_info = kzalloc(sizeof(*dcbx_info), GFP_ATOMIC);
if (!dcbx_info)
return NULL;

- memset(dcbx_info, 0, sizeof(*dcbx_info));
if (qed_dcbx_query_params(hwfn, dcbx_info, type)) {
kfree(dcbx_info);
return NULL;
--
1.9.1


From 1584293647237006606@xxx Fri Nov 17 06:29:21 +0000 2017
X-GM-THRID: 1584176532244896356
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread


2017-11-17 06:29:21

by Vasyl Gomonovych

[permalink] [raw]
Subject: Re: [PATCH] qed: fix unnecessary call to memset cocci warnings

Sorry.

From 1584185334845273869@xxx Thu Nov 16 01:47:46 +0000 2017
X-GM-THRID: 1584176532244896356
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-16 01:47:46

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] qed: fix unnecessary call to memset cocci warnings

From: Vasyl Gomonovych <[email protected]>
Date: Wed, 15 Nov 2017 20:58:15 +0100

> @@ -1277,11 +1277,10 @@ static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn,
> {
> struct qed_dcbx_get *dcbx_info;
>
> - dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_ATOMIC);
> + dcbx_info = kzmalloc(sizeof(*dcbx_info), GFP_ATOMIC);

Thanks for not even compile testing your patch.

From 1584176532244896356@xxx Wed Nov 15 23:27:51 +0000 2017
X-GM-THRID: 1584176532244896356
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread