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>
This commit is contained in:
Uwe Kleine-König 2025-08-18 12:35:45 +02:00 committed by David Gibson
parent 739403f222
commit 763c6ab418

View file

@ -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)