lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 24 Sep 2020 14:45:23 +0200
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Joel Becker <jlbec@...lplan.org>, Christoph Hellwig <hch@....de>
Cc:     linux-kernel@...r.kernel.org,
        Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: [PATCH 09/12] samples: configfs: prefer sizeof(*var) to sizeof(struct var_type)

From: Bartosz Golaszewski <bgolaszewski@...libre.com>

It's better to use the size of the actual variable than its type when
allocating memory. This also has the benefit of avoiding a line break
here.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
---
 samples/configfs/configfs_sample.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/samples/configfs/configfs_sample.c b/samples/configfs/configfs_sample.c
index 20bf3b3e0f0f..220aee7075b6 100644
--- a/samples/configfs/configfs_sample.c
+++ b/samples/configfs/configfs_sample.c
@@ -185,7 +185,7 @@ static struct config_item *simple_children_make_item(struct config_group *group,
 {
 	struct simple_child *simple_child;
 
-	simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL);
+	simple_child = kzalloc(sizeof(*simple_child), GFP_KERNEL);
 	if (!simple_child)
 		return ERR_PTR(-ENOMEM);
 
@@ -262,8 +262,7 @@ group_children_make_group(struct config_group *group, const char *name)
 {
 	struct simple_children *simple_children;
 
-	simple_children = kzalloc(sizeof(struct simple_children),
-				  GFP_KERNEL);
+	simple_children = kzalloc(sizeof(*simple_children), GFP_KERNEL);
 	if (!simple_children)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