Re: [PATCH v2 1/2] livetree: Simplify append_to_property()

David Gibson <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler
Message-ID <aKANP68-2mO_RmZu@zatzit>
On Fri, Aug 15, 2025 at 03:34:53PM +0200, Uwe Kleine-König wrote:
> 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.

The patch looks good, but I'll need a Signed-off-by line.

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

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmigDTQACgkQzQJF27ox
2GeDpg//UEAWXkYyd6lIQOJ5x0n5judgeIy54ZT+xbWsaMhcf/ps/8toQiM5f9Vn
R8ZlN3D2SOBLlYgB/fVVDgnQfs6fis1Kp5RgCuuwi0KMstVJuo0wLNUcwUCOXYo3
mcjl7HikdCrVJEdGHuLNmYUeiaT6j2FqCrI/Jba8Pah7TVZwKrvCAmg1KEJNWLbx
Nua7PAbW6+i4QX3+iSeWPNj4Ln9Jem2lNUuz7l2HMDC+SZpLKNeGjVwgD8SlUn5w
wKZnd/yi6QJIchAdGicGJ18NVg5B9L5Pb3zR6pw0OFiqL23NwMiFNlKd0+QyPA5e
resdPzN3sE7gNm/lgKa+dwknsaGWWGXh+wF75/Sdp9pNe9SmU5uzVrKQexzAj2+s
ULInLSSbNeG0QxNQnAlpyOQd17gF68+Pf9af4pym+payK8t52Ixmnb4wAIPpYwBR
p+sqsqRQ6LB2TzsPGQddefKEIV/dHEoixnNsSUFqA2d2BW1Gr2ZhMQwTtO9zUOIi
/F7N4iYwPJ9lM4V0wXe3waHzddvxJIAITOkNG4MEA30E4kafpwKwkiOjH9nzR/F2
UEwHNRbybyfqdmTtYOjrJ97yCo79xVk2Q2FP5zvz93/YbYgEh7qvNGumhAiyoe42
bK+IHT0Nri1cBX9vTCV1vR7+46aKPN8yxG71x86kLKOKt/9uXYQ=
=Q5gq
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.