diff mbox

[05/18] HID: Improve two size determinations in hid_open_report()

Message ID 08ff35e1-d9f4-2296-c641-d6a28e951594@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring Feb. 7, 2017, 7:46 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 22:00:07 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 404eccd0d670..16c73bf49d55 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -975,7 +975,7 @@  int hid_open_report(struct hid_device *device)
 	device->rdesc = start;
 	device->rsize = size;
 
-	parser = vzalloc(sizeof(struct hid_parser));
+	parser = vzalloc(sizeof(*parser));
 	if (!parser) {
 		ret = -ENOMEM;
 		goto err;
@@ -986,7 +986,7 @@  int hid_open_report(struct hid_device *device)
 	end = start + size;
 
 	device->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
-				     sizeof(struct hid_collection), GFP_KERNEL);
+				     sizeof(*device->collection), GFP_KERNEL);
 	if (!device->collection) {
 		ret = -ENOMEM;
 		goto err;