lkml.org 
[lkml]   [2020]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 09/12] samples: configfs: prefer sizeof(*var) to sizeof(struct var_type)
Date
From: Bartosz Golaszewski <bgolaszewski@baylibre.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@baylibre.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
\
 
 \ /
  Last update: 2020-09-24 14:47    [W:0.871 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site