31 lines
565 B
Django/Jinja
31 lines
565 B
Django/Jinja
{# SPDX-License-Identifier: GPL-2.0 #}
|
|
|
|
{% if annotate %}
|
|
/* enum {{ name }} */
|
|
{% endif %}
|
|
{% if name in public_apis %}
|
|
bool
|
|
{% else %}
|
|
static bool __maybe_unused
|
|
{% endif %}
|
|
xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ name }} *ptr)
|
|
{
|
|
u32 val;
|
|
|
|
if (xdr_stream_decode_u32(xdr, &val) < 0)
|
|
return false;
|
|
{% if validate and enumerators %}
|
|
/* Compiler may optimize to a range check for dense enums */
|
|
switch (val) {
|
|
{% for e in enumerators %}
|
|
case {{ e.name }}:
|
|
{% endfor %}
|
|
break;
|
|
default:
|
|
return false;
|
|
}
|
|
{% endif %}
|
|
*ptr = val;
|
|
return true;
|
|
}
|