From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Chanwoo Choi <cw00.choi@samsung.com>,
Bumwoo Lee <bw365.lee@samsung.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Subject: [PATCH v3 2/3] extcon: Use sizeof(*pointer) instead of sizeof(type)
Date: Tue, 11 Apr 2023 14:48:23 +0300 [thread overview]
Message-ID: <20230411114824.82960-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20230411114824.82960-1-andriy.shevchenko@linux.intel.com>
It is preferred to use sizeof(*pointer) instead of sizeof(type).
The type of the variable can change and one needs not change
the former (unlike the latter). No functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/extcon/extcon.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 5da1cc60582a..76dc41e8f250 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -1098,8 +1098,7 @@ static int extcon_alloc_cables(struct extcon_dev *edev)
if (!edev->max_supported)
return 0;
- edev->cables = kcalloc(edev->max_supported,
- sizeof(struct extcon_cable),
+ edev->cables = kcalloc(edev->max_supported, sizeof(*edev->cables),
GFP_KERNEL);
if (!edev->cables)
return -ENOMEM;
@@ -1161,14 +1160,12 @@ static int extcon_alloc_muex(struct extcon_dev *edev)
for (index = 0; edev->mutually_exclusive[index]; index++)
;
- edev->attrs_muex = kcalloc(index + 1,
- sizeof(struct attribute *),
+ edev->attrs_muex = kcalloc(index + 1, sizeof(*edev->attrs_muex),
GFP_KERNEL);
if (!edev->attrs_muex)
return -ENOMEM;
- edev->d_attrs_muex = kcalloc(index,
- sizeof(struct device_attribute),
+ edev->d_attrs_muex = kcalloc(index, sizeof(*edev->d_attrs_muex),
GFP_KERNEL);
if (!edev->d_attrs_muex) {
kfree(edev->attrs_muex);
@@ -1214,8 +1211,8 @@ static int extcon_alloc_groups(struct extcon_dev *edev)
return 0;
edev->extcon_dev_type.groups = kcalloc(edev->max_supported + 2,
- sizeof(struct attribute_group *),
- GFP_KERNEL);
+ sizeof(*edev->extcon_dev_type.groups),
+ GFP_KERNEL);
if (!edev->extcon_dev_type.groups)
return -ENOMEM;
--
2.40.0.1.gaa8946217a0b
next prev parent reply other threads:[~2023-04-11 11:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 11:48 [PATCH v3 0/3] extcon: Core cleanups and documentation fixes Andy Shevchenko
2023-04-11 11:48 ` [PATCH v3 1/3] extcon: Use unique number for the extcon device ID Andy Shevchenko
2023-04-11 11:48 ` Andy Shevchenko [this message]
2023-04-11 11:48 ` [PATCH v3 3/3] extcon: Drop unneeded assignments Andy Shevchenko
2023-04-16 15:28 ` [PATCH v3 0/3] extcon: Core cleanups and documentation fixes Chanwoo Choi
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=20230411114824.82960-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bw365.lee@samsung.com \
--cc=cw00.choi@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.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