Author: pfg
Date: Wed Jan 18 15:23:40 2017
New Revision: 312386
URL: https://svnweb.freebsd.org/changeset/base/312386

Log:
  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)

Modified:
  stable/10/usr.bin/rpcgen/rpc_cout.c
  stable/10/usr.bin/rpcgen/rpc_svcout.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/rpcgen/rpc_cout.c
==============================================================================
--- stable/10/usr.bin/rpcgen/rpc_cout.c Wed Jan 18 15:22:54 2017        
(r312385)
+++ stable/10/usr.bin/rpcgen/rpc_cout.c Wed Jan 18 15:23:40 2017        
(r312386)
@@ -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;
                }

Modified: stable/10/usr.bin/rpcgen/rpc_svcout.c
==============================================================================
--- stable/10/usr.bin/rpcgen/rpc_svcout.c       Wed Jan 18 15:22:54 2017        
(r312385)
+++ stable/10/usr.bin/rpcgen/rpc_svcout.c       Wed Jan 18 15:23:40 2017        
(r312386)
@@ -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, con
        /* 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 {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to