diff options
author | pfg <pfg@FreeBSD.org> | 2017-01-18 15:23:40 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2017-01-18 15:23:40 +0000 |
commit | 42e9324682a0972e7d339d70498fb0c80fa98b1d (patch) | |
tree | 631a02ce7b78569917fe65be69a227dca59daf2f /usr.bin | |
parent | a76fe43d92f5b9c0f4e085f3c1c0ee84b42754f7 (diff) | |
download | FreeBSD-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)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rpcgen/rpc_cout.c | 3 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_svcout.c | 9 |
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 { |