linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-mm@kvack.org, kernel-janitors@vger.kernel.org,
	Muchun Song <muchun.song@linux.dev>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] hugetlbfs: Improve a size determination in two functions
Date: Fri, 29 Dec 2023 12:37:48 +0100	[thread overview]
Message-ID: <8c9488b0-4d91-48ac-bee7-6454e3045a9f@web.de> (raw)
In-Reply-To: <9ce3f553-24bc-4ecd-ac5e-7ba27caeff57@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 29 Dec 2023 11:32:07 +0100

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.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/hugetlbfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index ea5b8e57d904..24401a5046dd 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1460,7 +1460,7 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	struct hugetlbfs_fs_context *ctx = fc->fs_private;
 	struct hugetlbfs_sb_info *sbinfo;

-	sbinfo = kmalloc(sizeof(struct hugetlbfs_sb_info), GFP_KERNEL);
+	sbinfo = kmalloc(sizeof(*sbinfo), GFP_KERNEL);
 	if (!sbinfo)
 		return -ENOMEM;
 	sb->s_fs_info = sbinfo;
@@ -1530,7 +1530,7 @@ static int hugetlbfs_init_fs_context(struct fs_context *fc)
 {
 	struct hugetlbfs_fs_context *ctx;

-	ctx = kzalloc(sizeof(struct hugetlbfs_fs_context), GFP_KERNEL);
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;

--
2.43.0



  reply	other threads:[~2023-12-29 11:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-29 11:36 [PATCH 0/2] hugetlbfs: Adjustments for two function implementations Markus Elfring
2023-12-29 11:37 ` Markus Elfring [this message]
2024-01-02  2:57   ` [PATCH 1/2] hugetlbfs: Improve a size determination in two functions Muchun Song
2023-12-29 11:40 ` [PATCH 2/2] hugetlbfs: Improve exception handling in hugetlbfs_fill_super() Markus Elfring
2023-12-29 14:52   ` Matthew Wilcox
2023-12-30  6:45     ` 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=8c9488b0-4d91-48ac-bee7-6454e3045a9f@web.de \
    --to=markus.elfring@web.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    /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