char-bsr: Adjustments for two function implementations
Subsystems (2)
cover char-bsr: Adjustments for two function implementations
From: Markus Elfring <[email protected]>
Date: Sun, 15 Oct 2017 22:02:34 +0200
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 bsr_add_node() Improve a size determination in bsr_add_node()
Adjust one function call together with a variable assignment
drivers/char/bsr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.14.2
PATCH 1/3 char/bsr: Delete an error message for a failed memory allocation in bsr_add_node()
From: Markus Elfring <[email protected]>
Date: Sun, 15 Oct 2017 21:12:34 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/char/bsr.c | 1 - 1 file changed, 1 deletion(-)
drivers/char/bsr.c +0 -1
@@ -203,7 +203,6 @@ static int bsr_add_node(struct device_node *bn)int result;if (!cur) { -printk (KERN_ERR "Unable to alloc bsr dev\n" ); ret = -ENOMEM ; goto out_err; }
Signature · 1 line
2.14.2
PATCH 2/3 char/bsr: Improve a size determination in bsr_add_node()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Oct 2017 21:25:46 +0200
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.
--- drivers/char/bsr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/bsr.c +1 -2
@@ -197,8 +197,7 @@ static int bsr_add_node(struct device_node *bn) num_bsr_devs = bsr_bytes_len /sizeof (u32);for (i =0 ; i < num_bsr_devs; i++) { -struct bsr_dev *cur =kzalloc (sizeof (struct bsr_dev ), -GFP_KERNEL ); +struct bsr_dev *cur =kzalloc (sizeof (*cur),GFP_KERNEL );struct resource res;int result;
Signature · 1 line
2.14.2
PATCH 3/3 char/bsr: Adjust one function call together with a variable assignment
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 15 Oct 2017 21:55:26 +0200
The script "checkpatch.pl" pointed information out like the following.
ERROR: do not use assignment in if condition
Thus fix the affected source code place.
--- drivers/char/bsr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/bsr.c +2 -1
@@ -320,7 +320,8 @@ static int __init bsr_init(void) goto out_err_2; } -if ((ret =bsr_create_devs (np)) <0 ) { + ret =bsr_create_devs (np); +if (ret <0 ) { np =NULL ; goto out_err_3; }
Signature · 1 line
2.14.2