From 763c6ab4189c16cb61b5878dddcbd46d76535e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Mon, 18 Aug 2025 12:35:45 +0200 Subject: [PATCH] livetree: Simplify append_to_property() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Message-ID: Signed-off-by: David Gibson --- livetree.c | 14 +++++--------- 1 file 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)