Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1593566

[PATCH 5/5] IB/nes: Improve size determinations in two functions

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 5/5] IB/nes: Improve size determinations in two functions
Date 2017-03-06 19:30 +0100
Message-ID <ti5yp-3DN-5@gated-at.bofh.it> (permalink)
References <ti4VI-33v-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Mar 2017 18:12:37 +0100

Replace the specification of two data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determinations a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/nes/nes_verbs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 7764ba423c1c..5cbb62e44d84 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -678,7 +678,7 @@ static struct ib_pd *nes_alloc_pd(struct ib_device *ibdev,
 	if (err)
 		return ERR_PTR(err);
 
-	nespd = kzalloc(sizeof (struct nes_pd), GFP_KERNEL);
+	nespd = kzalloc(sizeof(*nespd), GFP_KERNEL);
 	if (!nespd) {
 		nes_free_resource(nesadapter, nesadapter->allocated_pds, pd_num);
 		return ERR_PTR(-ENOMEM);
@@ -1447,7 +1447,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev,
 	if (err)
 		return ERR_PTR(err);
 
-	nescq = kzalloc(sizeof(struct nes_cq), GFP_KERNEL);
+	nescq = kzalloc(sizeof(*nescq), GFP_KERNEL);
 	if (!nescq) {
 		nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num);
 		return ERR_PTR(-ENOMEM);
-- 
2.12.0

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] IB/nes: Fine-tuning for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-03-06 19:00 +0100
  [PATCH 4/5] IB/nes: Delete unnecessary braces SF Markus Elfring <elfring@users.sourceforge.net> - 2017-03-06 19:10 +0100
    Re: [PATCH 4/5] IB/nes: Delete unnecessary braces Joe Perches <joe@perches.com> - 2017-03-06 19:40 +0100
      [PATCH] IB/nes: Neaten nes_alloc_mw Joe Perches <joe@perches.com> - 2017-03-07 01:40 +0100
    Re: [PATCH 4/5] IB/nes: Delete unnecessary braces Julia Lawall <julia.lawall@lip6.fr> - 2017-03-06 22:40 +0100
  [PATCH 5/5] IB/nes: Improve size determinations in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-03-06 19:30 +0100

csiph-web