From: Andrew Deason Date: Thu, 15 Oct 2009 17:48:08 +0000 (-0400) Subject: Fix rxgen-generated warnings X-Git-Tag: openafs-devel-1_5_66~57 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=508bcd69b5ad55bcadf26d9b748f175c7a33ce77;p=packages%2Fo%2Fopenafs.git Fix rxgen-generated warnings Prevent rxgen from generating code that produces warnings at compile time. * Add print_ifarg_with_cast(). Used within print_ifstat() to generate a member in an argument list complete with a type cast. The type cast may be a pointer to the type or the type depending on the value of the 'ptr_to' parameter. * When print_ifstat() generates the output for an opaque vector, cast the object to 'caddr_t' as xdr_opaque() accepts an argument of type 'caddr_t'. * When print_ifstat() generates the output for an opaque array, cast the object to 'char **' because xdr_bytes() accepts an argument of type 'char **'. * When print_ifstat() generates the output for any array that is not opaque or string, cast the object to 'caddr_t' because all of the xdr_XXX() functions other than xdr_opaque and xdr_bytes accept an argument of type 'caddr_t'. * When print_ifstat() generates the output for an alias, cast the output to a pointer to the specified type because xdr_ accepts an argument of type ' *'. This addresses warnings generated when compiling fsint/Kvice.xdr.c and fsint/afsint.xdr.c. Reviewed-on: http://gerrit.openafs.org/664 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/README.WARNINGS b/README.WARNINGS index d7fc5f9b2..79a9c43ff 100644 --- a/README.WARNINGS +++ b/README.WARNINGS @@ -59,7 +59,6 @@ butc/recoverDb.c : all : pointer target issues (XXX) butc/tcudbprocs.c : all : ubik_Call butc/dump.c : all : pointer types (XXX) comerr/error_table.c : all : Autogenerated file with unused labels -fsint/afsint.xdr.c : all : rxgen opaque vectors problem kauth/kaprocs.c : all : XXX kauth/kaserver.c : all : ExtendedCellInfo kauth/krb_udp.c : all : XXX diff --git a/src/fsint/Makefile.in b/src/fsint/Makefile.in index fa1c197d6..5704a7b54 100644 --- a/src/fsint/Makefile.in +++ b/src/fsint/Makefile.in @@ -107,12 +107,7 @@ afsint.h: common.xg afsint.xg afscbint.h: common.xg afscbint.xg ${RXGEN} -A -x -h -o afscbint.h ${srcdir}/afscbint.xg -# Files with warnings -# rpcgen currently handles opaque vectors badly -# - it relies on char a[1]; &a == a; which leads to type errors - afsint.xdr.o: afsint.xdr.c - $(CC) $(CFLAGS) -c @CFLAGS_NOERROR@ $< # # Installation targets diff --git a/src/rxgen/rpc_cout.c b/src/rxgen/rpc_cout.c index 38bd0b4e7..0a24e2327 100644 --- a/src/rxgen/rpc_cout.c +++ b/src/rxgen/rpc_cout.c @@ -50,6 +50,7 @@ static void print_header(definition * def); static void print_trailer(void); static void print_ifopen(int indent, char *name); static void print_ifarg(char *arg); +static void print_ifarg_with_cast(int ptr_to, char *type, char *arg); static void print_ifsizeof(char *prefix, char *type); static void print_ifclose(int indent); static void space(void); @@ -159,6 +160,12 @@ print_ifarg(char *arg) } +static void +print_ifarg_with_cast(int ptr_to, char *type, char *arg) +{ + f_print(fout, ptr_to ? ", (%s *) %s" : ", (%s) %s", type, arg); +} + static void print_ifsizeof(char *prefix, char *type) { @@ -194,12 +201,12 @@ print_ifstat(int indent, char *prefix, char *type, relation rel, char *amax, char *objname, char *name) { char *alt = NULL; + char *altcast = NULL; switch (rel) { case REL_POINTER: print_ifopen(indent, "pointer"); - print_ifarg("(char **)"); - f_print(fout, "%s", objname); + print_ifarg_with_cast(1, "char *", objname); print_ifsizeof(prefix, type); break; case REL_VECTOR: @@ -207,14 +214,18 @@ print_ifstat(int indent, char *prefix, char *type, relation rel, char *amax, alt = "string"; } else if (streq(type, "opaque")) { alt = "opaque"; + altcast = "caddr_t"; } if (alt) { print_ifopen(indent, alt); - print_ifarg(objname); + if (altcast) { + print_ifarg_with_cast(0, altcast, objname); + } else { + print_ifarg(objname); + } } else { print_ifopen(indent, "vector"); - print_ifarg("(char *)"); - f_print(fout, "%s", objname); + print_ifarg_with_cast(1, "char", objname); } print_ifarg(amax); if (!alt) { @@ -233,10 +244,11 @@ print_ifstat(int indent, char *prefix, char *type, relation rel, char *amax, } else { if (alt) { print_ifopen(indent, alt); + print_ifarg("(char **)"); } else { print_ifopen(indent, "array"); + print_ifarg("(caddr_t *)"); } - print_ifarg("(char **)"); if (*objname == '&') { f_print(fout, "%s.%s_val, (u_int *)%s.%s_len", objname, name, objname, name); @@ -252,7 +264,7 @@ print_ifstat(int indent, char *prefix, char *type, relation rel, char *amax, break; case REL_ALIAS: print_ifopen(indent, type); - print_ifarg(objname); + print_ifarg_with_cast(1, type, objname); break; } print_ifclose(indent);