From: Markus Elfring <Markus.Elfring@web.de>
To: kernel-janitors@vger.kernel.org, drbd-dev@lists.linbit.com,
"Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>,
"Lars Ellenberg" <lars.ellenberg@linbit.com>,
"Philipp Reisner" <philipp.reisner@linbit.com>
Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr
Subject: [Drbd-dev] [PATCH 2/3] lru_cache: Improve two size determinations in lc_create()
Date: Wed, 29 Mar 2023 15:42:07 +0200 [thread overview]
Message-ID: <f03b9407-0336-e949-e98d-9e0ddf3bfa57@web.de> (raw)
In-Reply-To: <33226beb-4fe2-3da5-5d69-a33e683dec57@web.de>
Date: Wed, 29 Mar 2023 15:00:13 +0200
Replace the specification of data structures by pointer dereferences
as the parameter for the operator “sizeof” to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
lib/lru_cache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/lru_cache.c b/lib/lru_cache.c
index e0db27b3a2d7..31820f03b146 100644
--- a/lib/lru_cache.c
+++ b/lib/lru_cache.c
@@ -94,11 +94,11 @@ struct lru_cache *lc_create(const char *name, struct kmem_cache *cache,
if (e_count > LC_MAX_ACTIVE)
return NULL;
- slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL);
+ slot = kcalloc(e_count, sizeof(*slot), GFP_KERNEL);
if (!slot)
return NULL;
- element = kcalloc(e_count, sizeof(struct lc_element *), GFP_KERNEL);
+ element = kcalloc(e_count, sizeof(*element), GFP_KERNEL);
if (!element)
goto out_fail;
--
2.40.0
next prev parent reply other threads:[~2023-03-29 13:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <6cbcf640-55e5-2f11-4a09-716fe681c0d2@web.de>
2023-03-29 13:36 ` [Drbd-dev] [PATCH 0/3] lru_cache: Adjustments for lc_create() Markus Elfring
2023-03-29 13:40 ` [Drbd-dev] [PATCH 1/3] lru_cache: Return directly after a failed kzalloc() in lc_create() Markus Elfring
2023-03-29 13:42 ` Markus Elfring [this message]
2023-03-29 13:44 ` [Drbd-dev] [PATCH 3/3] lru_cache: Improve exception handling " Markus Elfring
2024-01-10 11:40 ` [Drbd-dev] [PATCH 0/3] lru_cache: Adjustments for lc_create() Markus Elfring
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=f03b9407-0336-e949-e98d-9e0ddf3bfa57@web.de \
--to=markus.elfring@web.de \
--cc=christoph.boehmwalder@linbit.com \
--cc=cocci@inria.fr \
--cc=drbd-dev@lists.linbit.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars.ellenberg@linbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=philipp.reisner@linbit.com \
/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