summaryrefslogtreecommitdiffstats
path: root/usr.bin/rpcgen/rpc_svcout.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-01-18 15:22:54 +0000
committerpfg <pfg@FreeBSD.org>2017-01-18 15:22:54 +0000
commit4d4bfe27534638421ca344bba7e3ed69a6008615 (patch)
tree4b1223c701ca776741d44790e7198f21586ec90b /usr.bin/rpcgen/rpc_svcout.c
parentfefedac602874fa19643279757c8069e48c5e97b (diff)
downloadFreeBSD-src-4d4bfe27534638421ca344bba7e3ed69a6008615.zip
FreeBSD-src-4d4bfe27534638421ca344bba7e3ed69a6008615.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/rpcgen/rpc_svcout.c')
-rw-r--r--usr.bin/rpcgen/rpc_svcout.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c
index aa5a86a..3c6d082 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