2018-01-24 17:39:02

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] Input-arc_ps2: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jan 2018 18:34:56 +0100

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

Markus Elfring (2):
Delete an error message for a failed memory allocation in arc_ps2_probe()
Improve a size determination in two functions

drivers/input/serio/arc_ps2.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

--
2.16.1



2018-01-24 17:40:47

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] Input: arc_ps2: Delete an error message for a failed memory allocation in arc_ps2_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jan 2018 18:17: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 <[email protected]>
---
drivers/input/serio/arc_ps2.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/serio/arc_ps2.c b/drivers/input/serio/arc_ps2.c
index 99e57a418753..9860b1c1e67a 100644
--- a/drivers/input/serio/arc_ps2.c
+++ b/drivers/input/serio/arc_ps2.c
@@ -197,10 +197,8 @@ static int arc_ps2_probe(struct platform_device *pdev)

arc_ps2 = devm_kzalloc(&pdev->dev, sizeof(struct arc_ps2_data),
GFP_KERNEL);
- if (!arc_ps2) {
- dev_err(&pdev->dev, "out of memory\n");
+ if (!arc_ps2)
return -ENOMEM;
- }

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
arc_ps2->addr = devm_ioremap_resource(&pdev->dev, res);
--
2.16.1


2018-01-24 17:41:22

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] Input: arc_ps2: Improve a size determination in two functions

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jan 2018 18:30:45 +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 <[email protected]>
---
drivers/input/serio/arc_ps2.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/input/serio/arc_ps2.c b/drivers/input/serio/arc_ps2.c
index 9860b1c1e67a..6a3c845e12ea 100644
--- a/drivers/input/serio/arc_ps2.c
+++ b/drivers/input/serio/arc_ps2.c
@@ -156,9 +156,8 @@ static int arc_ps2_create_port(struct platform_device *pdev,
int index)
{
struct arc_ps2_port *port = &arc_ps2->port[index];
- struct serio *io;
+ struct serio *io = kzalloc(sizeof(*io), GFP_KERNEL);

- io = kzalloc(sizeof(struct serio), GFP_KERNEL);
if (!io)
return -ENOMEM;

@@ -195,8 +194,7 @@ static int arc_ps2_probe(struct platform_device *pdev)
return -EINVAL;
}

- arc_ps2 = devm_kzalloc(&pdev->dev, sizeof(struct arc_ps2_data),
- GFP_KERNEL);
+ arc_ps2 = devm_kzalloc(&pdev->dev, sizeof(*arc_ps2), GFP_KERNEL);
if (!arc_ps2)
return -ENOMEM;

--
2.16.1