cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 08/10] dlm: Use kcalloc() in two functions
Date: Sat, 6 May 2017 10:45:50 +0200	[thread overview]
Message-ID: <01b774a8-5f5a-8939-2b57-1fc99a864d11@users.sourceforge.net> (raw)
In-Reply-To: <4bd895d7-9448-928d-1e4c-42326ce20607@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 6 May 2017 09:34:53 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus reuse the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences
  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>
---
 fs/dlm/member.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/dlm/member.c b/fs/dlm/member.c
index 89257699d4e4..92c601a11e38 100644
--- a/fs/dlm/member.c
+++ b/fs/dlm/member.c
@@ -217,8 +217,7 @@ int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int *slots_size,
 	}
 
 	array_size = max + need;
-
-	array = kzalloc(array_size * sizeof(struct dlm_slot), GFP_NOFS);
+	array = kcalloc(array_size, sizeof(*array), GFP_NOFS);
 	if (!array)
 		return -ENOMEM;
 
@@ -491,8 +490,7 @@ void dlm_lsop_recover_done(struct dlm_ls *ls)
 		return;
 
 	num = ls->ls_num_nodes;
-
-	slots = kzalloc(num * sizeof(struct dlm_slot), GFP_KERNEL);
+	slots = kcalloc(num, sizeof(*slots), GFP_KERNEL);
 	if (!slots)
 		return;
 
-- 
2.12.2



  parent reply	other threads:[~2017-05-06  8:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-06  8:34 [Cluster-devel] [PATCH 00/10] fs-DLM: Fine-tuning for several function implementations SF Markus Elfring
2017-05-06  8:36 ` [Cluster-devel] [PATCH 01/10] dlm: Replace six seq_puts() calls by seq_putc() SF Markus Elfring
2017-05-06  8:38 ` [Cluster-devel] [PATCH 02/10] dlm: Add spaces for better code readability SF Markus Elfring
2017-05-06  8:39 ` [Cluster-devel] [PATCH 03/10] dlm: Improve a size determination in table_seq_start() SF Markus Elfring
2017-05-06  8:40 ` [Cluster-devel] [PATCH 04/10] dlm: Use kcalloc() in dlm_scan_waiters() SF Markus Elfring
2017-05-06  8:41 ` [Cluster-devel] [PATCH 05/10] dlm: Improve a size determination in dlm_recover_waiters_pre() SF Markus Elfring
2017-05-06  8:43 ` [Cluster-devel] [PATCH 06/10] dlm: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-05-06  8:44 ` [Cluster-devel] [PATCH 07/10] dlm: Use kmalloc_array() in make_member_array() SF Markus Elfring
2017-05-06  8:45 ` SF Markus Elfring [this message]
2017-05-06  8:47 ` [Cluster-devel] [PATCH 09/10] dlm: Improve a size determination in two functions SF Markus Elfring
2017-05-06  8:48 ` [Cluster-devel] [PATCH 10/10] dlm: Delete an unnecessary variable initialisation in dlm_ls_start() SF Markus Elfring
2017-05-08 20:08 ` [Cluster-devel] [PATCH 00/10] fs-DLM: Fine-tuning for several function implementations Bob Peterson

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=01b774a8-5f5a-8939-2b57-1fc99a864d11@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    /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).