[PATCH] ima: Use sizeof struct rather than pointer

From: Vaishali Thakkar
Date: Mon Apr 04 2016 - 12:24:03 EST


When sizeof the pointer is applied to a pointer typed expression it
gives the size of the pointer. Here, for the cleanness sake, let's
not use sizeof the pointer. This does not actually change the behavior
of the code as both being pointers, *fields and **fields have the same
size and fields is a ***.

Problem found using Coccinelle.

Signed-off-by: Vaishali Thakkar <vaishali.thakkar@xxxxxxxxxx>
---
security/integrity/ima/ima_template.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index febd12e..fdba86f 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -171,11 +171,11 @@ static int template_desc_init_fields(const char *template_fmt,
}

if (fields && num_fields) {
- *fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL);
+ *fields = kmalloc_array(i, sizeof(**fields), GFP_KERNEL);
if (*fields == NULL)
return -ENOMEM;

- memcpy(*fields, found_fields, i * sizeof(*fields));
+ memcpy(*fields, found_fields, i * sizeof(**fields));
*num_fields = i;
}

--
2.1.4