cpufreq: Use sizeof(*ptr) convetion for computing sizes
Chapter 14 of Documentation/CodingStyle says: The preferred form for passing a size of a struct is the following: p = kmalloc(sizeof(*p), ...); The alternative form where struct name is spelled out hurts readability and introduces an opportunity for a bug when the pointer variable type is changed but the corresponding sizeof that is passed to a memory allocator is not. This wasn't followed consistently in drivers/cpufreq, let's make it more consistent by always following this rule. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:

committed by
Rafael J. Wysocki

parent
3a3e9e06d0
commit
d5b73cd870
@@ -177,7 +177,7 @@ static int get_ranges(unsigned char *pst)
|
||||
unsigned int speed;
|
||||
u8 fid, vid;
|
||||
|
||||
powernow_table = kzalloc((sizeof(struct cpufreq_frequency_table) *
|
||||
powernow_table = kzalloc((sizeof(*powernow_table) *
|
||||
(number_scales + 1)), GFP_KERNEL);
|
||||
if (!powernow_table)
|
||||
return -ENOMEM;
|
||||
@@ -309,8 +309,7 @@ static int powernow_acpi_init(void)
|
||||
goto err0;
|
||||
}
|
||||
|
||||
acpi_processor_perf = kzalloc(sizeof(struct acpi_processor_performance),
|
||||
GFP_KERNEL);
|
||||
acpi_processor_perf = kzalloc(sizeof(*acpi_processor_perf), GFP_KERNEL);
|
||||
if (!acpi_processor_perf) {
|
||||
retval = -ENOMEM;
|
||||
goto err0;
|
||||
@@ -346,7 +345,7 @@ static int powernow_acpi_init(void)
|
||||
goto err2;
|
||||
}
|
||||
|
||||
powernow_table = kzalloc((sizeof(struct cpufreq_frequency_table) *
|
||||
powernow_table = kzalloc((sizeof(*powernow_table) *
|
||||
(number_scales + 1)), GFP_KERNEL);
|
||||
if (!powernow_table) {
|
||||
retval = -ENOMEM;
|
||||
@@ -497,7 +496,7 @@ static int powernow_decode_bios(int maxfid, int startvid)
|
||||
"relevant to this CPU).\n",
|
||||
psb->numpst);
|
||||
|
||||
p += sizeof(struct psb_s);
|
||||
p += sizeof(*psb);
|
||||
|
||||
pst = (struct pst_s *) p;
|
||||
|
||||
@@ -510,12 +509,12 @@ static int powernow_decode_bios(int maxfid, int startvid)
|
||||
(maxfid == pst->maxfid) &&
|
||||
(startvid == pst->startvid)) {
|
||||
print_pst_entry(pst, j);
|
||||
p = (char *)pst + sizeof(struct pst_s);
|
||||
p = (char *)pst + sizeof(*pst);
|
||||
ret = get_ranges(p);
|
||||
return ret;
|
||||
} else {
|
||||
unsigned int k;
|
||||
p = (char *)pst + sizeof(struct pst_s);
|
||||
p = (char *)pst + sizeof(*pst);
|
||||
for (k = 0; k < number_scales; k++)
|
||||
p += 2;
|
||||
}
|
||||
|
Reference in New Issue
Block a user