aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>2025-08-18 12:35:45 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2025-08-19 09:24:37 +1000
commit763c6ab4189c16cb61b5878dddcbd46d76535e67 (patch)
treef4432241ae45523d978b46a8da341b41d720ee0f
parent739403f222420a2fade2f939d001f51da473b6af (diff)
downloaddtc-763c6ab4189c16cb61b5878dddcbd46d76535e67.zip
dtc-763c6ab4189c16cb61b5878dddcbd46d76535e67.tar.gz
dtc-763c6ab4189c16cb61b5878dddcbd46d76535e67.tar.bz2
livetree: Simplify append_to_property()
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. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Message-ID: <eef88e559f5b9818c4c2311fa8a75ab6fd4508d5.1755512759.git.u.kleine-koenig@baylibre.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--livetree.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/livetree.c b/livetree.c
index d51d058..6127d60 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)