linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations
@ 2017-04-25 15:12 SF Markus Elfring
  2017-04-25 15:13 ` [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions SF Markus Elfring
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-25 15:12 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions
  2017-04-25 15:12 [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations SF Markus Elfring
@ 2017-04-25 15:13 ` SF Markus Elfring
  2017-06-05 15:29   ` Jason Gerecke
  2017-04-25 15:14 ` [PATCH 2/3] HID: Wacom: Improve size determinations in three functions SF Markus Elfring
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-25 15:13 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 drivers/hid/wacom_sys.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 0022c0dac88a..550faf8819ea 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] HID: Wacom: Improve size determinations in three functions
  2017-04-25 15:12 [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations SF Markus Elfring
  2017-04-25 15:13 ` [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions SF Markus Elfring
@ 2017-04-25 15:14 ` SF Markus Elfring
  2017-04-25 15:15 ` [PATCH 3/3] HID: Wacom: Delete two unnecessary return statements SF Markus Elfring
  2017-05-15 17:18 ` [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations Jason Gerecke
  3 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-25 15:14 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

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

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 550faf8819ea..7517da5300fd 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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;
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] HID: Wacom: Delete two unnecessary return statements
  2017-04-25 15:12 [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations SF Markus Elfring
  2017-04-25 15:13 ` [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions SF Markus Elfring
  2017-04-25 15:14 ` [PATCH 2/3] HID: Wacom: Improve size determinations in three functions SF Markus Elfring
@ 2017-04-25 15:15 ` SF Markus Elfring
  2017-05-15 17:18 ` [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations Jason Gerecke
  3 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-04-25 15:15 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/wacom_sys.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 7517da5300fd..f70e7d7351c7 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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,
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations
  2017-04-25 15:12 [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations SF Markus Elfring
                   ` (2 preceding siblings ...)
  2017-04-25 15:15 ` [PATCH 3/3] HID: Wacom: Delete two unnecessary return statements SF Markus Elfring
@ 2017-05-15 17:18 ` Jason Gerecke
  3 siblings, 0 replies; 6+ messages in thread
From: Jason Gerecke @ 2017-05-15 17:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Linux Input, Benjamin Tissoires, Jiri Kosina, LKML, kernel-janitors

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

Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>

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....



On Tue, Apr 25, 2017 at 8:12 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions
  2017-04-25 15:13 ` [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions SF Markus Elfring
@ 2017-06-05 15:29   ` Jason Gerecke
  0 siblings, 0 replies; 6+ messages in thread
From: Jason Gerecke @ 2017-06-05 15:29 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Linux Input, Benjamin Tissoires, LKML, SF Markus Elfring,
	kernel-janitors

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:

Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>

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....



On Tue, Apr 25, 2017 at 8:13 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> ---
>  drivers/hid/wacom_sys.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index 0022c0dac88a..550faf8819ea 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-06-05 15:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25 15:12 [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations SF Markus Elfring
2017-04-25 15:13 ` [PATCH 1/3] HID: Wacom: Use devm_kcalloc() in two functions SF Markus Elfring
2017-06-05 15:29   ` Jason Gerecke
2017-04-25 15:14 ` [PATCH 2/3] HID: Wacom: Improve size determinations in three functions SF Markus Elfring
2017-04-25 15:15 ` [PATCH 3/3] HID: Wacom: Delete two unnecessary return statements SF Markus Elfring
2017-05-15 17:18 ` [PATCH 0/3] HID-Wacom: Fine-tuning for seven function implementations Jason Gerecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).