linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] sh-clk: Adjustments for two function implementations
@ 2017-05-16 17:29 SF Markus Elfring
  2017-05-16 17:30 ` [PATCH 1/2] sh-clk: Improve a size determination in sh_clk_fsidiv_register() SF Markus Elfring
  2017-05-16 17:31 ` [PATCH 2/2] sh-clk: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-05-16 17:29 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 16 May 2017 19:24:56 +0200

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

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

 drivers/sh/clk/cpg.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

-- 
2.13.0


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

* [PATCH 1/2] sh-clk: Improve a size determination in sh_clk_fsidiv_register()
  2017-05-16 17:29 [PATCH 0/2] sh-clk: Adjustments for two function implementations SF Markus Elfring
@ 2017-05-16 17:30 ` SF Markus Elfring
  2017-05-16 17:31 ` [PATCH 2/2] sh-clk: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-05-16 17:30 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 16 May 2017 18:42:22 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/sh/clk/cpg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/sh/clk/cpg.c b/drivers/sh/clk/cpg.c
index 7442bc130055..f23464bbeb7c 100644
--- a/drivers/sh/clk/cpg.c
+++ b/drivers/sh/clk/cpg.c
@@ -470,6 +470,5 @@ int __init sh_clk_fsidiv_register(struct clk *clks, int nr)
 	int i;
 
 	for (i = 0; i < nr; i++) {
-
-		map = kzalloc(sizeof(struct clk_mapping), GFP_KERNEL);
+		map = kzalloc(sizeof(*map), GFP_KERNEL);
 		if (!map) {
-- 
2.13.0


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

* [PATCH 2/2] sh-clk: Delete an error message for a failed memory allocation in two functions
  2017-05-16 17:29 [PATCH 0/2] sh-clk: Adjustments for two function implementations SF Markus Elfring
  2017-05-16 17:30 ` [PATCH 1/2] sh-clk: Improve a size determination in sh_clk_fsidiv_register() SF Markus Elfring
@ 2017-05-16 17:31 ` SF Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-05-16 17:31 UTC (permalink / raw)
  To: linux-sh, Rich Felker, Yoshinori Sato; +Cc: LKML, kernel-janitors, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 16 May 2017 19:05:36 +0200

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/sh/clk/cpg.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/sh/clk/cpg.c b/drivers/sh/clk/cpg.c
index f23464bbeb7c..b3afe5c4fa3b 100644
--- a/drivers/sh/clk/cpg.c
+++ b/drivers/sh/clk/cpg.c
@@ -253,7 +253,5 @@ static int __init sh_clk_div_register_ops(struct clk *clks, int nr,
-	if (!freq_table) {
-		pr_err("%s: unable to alloc memory\n", __func__);
+	if (!freq_table)
 		return -ENOMEM;
-	}
 
 	for (k = 0; !ret && (k < nr); k++) {
 		clkp = clks + k;
@@ -474,7 +472,5 @@ int __init sh_clk_fsidiv_register(struct clk *clks, int nr)
-		if (!map) {
-			pr_err("%s: unable to alloc memory\n", __func__);
+		if (!map)
 			return -ENOMEM;
-		}
 
 		/* clks[i].enable_reg came from SH_CLK_FSIDIV() */
 		map->phys		= (phys_addr_t)clks[i].enable_reg;
-- 
2.13.0


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

end of thread, other threads:[~2017-05-16 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-16 17:29 [PATCH 0/2] sh-clk: Adjustments for two function implementations SF Markus Elfring
2017-05-16 17:30 ` [PATCH 1/2] sh-clk: Improve a size determination in sh_clk_fsidiv_register() SF Markus Elfring
2017-05-16 17:31 ` [PATCH 2/2] sh-clk: Delete an error message for a failed memory allocation in two functions 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).