[PATCH 2/2] of: base: of_new_property(): use xstrdup() instead of strdup()

Antony Pavlov antonynpavlov at gmail.com
Mon Apr 17 03:42:10 PDT 2017


At the moment of_new_property() uses xfunctions for memory
allocation so we can use xstrdup() instead of strdup()
for code simplification.

A side effect of this commmit is that
the of_new_property() function can't return NULL
anymore if CONFIG_OFTREE is set.

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 drivers/of/base.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 1161ce9793..c9bdd91810 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1802,12 +1802,7 @@ struct property *of_new_property(struct device_node *node, const char *name,
 	struct property *prop;
 
 	prop = xzalloc(sizeof(*prop));
-	prop->name = strdup(name);
-	if (!prop->name) {
-		free(prop);
-		return NULL;
-	}
-
+	prop->name = xstrdup(name);
 	prop->length = len;
 	prop->value = xzalloc(len);
 
-- 
2.11.0




More information about the barebox mailing list