summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-01-18 15:23:40 +0000
committerpfg <pfg@FreeBSD.org>2017-01-18 15:23:40 +0000
commit42e9324682a0972e7d339d70498fb0c80fa98b1d (patch)
tree631a02ce7b78569917fe65be69a227dca59daf2f
parenta76fe43d92f5b9c0f4e085f3c1c0ee84b42754f7 (diff)
downloadFreeBSD-src-42e9324682a0972e7d339d70498fb0c80fa98b1d.zip
FreeBSD-src-42e9324682a0972e7d339d70498fb0c80fa98b1d.tar.gz
MFC r311947, r311981:
rpcgen(1): Avoid unused variable warning on generated code. Avoid "unused variable 'i'" warnings in generated .c files by only emitting the "int i;" for non-opaque arrays. Opaque arrays use xdr_opaque() rather than iterating over the array. Obtained from: OpenBSD (CVS rev 1.28) rpcgen(1): Check getrlimit() return for generated code. Obtained from: NetBSD (CVS rev 1.27, 1.28)
-rw-r--r--usr.bin/rpcgen/rpc_cout.c3
-rw-r--r--usr.bin/rpcgen/rpc_svcout.c9
2 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c
index 4c36ce6..45f0d90 100644
--- a/usr.bin/rpcgen/rpc_cout.c
+++ b/usr.bin/rpcgen/rpc_cout.c
@@ -551,7 +551,8 @@ emit_struct(definition *def)
}
for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
- if (dl->decl.rel == REL_VECTOR){
+ if (dl->decl.rel == REL_VECTOR &&
+ strcmp(dl->decl.type, "opaque") != 0){
f_print(fout, "\tint i;\n");
break;
}
diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c
index 4b951a3..e868c01 100644
--- a/usr.bin/rpcgen/rpc_svcout.c
+++ b/usr.bin/rpcgen/rpc_svcout.c
@@ -728,7 +728,8 @@ write_timeout_func(void)
if (tirpcflag) {
f_print(fout, "\t\t\tstruct rlimit rl;\n\n");
f_print(fout, "\t\t\trl.rlim_max = 0;\n");
- f_print(fout, "\t\t\tgetrlimit(RLIMIT_NOFILE, &rl);\n");
+ f_print(fout, "\t\t\tif (getrlimit(RLIMIT_NOFILE, &rl) == -1)\n");
+ f_print(fout, "\t\t\t\treturn;\n");
f_print(fout, "\t\t\tif ((size = rl.rlim_max) == 0) {\n");
if (mtflag)
@@ -902,7 +903,11 @@ write_rpc_svc_fg(const char *infile, const char *sp)
/* get number of file descriptors */
if (tirpcflag) {
f_print(fout, "%srl.rlim_max = 0;\n", sp);
- f_print(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp);
+ f_print(fout, "%sif (getrlimit(RLIMIT_NOFILE, &rl) == -1) {\n",
+ sp);
+ f_print(fout, "%s\tperror(\"getrlimit\");\n", sp);
+ f_print(fout, "%s\texit(1);\n", sp);
+ f_print(fout, "%s}\n", sp);
f_print(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp);
f_print(fout, "%s\texit(1);\n", sp);
} else {
OpenPOWER on IntegriCloud