Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742325

[PATCH 2/2] ACPI-scan: Improve a size determination in three functions

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 2/2] ACPI-scan: Improve a size determination in three functions
Date 2017-09-29 22:20 +0200
Message-ID <uv9Vp-2wp-23@gated-at.bofh.it> (permalink)
References <uv9Vo-2wp-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 29 Sep 2017 22:00:25 +0200

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.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/scan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 7df7bea1e177..34bc7274dc8e 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -650,7 +650,7 @@ int acpi_device_add(struct acpi_device *device,
 	INIT_LIST_HEAD(&device->del_list);
 	mutex_init(&device->physical_node_lock);
 
-	new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
+	new_bus_id = kzalloc(sizeof(*new_bus_id), GFP_KERNEL);
 	if (!new_bus_id) {
 		result = -ENOMEM;
 		goto err_detach;
@@ -1577,7 +1577,7 @@ static int acpi_add_single_object(struct acpi_device **child,
 	struct acpi_device *device;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 
-	device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
+	device = kzalloc(sizeof(*device), GFP_KERNEL);
 	if (!device)
 		return -ENOMEM;
 
@@ -1786,7 +1786,7 @@ static void acpi_device_dep_initialize(struct acpi_device *adev)
 		if (skip)
 			continue;
 
-		dep = kzalloc(sizeof(struct acpi_dep_data), GFP_KERNEL);
+		dep = kzalloc(sizeof(*dep), GFP_KERNEL);
 		if (!dep)
 			return;
 
-- 
2.14.2

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] ACPI: Adjustments for six function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-29 22:20 +0200
  [PATCH 1/2] ACPI: Delete an error message for a failed memory  allocation in five functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-29 22:20 +0200
  [PATCH 2/2] ACPI-scan: Improve a size determination in three  functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-29 22:20 +0200

csiph-web