Re: [PATCH 1/3] Add alloc_marker

David Gibson <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler
Message-ID <Z8V30ae2praqHiPC@zatzit>
On Sat, Mar 01, 2025 at 06:55:02PM +0530, Ayush Singh wrote:
> - Add helper to allocate new marker
> 
> Signed-off-by: Ayush Singh <[email protected]>

Reviewed-by: David Gibson <[email protected]>

This patch is a reasonable cleanup, regardless of what happens with
the rest of the series.

> ---
>  data.c | 20 +++++++++++++++-----
>  dtc.h  |  2 ++
>  2 files changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/data.c b/data.c
> index 14734233ad8b7ebd38c3e62442b81aae66601806..913796f2e664d07cdc48e0cbf2ab5d6fe9978072 100644
> --- a/data.c
> +++ b/data.c
> @@ -228,11 +228,7 @@ struct data data_add_marker(struct data d, enum markertype type, char *ref)
>  {
>  	struct marker *m;
>  
> -	m = xmalloc(sizeof(*m));
> -	m->offset = d.len;
> -	m->type = type;
> -	m->ref = ref;
> -	m->next = NULL;
> +	m = alloc_marker(d.len, type, ref);
>  
>  	return data_append_markers(d, m);
>  }
> @@ -254,3 +250,17 @@ bool data_is_one_string(struct data d)
>  
>  	return true;
>  }
> +
> +struct marker *alloc_marker(unsigned int offset, enum markertype type,
> +			    char *ref)
> +{
> +	struct marker *m;
> +
> +	m = xmalloc(sizeof(*m));
> +	m->offset = offset;
> +	m->type = type;
> +	m->ref = ref;
> +	m->next = NULL;
> +
> +	return m;
> +}
> diff --git a/dtc.h b/dtc.h
> index 4c4aaca1fc417c9d93e904e64b2c40216ee1b093..86928e1eea9764fe5d74d6dbb987589d65d54b66 100644
> --- a/dtc.h
> +++ b/dtc.h
> @@ -183,6 +183,8 @@ struct data data_append_byte(struct data d, uint8_t byte);
>  struct data data_append_zeroes(struct data d, int len);
>  struct data data_append_align(struct data d, int align);
>  
> +struct marker *alloc_marker(unsigned int offset, enum markertype type,
> +			    char *ref);
>  struct data data_add_marker(struct data d, enum markertype type, char *ref);
>  
>  bool data_is_one_string(struct data d);
> 

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

iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmfFd9AACgkQzQJF27ox
2GfyvQ//ewpTQ5BKFdDow0hTUm/qn9Q954BjRm9QlCVuVFiI+5QKRyE/5LrMATnS
Hw1f5QBUzf+bMvaDUH+8fSNFon1rF0oVfITDflmDvmXuyJU7oCW79NaCMW3rWzkh
nb6e9fNcBsB+6GjjiosCcKqNhJQwVFYTjR5/WDybLKq/vhNQmgrNeShVFEA2D19N
UHZOzaX0XuzjWsWfU0rdlPDF1L1zWsi9+UzRYmhF0LgVmxPYVxvbvsgsmklybKU7
Hcbl6ke2x334VH8Eh6VbiUG79QHfKi+g6/XvNo9rC3/rQnqf/7cNhbBfw5kV8vgO
BGFj9f1r7XNum+UVXa67VsI0tYaXD1G96ujc9siEfZDqU4m9XgGXK7omjMGn29ke
JL4R+1ITUpyo6NzZPciKvLKcauMNH0I21PZ1X/q0W+jaowr06BdZsZc+M+sp6wP1
NN6/+UA4Wl6+G1fFYFq9htIrqF2WfCnHXJIzKrmNzu645v3Rh5fJbb5UcfFzALnb
6l+8HIW/q1NPZfJVKjy6KvxZmxrLU1fjUlMHSsQYDgXPKVqdlMPMGmaNS6falt1J
M9Dlhwf6H1YoU1cn9D891y05fqnbPNxRGL7ITBQmruJjLEq4Mok7PA9k007a4nx1
dU1MD6tevFJ46X2QYZEa8M+waAEMmDQCg/CqqpZpIdPYbbFbrlU=
=bHrx
-----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.