Skip to contentSkip to conversation

Input: nspire-keypad: Adjustments for nspire_keypad_probe()

PATCH New SF Markus Elfring 1 participant 3 messages Jan 27, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.16.1
#1 lore raw

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.

---
 drivers/input/keyboard/nspire-keypad.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/keyboard/nspire-keypad.c +1 -3
index c7f26fa3034c..f13b50213f94 100644
@@ -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);
 
Signature · 1 line
2.16.1
#2 lore raw

PATCH 2/2 Input: nspire-keypad: Improve a size determination in nspire_keypad_probe()

In reply to SF Markus Elfring

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.

---
 drivers/input/keyboard/nspire-keypad.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/keyboard/nspire-keypad.c +1 -2
index f13b50213f94..caadc99741c0 100644
@@ -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;
 
Signature · 1 line
2.16.1