linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] HID-Logitech: Adjustments for two function implementations
@ 2018-02-06 14:43 SF Markus Elfring
  2018-02-06 14:45 ` [PATCH 1/3] hid-lg: Delete an error message for a failed memory allocation in lg_probe() SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-02-06 14:43 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 15:38:30 +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 lg_probe()
  Improve a size determination in lg_probe()
  Delete an error message for a failed memory allocation in lg4ff_init()

 drivers/hid/hid-lg.c    | 7 +++----
 drivers/hid/hid-lg4ff.c | 4 +---
 2 files changed, 4 insertions(+), 7 deletions(-)

-- 
2.16.1

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

* [PATCH 1/3] hid-lg: Delete an error message for a failed memory allocation in lg_probe()
  2018-02-06 14:43 [PATCH 0/3] HID-Logitech: Adjustments for two function implementations SF Markus Elfring
@ 2018-02-06 14:45 ` SF Markus Elfring
  2018-02-06 14:46 ` [PATCH 2/3] hid-lg: Improve a size determination " SF Markus Elfring
  2018-02-06 14:47 ` [PATCH 3/3] hid-lg4ff: Delete an error message for a failed memory allocation in lg4ff_init() SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-02-06 14:45 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 14:25:32 +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/hid/hid-lg.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 596227ddb6e0..f4439dc64497 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -728,10 +728,9 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	}
 
 	drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
-	if (!drv_data) {
-		hid_err(hdev, "Insufficient memory, cannot allocate driver data\n");
+	if (!drv_data)
 		return -ENOMEM;
-	}
+
 	drv_data->quirks = id->driver_data;
 
 	hid_set_drvdata(hdev, (void *)drv_data);
-- 
2.16.1


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

* [PATCH 2/3] hid-lg: Improve a size determination in lg_probe()
  2018-02-06 14:43 [PATCH 0/3] HID-Logitech: Adjustments for two function implementations SF Markus Elfring
  2018-02-06 14:45 ` [PATCH 1/3] hid-lg: Delete an error message for a failed memory allocation in lg_probe() SF Markus Elfring
@ 2018-02-06 14:46 ` SF Markus Elfring
  2018-02-06 14:47 ` [PATCH 3/3] hid-lg4ff: Delete an error message for a failed memory allocation in lg4ff_init() SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-02-06 14:46 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 14:54:14 +0100

Replace the specification of a data structure by a pointer dereference
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/hid/hid-lg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index f4439dc64497..358b4c6f856d 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -727,7 +727,7 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		return -ENODEV;
 	}
 
-	drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
+	drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
 	if (!drv_data)
 		return -ENOMEM;
 
-- 
2.16.1


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

* [PATCH 3/3] hid-lg4ff: Delete an error message for a failed memory allocation in lg4ff_init()
  2018-02-06 14:43 [PATCH 0/3] HID-Logitech: Adjustments for two function implementations SF Markus Elfring
  2018-02-06 14:45 ` [PATCH 1/3] hid-lg: Delete an error message for a failed memory allocation in lg_probe() SF Markus Elfring
  2018-02-06 14:46 ` [PATCH 2/3] hid-lg: Improve a size determination " SF Markus Elfring
@ 2018-02-06 14:47 ` SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-02-06 14:47 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 15:26:06 +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/hid/hid-lg4ff.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 512d67e1aae3..ec6b94bb3fd8 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -1401,10 +1401,8 @@ int lg4ff_init(struct hid_device *hid)
 
 		for (j = 0; j < 5; j++) {
 			led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL);
-			if (!led) {
-				hid_err(hid, "can't allocate memory for LED %d\n", j);
+			if (!led)
 				goto err_leds;
-			}
 
 			name = (void *)(&led[1]);
 			snprintf(name, name_sz, "%s::RPM%d", dev_name(&hid->dev), j+1);
-- 
2.16.1

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

end of thread, other threads:[~2018-02-06 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-06 14:43 [PATCH 0/3] HID-Logitech: Adjustments for two function implementations SF Markus Elfring
2018-02-06 14:45 ` [PATCH 1/3] hid-lg: Delete an error message for a failed memory allocation in lg_probe() SF Markus Elfring
2018-02-06 14:46 ` [PATCH 2/3] hid-lg: Improve a size determination " SF Markus Elfring
2018-02-06 14:47 ` [PATCH 3/3] hid-lg4ff: Delete an error message for a failed memory allocation in lg4ff_init() 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).