linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Input: ims-pcu: Adjustments for three function implementations
@ 2018-01-25 18:51 SF Markus Elfring
  2018-01-25 18:52 ` [PATCH 1/3] Input: ims-pcu: Delete an error message for a failed memory allocation in ims_pcu_buffers_alloc() SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-01-25 18:51 UTC (permalink / raw)
  To: linux-input, Arvind Yadav, Dmitry Torokhov, Joe Perches,
	Johan Hovold, Zhen Lei
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jan 2018 19:46:56 +0100

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

Markus Elfring (3):
  Delete an error message for a failed memory allocation
    in ims_pcu_buffers_alloc()
  Improve a size determination in two functions
  Delete an unnecessary variable assignment in ims_pcu_setup_gamepad()

 drivers/input/misc/ims-pcu.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

-- 
2.16.1

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

* [PATCH 1/3] Input: ims-pcu: Delete an error message for a failed memory allocation in ims_pcu_buffers_alloc()
  2018-01-25 18:51 [PATCH 0/3] Input: ims-pcu: Adjustments for three function implementations SF Markus Elfring
@ 2018-01-25 18:52 ` SF Markus Elfring
  2018-01-25 18:53 ` [PATCH 2/3] Input: ims-pcu: Improve a size determination in two functions SF Markus Elfring
  2018-01-25 18:54 ` [PATCH 3/3] Input: ims-pcu: Delete an unnecessary variable assignment in ims_pcu_setup_gamepad() SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-01-25 18:52 UTC (permalink / raw)
  To: linux-input, Arvind Yadav, Dmitry Torokhov, Joe Perches,
	Johan Hovold, Zhen Lei
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jan 2018 19:06:07 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/misc/ims-pcu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index 3d51175c4d72..4aca2a02ff6d 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -1556,7 +1556,6 @@ static int ims_pcu_buffers_alloc(struct ims_pcu *pcu)
 	 */
 	pcu->urb_out_buf = kmalloc(pcu->max_out_size, GFP_KERNEL);
 	if (!pcu->urb_out_buf) {
-		dev_err(pcu->dev, "Failed to allocate memory for write buffer\n");
 		error = -ENOMEM;
 		goto err_free_in_urb;
 	}
-- 
2.16.1

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

* [PATCH 2/3] Input: ims-pcu: Improve a size determination in two functions
  2018-01-25 18:51 [PATCH 0/3] Input: ims-pcu: Adjustments for three function implementations SF Markus Elfring
  2018-01-25 18:52 ` [PATCH 1/3] Input: ims-pcu: Delete an error message for a failed memory allocation in ims_pcu_buffers_alloc() SF Markus Elfring
@ 2018-01-25 18:53 ` SF Markus Elfring
  2018-01-25 18:54 ` [PATCH 3/3] Input: ims-pcu: Delete an unnecessary variable assignment in ims_pcu_setup_gamepad() SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-01-25 18:53 UTC (permalink / raw)
  To: linux-input, Arvind Yadav, Dmitry Torokhov, Joe Perches,
	Johan Hovold, Zhen Lei
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jan 2018 19:20:38 +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.

This issue was detected by using the Coccinelle software.

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

diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index 4aca2a02ff6d..d7778b273151 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -288,12 +288,10 @@ static void ims_pcu_gamepad_report(struct ims_pcu *pcu, u32 data)
 
 static int ims_pcu_setup_gamepad(struct ims_pcu *pcu)
 {
-	struct ims_pcu_gamepad *gamepad;
-	struct input_dev *input;
 	int error;
+	struct ims_pcu_gamepad *gamepad = kzalloc(sizeof(*gamepad), GFP_KERNEL);
+	struct input_dev *input = input_allocate_device();
 
-	gamepad = kzalloc(sizeof(struct ims_pcu_gamepad), GFP_KERNEL);
-	input = input_allocate_device();
 	if (!gamepad || !input) {
 		dev_err(pcu->dev,
 			"Not enough memory for gamepad device\n");
@@ -2003,10 +2001,9 @@ static int ims_pcu_probe(struct usb_interface *intf,
 			 const struct usb_device_id *id)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
-	struct ims_pcu *pcu;
 	int error;
+	struct ims_pcu *pcu = kzalloc(sizeof(*pcu), GFP_KERNEL);
 
-	pcu = kzalloc(sizeof(struct ims_pcu), GFP_KERNEL);
 	if (!pcu)
 		return -ENOMEM;
 
-- 
2.16.1

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

* [PATCH 3/3] Input: ims-pcu: Delete an unnecessary variable assignment in ims_pcu_setup_gamepad()
  2018-01-25 18:51 [PATCH 0/3] Input: ims-pcu: Adjustments for three function implementations SF Markus Elfring
  2018-01-25 18:52 ` [PATCH 1/3] Input: ims-pcu: Delete an error message for a failed memory allocation in ims_pcu_buffers_alloc() SF Markus Elfring
  2018-01-25 18:53 ` [PATCH 2/3] Input: ims-pcu: Improve a size determination in two functions SF Markus Elfring
@ 2018-01-25 18:54 ` SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-01-25 18:54 UTC (permalink / raw)
  To: linux-input, Arvind Yadav, Dmitry Torokhov, Joe Perches,
	Johan Hovold, Zhen Lei
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jan 2018 19:37:34 +0100

An error code was assigned to a local variable in an if branch.
This value was not read again before it was used by a return statement
as a constant value at the end of this function.
Thus remove such an unneeded assignment.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/misc/ims-pcu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index d7778b273151..aa1bb284c714 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -295,7 +295,6 @@ static int ims_pcu_setup_gamepad(struct ims_pcu *pcu)
 	if (!gamepad || !input) {
 		dev_err(pcu->dev,
 			"Not enough memory for gamepad device\n");
-		error = -ENOMEM;
 		goto err_free_mem;
 	}
 
-- 
2.16.1

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

end of thread, other threads:[~2018-01-25 18:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25 18:51 [PATCH 0/3] Input: ims-pcu: Adjustments for three function implementations SF Markus Elfring
2018-01-25 18:52 ` [PATCH 1/3] Input: ims-pcu: Delete an error message for a failed memory allocation in ims_pcu_buffers_alloc() SF Markus Elfring
2018-01-25 18:53 ` [PATCH 2/3] Input: ims-pcu: Improve a size determination in two functions SF Markus Elfring
2018-01-25 18:54 ` [PATCH 3/3] Input: ims-pcu: Delete an unnecessary variable assignment in ims_pcu_setup_gamepad() SF Markus Elfring

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