HID-Wacom: Fine-tuning for seven function implementations
Subsystems (3)
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
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
@@ -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
Re: [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions
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.
Signed-off-by Markus Elfring <[email protected]>--- drivers/hid/wacom_sys.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/hid/wacom_sys.c +2
-4@@ -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
PATCH 2/3 HID: Wacom: Improve size determinations in three functions
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 3/3 HID: Wacom: Delete two unnecessary return statements
In reply to SF Markus ElfringFrom: 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
@@ -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
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 +0200Three update suggestions were taken into account
from static source code analysis.Markus Elfring (3):
Usedevm_kcalloc()in two functions
Improve size determinations in three functions
Delete two unnecessary return statementsdrivers/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