2018-01-27 09:53:27

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] Input: nspire-keypad: Adjustments for nspire_keypad_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 10:48:28 +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
Improve a size determination

drivers/input/keyboard/nspire-keypad.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

--
2.16.1



2018-01-27 09:54:52

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] Input: nspire-keypad: Delete an error message for a failed memory allocation in nspire_keypad_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 10:33:37 +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/keyboard/nspire-keypad.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c
index c7f26fa3034c..f13b50213f94 100644
--- a/drivers/input/keyboard/nspire-keypad.c
+++ b/drivers/input/keyboard/nspire-keypad.c
@@ -175,10 +175,8 @@ static int nspire_keypad_probe(struct platform_device *pdev)

keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad),
GFP_KERNEL);
- if (!keypad) {
- dev_err(&pdev->dev, "failed to allocate keypad memory\n");
+ if (!keypad)
return -ENOMEM;
- }

keypad->row_shift = get_count_order(KEYPAD_BITMASK_COLS);

--
2.16.1


2018-01-27 09:56:39

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] Input: nspire-keypad: Improve a size determination in nspire_keypad_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 10:36:20 +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 <[email protected]>
---
drivers/input/keyboard/nspire-keypad.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c
index f13b50213f94..caadc99741c0 100644
--- a/drivers/input/keyboard/nspire-keypad.c
+++ b/drivers/input/keyboard/nspire-keypad.c
@@ -173,8 +173,7 @@ static int nspire_keypad_probe(struct platform_device *pdev)
return -EINVAL;
}

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

--
2.16.1