rxgen, kauth: Set but not used variables
[openafs.git] / src / rxgen / rpc_parse.c
index 873e308..28f07fa 100644 (file)
@@ -6,37 +6,35 @@
  * may copy or modify Sun RPC without charge, but are not authorized
  * to license or distribute it to anyone else except as part of a product or
  * program developed by the user.
- * 
+ *
  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
+ *
  * Sun RPC is provided with no support and without any obligation on the
  * part of Sun Microsystems, Inc. to assist in its use, correction,
  * modification or enhancement.
- * 
+ *
  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  * OR ANY PART THEREOF.
- * 
+ *
  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  * or profits or other special, indirect and consequential damages, even if
  * Sun has been advised of the possibility of such damages.
- * 
+ *
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
 
 /*
- * rpc_parse.c, Parser for the RPC protocol compiler 
+ * rpc_parse.c, Parser for the RPC protocol compiler
  * Copyright (C) 1987 Sun Microsystems, Inc.
  */
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -161,7 +159,7 @@ get_definition(void)
     token tok;
 
     defp = ALLOC(definition);
-    memset((char *)defp, 0, sizeof(definition));
+    memset(defp, 0, sizeof(definition));
     get_token(&tok);
     switch (tok.kind) {
     case TOK_STRUCT:
@@ -880,7 +878,7 @@ analyze_ProcParams(definition * defp, token * tokp)
     do {
        get_token(tokp);
        Proc_list = ALLOC(proc1_list);
-       memset((char *)Proc_list, 0, sizeof(proc1_list));
+       memset(Proc_list, 0, sizeof(proc1_list));
        Proc_list->pl.param_flag = 0;
        switch (tokp->kind) {
        case TOK_IN:
@@ -902,7 +900,7 @@ analyze_ProcParams(definition * defp, token * tokp)
        *Proc_listp = Proc_list;
        Proc_listp = &Proc_list->next;
        decls = ALLOC(decl_list);
-       memset((char *)decls, 0, sizeof(decl_list));
+       memset(decls, 0, sizeof(decl_list));
     if (tokp->kind != TOK_RPAREN)
         decls->decl = dec;
        *tailp = decls;
@@ -933,7 +931,7 @@ static void
 handle_split_proc(definition * defp, int multi_flag)
 {
     char *startname = SplitStart, *endname = SplitEnd;
-    int numofparams;
+    int numofparams = 0;
 
     if (!startname)
        startname = "Start";
@@ -1110,21 +1108,30 @@ cs_Proc_CodeGeneration(definition * defp, int split_flag, char *procheader)
     }
 }
 
-
 static void
 cs_ProcName_setup(definition * defp, char *procheader, int split_flag)
 {
     proc1_list *plist;
+    char *first_arg;
 
-    if (!cflag) {
+    if (ansic_flag) {
+       if (split_flag) {
+           first_arg = "struct rx_call *z_call";
+       } else {
+           first_arg = "struct rx_connection *z_conn";
+       }
+    } else {
        if (split_flag) {
-           f_print(fout, "int %s%s%s%s(z_call", procheader, prefix,
-                   PackagePrefix[PackageIndex], defp->pc.proc_name);
+           first_arg = "z_call";
        } else {
-           f_print(fout, "int %s%s%s%s(z_conn", procheader, prefix,
-                   PackagePrefix[PackageIndex], defp->pc.proc_name);
+           first_arg = "z_conn";
        }
     }
+
+    if (!cflag) {
+       f_print(fout, "int %s%s%s%s(%s", procheader, prefix,
+               PackagePrefix[PackageIndex], defp->pc.proc_name, first_arg);
+    }
     if ((strlen(procheader) + strlen(prefix) +
         strlen(PackagePrefix[PackageIndex]) + strlen(defp->pc.proc_name)) >=
        MAX_FUNCTION_NAME_LEN) {
@@ -1133,24 +1140,36 @@ cs_ProcName_setup(definition * defp, char *procheader, int split_flag)
     if (!cflag) {
        for (plist = defp->pc.plists; plist; plist = plist->next) {
            if (plist->component_kind == DEF_PARAM) {
-               plist->pl.param_flag &= ~PROCESSED_PARAM;
-               f_print(fout, ", %s", plist->pl.param_name);
+               if (ansic_flag) {
+                   if (plist->pl.param_flag & OUT_STRING) {
+                       f_print(fout, ",%s *%s", plist->pl.param_type,
+                               plist->pl.param_name);
+                   } else {
+                       f_print(fout, ",%s %s", plist->pl.param_type,
+                               plist->pl.param_name);
+                   }
+               } else {
+                   f_print(fout, ", %s", plist->pl.param_name);
+                   plist->pl.param_flag &= ~PROCESSED_PARAM;
+               }
            }
        }
        f_print(fout, ")\n");
     }
 }
 
-
 static void
 cs_ProcParams_setup(definition * defp, int split_flag)
 {
     proc1_list *plist, *plist1;
 
+    if (ansic_flag)
+       return;
+
     if (!split_flag)
-       f_print(fout, "\tregister struct rx_connection *z_conn;\n");
+       f_print(fout, "\tstruct rx_connection *z_conn;\n");
     if (split_flag) {
-       f_print(fout, "\tregister struct rx_call *z_call;\n");
+       f_print(fout, "\tstruct rx_call *z_call;\n");
     }
     for (plist = defp->pc.plists; plist; plist = plist->next) {
        if (plist->component_kind == DEF_PARAM
@@ -1448,6 +1467,7 @@ ss_ProcParams_setup(definition * defp, int *somefrees)
                    switch (defp1->pc.rel) {
                    case REL_ARRAY:
                    case REL_POINTER:
+                   default:
                        break;
                    }
                }
@@ -1507,6 +1527,8 @@ ss_ProcSpecial_setup(definition * defp, int *somefrees)
                        f_print(fout, "\n\t%s = 0;", plist->pl.param_name);
                        plist->pl.string_name = NULL;
                        break;
+                   default:
+                       break;
                    }
                }
            }
@@ -1628,14 +1650,8 @@ ss_ProcTail_setup(definition * defp, int somefrees)
        f_print(fout, "\tz_xdrs->x_op = XDR_FREE;\n");
     for (plist = defp->pc.plists; plist; plist = plist->next) {
        if (plist->component_kind == DEF_PARAM
-           && (plist->pl.param_flag & FREETHIS_PARAM)) {
-           char *dot = "", *extens = "";
-           if (plist->pl.string_name) {
-               dot = ".";
-               extens = plist->pl.string_name;
-           }
+               && (plist->pl.param_flag & FREETHIS_PARAM))
            f_print(fout, "\tif (!%s) goto fail1;\n", plist->scode);
-       }
     }
     for (listp = typedef_defined; listp != NULL; listp = listp->next) {
        defp1 = (definition *) listp->val;
@@ -1656,6 +1672,8 @@ ss_ProcTail_setup(definition * defp, int somefrees)
                        f_print(fout, "\tif (!%s) goto fail1;\n",
                                plist->scode);
                        break;
+                   default:
+                       break;
                    }
                }
            }
