mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-14 00:37:41 -04:00
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:
parent
739403f222
commit
763c6ab418
1 changed files with 5 additions and 9 deletions
14
livetree.c
14
livetree.c
|
@ -340,20 +340,16 @@ void append_to_property(struct node *node,
|
||||||
char *name, const void *data, int len,
|
char *name, const void *data, int len,
|
||||||
enum markertype type)
|
enum markertype type)
|
||||||
{
|
{
|
||||||
struct data d;
|
|
||||||
struct property *p;
|
struct property *p;
|
||||||
|
|
||||||
p = get_property(node, name);
|
p = get_property(node, name);
|
||||||
if (p) {
|
if (!p) {
|
||||||
d = data_add_marker(p->val, type, name);
|
p = build_property(name, empty_data, NULL);
|
||||||
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);
|
|
||||||
add_property(node, p);
|
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)
|
struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue