linux/tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_array.j2

{# SPDX-License-Identifier: GPL-2.0 #}

{% if annotate %}
/* typedef {{ name }} */
{% endif %}
{% if name in public_apis %}
bool
{% else %}
static bool __maybe_unused
{% endif %}
xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ classifier }}{{ name }} *ptr)
{
{% if annotate %}
	/* (variable-length array) */
{% endif %}
	if (xdr_stream_decode_u32(xdr, &ptr->count) < 0)
		return false;
{% if maxsize != "0" %}
	if (ptr->count > {{ maxsize }})
		return false;
{% endif %}
	for (u32 i = 0; i < ptr->count; i++)
		if (!xdrgen_decode_{{ type }}(xdr, &ptr->element[i]))
			return false;
	return true;
};