From: Andrew Deason Date: Tue, 10 Mar 2020 21:05:47 +0000 (-0500) Subject: rxgen: Properly generate brief union default arm X-Git-Tag: openafs-devel-1_9_0~124 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=abbadd3f4bf6fddc794b87d8d993ed6536c591e3 rxgen: Properly generate brief union default arm Commit 13ae3de3 (Add "brief" option to rxgen) added the -b option to rxgen, which (among other things) makes rxgen stop including the name of an RPC-L union type within its fields. That is, instead of this: struct foo_type { afs_int32 foo_tag; union { /* ... */ } foo_type_u; }; rxgen -b generates this: struct foo_type { afs_int32 foo_tag; union { /* ... */ } u; }; And all of the autogenerated XDR code is altered to use the 'u' field instead of foo_type_u. However, if a 'default:' arm is defined in the definition for the RPC-L union, the autogenerated XDR code still tries to reference the non-brief name (e.g. foo_type_u). This causes a build failure when actually trying to compile the generated .xdr.c, like so: foo.xdr.c:809:39: error: 'foo_type' has no member named 'foo_type_u' if (!xdr_bytes(xdrs, (char **)&objp->foo_type_u.xxx, &__len, FOO_MAX)) { ^ foo.xdr.c:812:11: error: 'foo_type' has no member named 'foo_type_u' *(&objp->foo_type_u.xxx) = __len; This happens because the portion of emit_union() that generates the XDR code for the default arm wasn't updated to use a different formatting string when 'brief_flag' is set, like the rest of emit_union. To fix this, just check for brief_flag and use 'briefformat' accordingly, like the other code that checks for brief_flag. Currently nothing in the tree uses the default arm of RPC-L unions with 'rxgen -b', but external callers could, or our future code may do so. Change-Id: Ifcebfc48a3a64c68fee12ba0d177ae19b0956c58 Reviewed-on: https://gerrit.openafs.org/14107 Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk --- diff --git a/src/rxgen/rpc_cout.c b/src/rxgen/rpc_cout.c index b0a686f..5c17a90 100644 --- a/src/rxgen/rpc_cout.c +++ b/src/rxgen/rpc_cout.c @@ -368,7 +368,10 @@ emit_union(definition * def) object = alloc(strlen(def->def_name) + strlen(format) + strlen(dflt->name) + 1); - s_print(object, format, def->def_name, dflt->name); + if (brief_flag) + s_print(object, briefformat, dflt->name); + else + s_print(object, format, def->def_name, dflt->name); print_ifstat(2, dflt->prefix, dflt->type, dflt->rel, dflt->array_max, object, dflt->name); free(object);