Skip to content

Commit ef753fb

Browse files
andy-shevchanwoochoi
authored andcommitted
extcon: Use sizeof(*pointer) instead of sizeof(type)
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> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 parent 7bba9e8 commit ef753fb

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

drivers/extcon/extcon.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,8 +1098,7 @@ static int extcon_alloc_cables(struct extcon_dev *edev)
10981098
if (!edev->max_supported)
10991099
return 0;
11001100

1101-
edev->cables = kcalloc(edev->max_supported,
1102-
sizeof(struct extcon_cable),
1101+
edev->cables = kcalloc(edev->max_supported, sizeof(*edev->cables),
11031102
GFP_KERNEL);
11041103
if (!edev->cables)
11051104
return -ENOMEM;
@@ -1161,14 +1160,12 @@ static int extcon_alloc_muex(struct extcon_dev *edev)
11611160
for (index = 0; edev->mutually_exclusive[index]; index++)
11621161
;
11631162

1164-
edev->attrs_muex = kcalloc(index + 1,
1165-
sizeof(struct attribute *),
1163+
edev->attrs_muex = kcalloc(index + 1, sizeof(*edev->attrs_muex),
11661164
GFP_KERNEL);
11671165
if (!edev->attrs_muex)
11681166
return -ENOMEM;
11691167

1170-
edev->d_attrs_muex = kcalloc(index,
1171-
sizeof(struct device_attribute),
1168+
edev->d_attrs_muex = kcalloc(index, sizeof(*edev->d_attrs_muex),
11721169
GFP_KERNEL);
11731170
if (!edev->d_attrs_muex) {
11741171
kfree(edev->attrs_muex);
@@ -1214,8 +1211,8 @@ static int extcon_alloc_groups(struct extcon_dev *edev)
12141211
return 0;
12151212

12161213
edev->extcon_dev_type.groups = kcalloc(edev->max_supported + 2,
1217-
sizeof(struct attribute_group *),
1218-
GFP_KERNEL);
1214+
sizeof(*edev->extcon_dev_type.groups),
1215+
GFP_KERNEL);
12191216
if (!edev->extcon_dev_type.groups)
12201217
return -ENOMEM;
12211218

0 commit comments

Comments
 (0)