[PATCH v3 1/2] livetree: Simplify append_to_property()
Uwe Kleine-König <[email protected]>
| Newsgroups | org.kernel.vger.devicetree-compiler |
|---|---|
| Message-ID | <eef88e559f5b9818c4c2311fa8a75ab6fd4508d5.1755512759.git.u.kleine-koenig@baylibre.com> |
The two if branches are quite similar. Build the property first (in case
it doesn't exist) and then the common parts can be done outside the if
block.
---
livetree.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/livetree.c b/livetree.c
index d51d05830b18..6127d604d528 100644
--- a/livetree.c
+++ b/livetree.c
@@ -340,20 +340,16 @@ void append_to_property(struct node *node,
char *name, const void *data, int len,
enum markertype type)
{
- struct data d;
struct property *p;
p = get_property(node, name);
- if (p) {
- d = data_add_marker(p->val, type, name);
- d = data_append_data(d, data, len);
- p->val = d;
- } else {
- d = data_add_marker(empty_data, type, name);
- d = data_append_data(d, data, len);
- p = build_property(name, d, NULL);
+ if (!p) {
+ p = build_property(name, empty_data, NULL);
add_property(node, p);
}
+
+ p->val = data_add_marker(p->val, type, name);
+ p->val = data_append_data(p->val, data, len);
}
struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
--
2.50.1