Skip to contentSkip to conversation

HID-Wacom: Fine-tuning for seven function implementations

PATCH In review SF Markus Elfring 2 participants 6 messages Apr 25, 2017 – Jun 5, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover HID-Wacom: Fine-tuning for seven function implementations

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 17:07:07 +0200

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Use devm_kcalloc() in two functions
Improve size determinations in three functions
Delete two unnecessary return statements

 drivers/hid/wacom_sys.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
Signature · 1 line
2.12.2
#1 lore raw

PATCH 1/3 HID: Wacom: Use devm_kcalloc() in two functions

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 16:06:08 +0200

* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "devm_kcalloc".

This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/hid/wacom_sys.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/hid/wacom_sys.c +2 -3
index 0022c0dac88a..550faf8819ea 100644
@@ -1245,7 +1245,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev,
 	if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL))
 		return -ENOMEM;
 
-	leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL);
+	leds = devm_kcalloc(dev, count, sizeof(*leds), GFP_KERNEL);
 	if (!leds) {
 		error = -ENOMEM;
 		goto err;
@@ -1345,8 +1345,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count)
 	struct wacom_group_leds *groups;
 	int error;
 
-	groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count,
-			      GFP_KERNEL);
+	groups = devm_kcalloc(dev, count, sizeof(*groups), GFP_KERNEL);
 	if (!groups)
 		return -ENOMEM;
 
Signature · 1 line
2.12.2
#3 lore raw

PATCH 2/3 HID: Wacom: Improve size determinations in three functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 16:38:59 +0200

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

---
 drivers/hid/wacom_sys.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hid/wacom_sys.c +3 -3
index 550faf8819ea..7517da5300fd 100644
@@ -726,7 +726,7 @@ static int wacom_add_shared_data(struct hid_device *hdev)
 
 	data = wacom_get_hdev_data(hdev);
 	if (!data) {
-		data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL);
+		data = kzalloc(sizeof(*data), GFP_KERNEL);
 		if (!data) {
 			retval = -ENOMEM;
 			goto out;
@@ -1088,7 +1088,7 @@ static int __wacom_devm_sysfs_create_group(struct wacom *wacom,
 	int error;
 
 	devres = devres_alloc(wacom_devm_sysfs_group_release,
-			      sizeof(struct wacom_sysfs_group_devres),
+			      sizeof(*devres),
 			      GFP_KERNEL);
 	if (!devres)
 		return -ENOMEM;
@@ -2556,7 +2556,7 @@ static int wacom_probe(struct hid_device *hdev,
 	/* hid-core sets this quirk for the boot interface */
 	hdev->quirks &= ~HID_QUIRK_NOGET;
 
-	wacom = devm_kzalloc(&hdev->dev, sizeof(struct wacom), GFP_KERNEL);
+	wacom = devm_kzalloc(&hdev->dev, sizeof(*wacom), GFP_KERNEL);
 	if (!wacom)
 		return -ENOMEM;
 
Signature · 1 line
2.12.2
#4 lore raw

PATCH 3/3 HID: Wacom: Delete two unnecessary return statements

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 16:50:02 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

---
 drivers/hid/wacom_sys.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/hid/wacom_sys.c +0 -3
index 7517da5300fd..f70e7d7351c7 100644
@@ -2329,7 +2329,6 @@ static void wacom_wireless_work(struct work_struct *work)
 fail:
 	wacom_release_resources(wacom1);
 	wacom_release_resources(wacom2);
-	return;
 }
 
 static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
@@ -2534,8 +2533,6 @@ static void wacom_mode_change_work(struct work_struct *work)
 		if (error)
 			return;
 	}
-
-	return;
 }
 
 static int wacom_probe(struct hid_device *hdev,
Signature · 1 line
2.12.2
Reviewed-by on the v1 series
#5 lore raw
In reply to SF Markus Elfring

Came across these and noticed that it doesn't appear anything has happened with them. The set looks good to me:

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....

Quoted 21 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 17:07:07 +0200

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Use devm_kcalloc() in two functions
Improve size determinations in three functions
Delete two unnecessary return statements

 drivers/hid/wacom_sys.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

--
2.12.2

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions

In reply to SF Markus Elfring

Going through old mail and noticed that these three patches seem to have been overlooked (at least, I don't see them in Jiri's branches...). For the set:

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....

Quoted 48 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 16:06:08 +0200

* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "devm_kcalloc".

This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/hid/wacom_sys.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/hid/wacom_sys.c +2 -4
index 0022c0dac88a..550faf8819ea 100644
@@ -1245,7 +1245,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev,
        if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL))
                return -ENOMEM;
 
-       leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL);
+       leds = devm_kcalloc(dev, count, sizeof(*leds), GFP_KERNEL);
        if (!leds) {
                error = -ENOMEM;
                goto err;
@@ -1345,8 +1345,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count)
        struct wacom_group_leds *groups;
        int error;
 
-       groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count,
-                             GFP_KERNEL);
+       groups = devm_kcalloc(dev, count, sizeof(*groups), GFP_KERNEL);
        if (!groups)
                return -ENOMEM;
 
--

2.12.2

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html