linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Power Mac: Adjustments for five function implementations
@ 2017-10-05 20:50 SF Markus Elfring
  2017-10-05 20:51 ` [PATCH 1/2] powermac: Delete an error message for a failed memory allocation in kw_i2c_host_init() SF Markus Elfring
  2017-10-05 20:52 ` [PATCH 2/2] powermac: Improve a size determination in five functions SF Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-10-05 20:50 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman,
	Paul Mackerras
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Oct 2017 22:48:22 +0200

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 kw_i2c_host_init()
  Improve a size determination in five functions

 arch/powerpc/platforms/powermac/low_i2c.c    | 11 ++++-------
 arch/powerpc/platforms/powermac/pfunc_core.c |  4 ++--
 2 files changed, 6 insertions(+), 9 deletions(-)

-- 
2.14.2

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

* [PATCH 1/2] powermac: Delete an error message for a failed memory allocation in kw_i2c_host_init()
  2017-10-05 20:50 [PATCH 0/2] Power Mac: Adjustments for five function implementations SF Markus Elfring
@ 2017-10-05 20:51 ` SF Markus Elfring
  2017-10-05 20:52 ` [PATCH 2/2] powermac: Improve a size determination in five functions SF Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-10-05 20:51 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman,
	Paul Mackerras
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Oct 2017 22:30:29 +0200

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 <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/powermac/low_i2c.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index 70183eb3d5c8..ecd166b5549b 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -493,11 +493,8 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
 	u32			steps;
 
 	host = kzalloc(sizeof(struct pmac_i2c_host_kw), GFP_KERNEL);
-	if (host == NULL) {
-		printk(KERN_ERR "low_i2c: Can't allocate host for %pOF\n",
-		       np);
+	if (!host)
 		return NULL;
-	}
 
 	/* Apple is kind enough to provide a valid AAPL,address property
 	 * on all i2c keywest nodes so far ... we would have to fallback
-- 
2.14.2

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

* [PATCH 2/2] powermac: Improve a size determination in five functions
  2017-10-05 20:50 [PATCH 0/2] Power Mac: Adjustments for five function implementations SF Markus Elfring
  2017-10-05 20:51 ` [PATCH 1/2] powermac: Delete an error message for a failed memory allocation in kw_i2c_host_init() SF Markus Elfring
@ 2017-10-05 20:52 ` SF Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-10-05 20:52 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman,
	Paul Mackerras
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Oct 2017 22:40:39 +0200

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 <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/powermac/low_i2c.c    | 6 +++---
 arch/powerpc/platforms/powermac/pfunc_core.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index ecd166b5549b..46b7eb1a0f5f 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -492,7 +492,7 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
 	const u32		*psteps, *prate, *addrp;
 	u32			steps;
 
-	host = kzalloc(sizeof(struct pmac_i2c_host_kw), GFP_KERNEL);
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
 	if (!host)
 		return NULL;
 
@@ -571,7 +571,7 @@ static void __init kw_i2c_add(struct pmac_i2c_host_kw *host,
 {
 	struct pmac_i2c_bus *bus;
 
-	bus = kzalloc(sizeof(struct pmac_i2c_bus), GFP_KERNEL);
+	bus = kzalloc(sizeof(*bus), GFP_KERNEL);
 	if (bus == NULL)
 		return;
 
@@ -1253,7 +1253,7 @@ static void* pmac_i2c_do_begin(struct pmf_function *func, struct pmf_args *args)
 	 * near OOM that need to be resolved, the allocator itself should
 	 * probably make GFP_NOIO implicit during suspend
 	 */
-	inst = kzalloc(sizeof(struct pmac_i2c_pf_inst), GFP_KERNEL);
+	inst = kzalloc(sizeof(*inst), GFP_KERNEL);
 	if (inst == NULL) {
 		pmac_i2c_close(bus);
 		return NULL;
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c
index df3c93bef228..e0462fedcdb8 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -643,7 +643,7 @@ static int pmf_add_function_prop(struct pmf_device *dev, void *driverdata,
 
 	while (length >= 12) {
 		/* Allocate a structure */
-		func = kzalloc(sizeof(struct pmf_function), GFP_KERNEL);
+		func = kzalloc(sizeof(*func), GFP_KERNEL);
 		if (func == NULL)
 			goto bail;
 		kref_init(&func->ref);
@@ -719,7 +719,7 @@ int pmf_register_driver(struct device_node *np,
 		return -EBUSY;
 	}
 
-	dev = kzalloc(sizeof(struct pmf_device), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
 		DBG("pmf: no memory !\n");
 		return -ENOMEM;
-- 
2.14.2

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

end of thread, other threads:[~2017-10-05 20:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-05 20:50 [PATCH 0/2] Power Mac: Adjustments for five function implementations SF Markus Elfring
2017-10-05 20:51 ` [PATCH 1/2] powermac: Delete an error message for a failed memory allocation in kw_i2c_host_init() SF Markus Elfring
2017-10-05 20:52 ` [PATCH 2/2] powermac: Improve a size determination in five 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).