Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xdrgen: Fix struct prefix for typedef types in program wrappers

The program templates for decoder/argument.j2 and encoder/result.j2
unconditionally add 'struct' prefix to all types. This is incorrect
when an RPC protocol specification lists a typedef'd basic type or
an enum as a procedure argument or result (e.g., NFSv2's fhandle or
stat), resulting in compiler errors when building generated C code.

Fixes: 4b132aacb076 ("tools: Add xdrgen")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+12 -1
+2 -1
tools/net/sunrpc/xdrgen/generators/__init__.py
··· 6 6 from jinja2 import Environment, FileSystemLoader, Template 7 7 8 8 from xdr_ast import _XdrAst, Specification, _RpcProgram, _XdrTypeSpecifier 9 - from xdr_ast import public_apis, pass_by_reference, get_header_name 9 + from xdr_ast import public_apis, pass_by_reference, structs, get_header_name 10 10 from xdr_parse import get_xdr_annotate 11 11 12 12 ··· 25 25 environment.globals["annotate"] = get_xdr_annotate() 26 26 environment.globals["public_apis"] = public_apis 27 27 environment.globals["pass_by_reference"] = pass_by_reference 28 + environment.globals["structs"] = structs 28 29 return environment 29 30 case _: 30 31 raise NotImplementedError("Language not supported")
+4
tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2
··· 14 14 {% if argument == 'void' %} 15 15 return xdrgen_decode_void(xdr); 16 16 {% else %} 17 + {% if argument in structs %} 17 18 struct {{ argument }} *argp = rqstp->rq_argp; 19 + {% else %} 20 + {{ argument }} *argp = rqstp->rq_argp; 21 + {% endif %} 18 22 19 23 return xdrgen_decode_{{ argument }}(xdr, argp); 20 24 {% endif %}
+6
tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2
··· 14 14 {% if result == 'void' %} 15 15 return xdrgen_encode_void(xdr); 16 16 {% else %} 17 + {% if result in structs %} 17 18 struct {{ result }} *resp = rqstp->rq_resp; 18 19 19 20 return xdrgen_encode_{{ result }}(xdr, resp); 21 + {% else %} 22 + {{ result }} *resp = rqstp->rq_resp; 23 + 24 + return xdrgen_encode_{{ result }}(xdr, *resp); 25 + {% endif %} 20 26 {% endif %} 21 27 }