lkml.org 
[lkml]   [2017]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] of/unittest: Delete an error message for a failed memory allocation in three functions
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 May 2017 22:20:52 +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/of/unittest.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 987a1530282a..9554f83a0260 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -914,12 +914,9 @@ static int __init unittest_data_add(void)

/* creating copy */
unittest_data = kmemdup(__dtb_testcases_begin, size, GFP_KERNEL);
-
- if (!unittest_data) {
- pr_warn("%s: Failed to allocate memory for unittest_data; "
- "not running tests\n", __func__);
+ if (!unittest_data)
return -ENOMEM;
- }
+
of_fdt_unflatten_tree(unittest_data, NULL, &unittest_data_node);
if (!unittest_data_node) {
pr_warn("%s: No tree to attach; not running tests\n", __func__);
@@ -1593,12 +1590,9 @@ static int unittest_i2c_bus_probe(struct platform_device *pdev)
}

dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name);
-
std = devm_kzalloc(dev, sizeof(*std), GFP_KERNEL);
- if (!std) {
- dev_err(dev, "Failed to allocate unittest i2c data\n");
+ if (!std)
return -ENOMEM;
- }

/* link them together */
std->pdev = pdev;
@@ -2062,10 +2056,8 @@ static int __init overlay_data_add(int onum)
* will create pointers to the passed in FDT in the EDT.
*/
info->data = kmemdup(info->dtb_begin, size, GFP_KERNEL);
- if (!info->data) {
- pr_err("unable to allocate memory for data, %d\n", onum);
+ if (!info->data)
return 0;
- }

of_fdt_unflatten_tree(info->data, NULL, &info->np_overlay);
if (!info->np_overlay) {
--
2.12.3
\
 
 \ /
  Last update: 2017-05-10 22:34    [W:0.029 / U:3.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site