mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] TTY-goldfish: small adjustments for two function implementations
@ 2017-04-11 18:26 SF Markus Elfring
  2017-04-11 18:28 ` [PATCH 1/2] tty-goldfish: Use kcalloc() in goldfish_tty_create_driver() SF Markus Elfring
  2017-04-11 18:30 ` [PATCH 2/2] tty-goldfish: Adjust five checks for null pointers SF Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-04-11 18:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 11 Apr 2017 20:22:10 +0200

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

Markus Elfring (2):
  Use kcalloc() in goldfish_tty_create_driver()
  Adjust five checks for null pointers

 drivers/tty/goldfish.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.12.2

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

* [PATCH 1/2] tty-goldfish: Use kcalloc() in goldfish_tty_create_driver()
  2017-04-11 18:26 [PATCH 0/2] TTY-goldfish: small adjustments for two function implementations SF Markus Elfring
@ 2017-04-11 18:28 ` SF Markus Elfring
  2017-04-11 18:30 ` [PATCH 2/2] tty-goldfish: Adjust five checks for null pointers SF Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-04-11 18:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 11 Apr 2017 20:00:23 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/tty/goldfish.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 996bd473dd03..b92c3312ecd2 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -180,8 +180,8 @@ static int goldfish_tty_create_driver(void)
 	int ret;
 	struct tty_driver *tty;
 
-	goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) *
-				goldfish_tty_line_count, GFP_KERNEL);
+	goldfish_ttys = kcalloc(goldfish_tty_line_count, sizeof(*goldfish_ttys),
+				GFP_KERNEL);
 	if (goldfish_ttys == NULL) {
 		ret = -ENOMEM;
 		goto err_alloc_goldfish_ttys_failed;
-- 
2.12.2

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

* [PATCH 2/2] tty-goldfish: Adjust five checks for null pointers
  2017-04-11 18:26 [PATCH 0/2] TTY-goldfish: small adjustments for two function implementations SF Markus Elfring
  2017-04-11 18:28 ` [PATCH 1/2] tty-goldfish: Use kcalloc() in goldfish_tty_create_driver() SF Markus Elfring
@ 2017-04-11 18:30 ` SF Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-04-11 18:30 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 11 Apr 2017 20:15:30 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/tty/goldfish.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index b92c3312ecd2..a07e5b01c279 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -182,12 +182,12 @@ static int goldfish_tty_create_driver(void)
 
 	goldfish_ttys = kcalloc(goldfish_tty_line_count, sizeof(*goldfish_ttys),
 				GFP_KERNEL);
-	if (goldfish_ttys == NULL) {
+	if (!goldfish_ttys) {
 		ret = -ENOMEM;
 		goto err_alloc_goldfish_ttys_failed;
 	}
 	tty = alloc_tty_driver(goldfish_tty_line_count);
-	if (tty == NULL) {
+	if (!tty) {
 		ret = -ENOMEM;
 		goto err_alloc_tty_driver_failed;
 	}
@@ -235,15 +235,15 @@ static int goldfish_tty_probe(struct platform_device *pdev)
 	unsigned int line;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (r == NULL)
+	if (!r)
 		return -EINVAL;
 
 	base = ioremap(r->start, 0x1000);
-	if (base == NULL)
+	if (!base)
 		pr_err("goldfish_tty: unable to remap base\n");
 
 	r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (r == NULL)
+	if (!r)
 		goto err_unmap;
 
 	irq = r->start;
-- 
2.12.2

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

end of thread, other threads:[~2017-04-11 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 18:26 [PATCH 0/2] TTY-goldfish: small adjustments for two function implementations SF Markus Elfring
2017-04-11 18:28 ` [PATCH 1/2] tty-goldfish: Use kcalloc() in goldfish_tty_create_driver() SF Markus Elfring
2017-04-11 18:30 ` [PATCH 2/2] tty-goldfish: Adjust five checks for null pointers 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

Powered by JetHome