xref: /linux/tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_array.j2 (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1{# SPDX-License-Identifier: GPL-2.0 #}
2{% if annotate %}
3	/* member {{ name }} (variable-length array) */
4{% endif %}
5	if (value->{{ name }}.count > {{ maxsize }})
6		return false;
7	if (xdr_stream_encode_u32(xdr, value->{{ name }}.count) != XDR_UNIT)
8		return false;
9	for (u32 i = 0; i < value->{{ name }}.count; i++)
10{% if type in pass_by_reference %}
11		if (!xdrgen_encode_{{ type }}(xdr, &value->{{ name }}.element[i]))
12{% else %}
13		if (!xdrgen_encode_{{ type }}(xdr, value->{{ name }}.element[i]))
14{% endif %}
15			return false;
16