@@ -1742,8 +1760,14 @@ ucs_ProcName_setup(definition * defp, char *procheader, int split_flag)
     proc1_list *plist;
 
     if (!cflag) {
-      f_print(fout, "int %s%s%s%s(aclient, aflags", procheader, prefix,
-             PackagePrefix[PackageIndex], defp->pc.proc_name);
+       if (ansic_flag) {
+           f_print(fout, "int %s%s%s%s(struct ubik_client *aclient, afs_int32 aflags",
+                         procheader, prefix, PackagePrefix[PackageIndex],
+                         defp->pc.proc_name);
+       } else {
+           f_print(fout, "int %s%s%s%s(aclient, aflags", procheader, prefix,
+                         PackagePrefix[PackageIndex], defp->pc.proc_name);
+       }
     }
     if ((strlen(procheader) + strlen(prefix) +
         strlen(PackagePrefix[PackageIndex]) + strlen(defp->pc.proc_name)) >=
@@ -1753,8 +1777,18 @@ ucs_ProcName_setup(definition * defp, char *procheader, int split_flag)
     if (!cflag) {
        for (plist = defp->pc.plists; plist; plist = plist->next) {
            if (plist->component_kind == DEF_PARAM) {
-               plist->pl.param_flag &= ~PROCESSED_PARAM;
-               f_print(fout, ", %s", plist->pl.param_name);
+               if (ansic_flag) {
+                   if (plist->pl.param_flag & OUT_STRING) {
+                       f_print(fout, ",%s *%s", plist->pl.param_type,
+                               plist->pl.param_name);
+                   } else {
+                       f_print(fout, ",%s %s", plist->pl.param_type,
+                               plist->pl.param_name);
+                   }
+               } else {
+                   plist->pl.param_flag &= ~PROCESSED_PARAM;
+                   f_print(fout, ", %s", plist->pl.param_name);
+               }
            }
        }
        f_print(fout, ")\n");
@@ -1767,7 +1801,10 @@ ucs_ProcParams_setup(definition * defp, int split_flag)
 {
     proc1_list *plist, *plist1;
 
-    f_print(fout, "\tregister struct ubik_client *aclient;\n\tafs_int32 aflags;\n");
+    if (ansic_flag)
+       return;
+
+    f_print(fout, "\tstruct ubik_client *aclient;\n\tafs_int32 aflags;\n");
     for (plist = defp->pc.plists; plist; plist = plist->next) {
        if (plist->component_kind == DEF_PARAM
            && !(plist->pl.param_flag & PROCESSED_PARAM)) {
@@ -1806,9 +1843,9 @@ ucs_ProcTail_setup(definition * defp, int split_flag)
     proc1_list *plist;
 
     f_print(fout, "{\tafs_int32 rcode, code, newHost, thisHost, i, _ucount;\n");
-    f_print(fout, "\tint chaseCount, pass, needsync, inlist;\n");
+    f_print(fout, "\tint chaseCount, pass, needsync;\n");
 #if 0 /* goes with block below */
-    f_print(fout, "\tint j;\n");
+    f_print(fout, "\tint j, inlist;\n");
 #endif
     f_print(fout, "\tstruct rx_connection *tc;\n");
     f_print(fout, "\tstruct rx_peer *rxp;\n");
@@ -1819,8 +1856,9 @@ ucs_ProcTail_setup(definition * defp, int split_flag)
     f_print(fout, "\t restart:\n");
     f_print(fout, "\torigLevel = aclient->initializationState;\n");
     f_print(fout, "\trcode = UNOSERVERS;\n");
-    f_print(fout, "\tchaseCount = inlist = needsync = 0;\n\n");
+    f_print(fout, "\tchaseCount = needsync = 0;\n\n");
 #if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
+    f_print(fout, "\tinlist = 0;\n");
     f_print(fout, "\tLOCK_UCLNT_CACHE;\n");
     f_print(fout, "\tfor (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {\n");
     f_print(fout, "\t\tif (calls_needsync[j] == (int *)%s%s%s) {\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
@@ -1886,7 +1924,7 @@ ucs_ProcTail_setup(definition * defp, int split_flag)
     f_print(fout, "\t\tif ((pass == 0) && (aclient->states[_ucount] & CFLastFailed)) {\n");
     f_print(fout, "\t\t\tcontinue;       /* this guy's down */\n");
     f_print(fout, "\t\t}\n");
-    
+
     f_print(fout, "\t\trcode = %s%s%s(tc\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
     for (plist = defp->pc.plists; plist; plist = plist->next) {
        if (plist->component_kind == DEF_PARAM) {
@@ -1915,15 +1953,16 @@ ucs_ProcTail_setup(definition * defp, int split_flag)
     f_print(fout, "\t}                           /*p */\n\n");
     f_print(fout, "\tdone:\n");
     f_print(fout, "\tif (needsync) {\n");
-    f_print(fout, "\t\tif (!inlist) {          /* Remember proc call that needs sync site */\n");
+
 #if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
+    f_print(fout, "\t\tif (!inlist) {          /* Remember proc call that needs sync site */\n");
     f_print(fout, "\t\t\tLOCK_UCLNT_CACHE;\n");
     f_print(fout, "\t\t\tcalls_needsync[synccount % SYNCCOUNT] = (int *)%s%s%s;\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
     f_print(fout, "\t\t\tsynccount++;\n");
     f_print(fout, "\t\t\tUNLOCK_UCLNT_CACHE;\n");
-#endif
     f_print(fout, "\t\t\tinlist = 1;\n");
     f_print(fout, "\t\t}\n");
+#endif
     f_print(fout, "\t\tif (!rcode) {           /* Remember the sync site - cmd successful */\n");
     f_print(fout, "\t\t\trxp = rx_PeerOf(aclient->conns[_ucount]);\n");
     f_print(fout, "\t\t\taclient->syncSite = rx_HostOf(rxp);\n");
@@ -2026,7 +2065,7 @@ er_ProcProcsArray_setup(void)
 static void
 er_ProcMainBody_setup(void)
 {
-    f_print(fout, "int %s%sExecuteRequest(register struct rx_call *z_call)\n",
+    f_print(fout, "int %s%sExecuteRequest(struct rx_call *z_call)\n",
            prefix, PackagePrefix[PackageIndex]);
     f_print(fout, "{\n\tint op;\n");
     f_print(fout, "\tXDR z_xdrs;\n");
@@ -2048,7 +2087,7 @@ static void
 er_HeadofOldStyleProc_setup(void)
 {
     f_print(fout,
-           "\nint %s%sExecuteRequest (register struct rx_call *z_call)\n",
+           "\nint %s%sExecuteRequest (struct rx_call *z_call)\n",
            prefix,
            (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
     f_print(fout, "{\n");
@@ -2111,6 +2150,38 @@ er_TailofOldStyleProc_setup(void)
     f_print(fout, "\treturn z_result;\n}\n");
 }
 
+static void
+h_ProcMainBody_setup(void)
+{
+    f_print(fout,"\nextern int %s%sExecuteRequest(struct rx_call *);\n",
+           prefix, PackagePrefix[PackageIndex]);
+}
+
+static void
+h_HeadofOldStyleProc_setup(void)
+{
+    f_print(fout,"\nextern int %s%sExecuteRequest(struct rx_call *);\n",
+           prefix,
+           (combinepackages ? MasterPrefix : PackagePrefix[PackageIndex]));
+}
+
+void
+h_Proc_CodeGeneration(void)
+{
+    int temp;
+
+    temp = PackageIndex;
+    if (!combinepackages)
+        PackageIndex = 0;
+    for (; PackageIndex <= temp; PackageIndex++) {
+       if (combinepackages || opcode_holes_exist()) {
+           h_HeadofOldStyleProc_setup();
+       } else {
+            h_ProcMainBody_setup();
+       }
+    }
+    PackageIndex = temp;
+}
 
 void
 h_opcode_stats(void)