Refactor printing arguments to the xdr routines 14/12114/5
authorChas Williams <3chas3@gmail.com>
Mon, 23 Nov 2015 17:29:31 +0000 (12:29 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Mon, 21 Mar 2016 03:13:54 +0000 (23:13 -0400)
This makes some future changes a bit easier to read and implement.

Change-Id: I48eafa67659739865f43a0bcfe1f8a897a7a8940
Reviewed-on: https://gerrit.openafs.org/12114
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/rxgen/rpc_cout.c

index 6e8c383..30ec519 100644 (file)
@@ -199,6 +199,42 @@ space(void)
 }
 
 static void
+print_ifarg_val(char *objname, char *name)
+{
+    if (*objname == '&') {
+       if (brief_flag) {
+           f_print(fout, "%s.val", objname);
+       } else {
+           f_print(fout, "%s.%s_val", objname, name);
+       }
+    } else {
+       if (brief_flag) {
+           f_print(fout, "&%s->val", objname);
+       } else {
+           f_print(fout, "&%s->%s_val", objname, name);
+       }
+    }
+}
+
+static void
+print_ifarg_len(char *objname, char *name)
+{
+    if (*objname == '&') {
+       if (brief_flag) {
+           f_print(fout, "(u_int *)%s.len", objname);
+       } else {
+           f_print(fout, "(u_int *)%s.%s_len", objname, name);
+       }
+    } else {
+       if (brief_flag) {
+           f_print(fout, "(u_int *)&%s->len", objname);
+       } else {
+           f_print(fout, "(u_int *)&%s->%s_len", objname, name);
+       }
+    }
+}
+
+static void
 print_ifstat(int indent, char *prefix, char *type, relation rel, char *amax,
             char *objname, char *name)
 {
@@ -251,22 +287,9 @@ print_ifstat(int indent, char *prefix, char *type, relation rel, char *amax,
                print_ifopen(indent, "array");
                 print_ifarg("(caddr_t *)");
            }
-           if (*objname == '&') {
-               if (brief_flag) {
-                   f_print(fout, "%s.val, (u_int *)%s.len", objname, objname);
-               } else {
-                   f_print(fout, "%s.%s_val, (u_int *)%s.%s_len",
-                           objname, name, objname, name);
-               }
-           } else {
-               if (brief_flag) {
-                   f_print(fout, "&%s->val, (u_int *)&%s->len",
-                           objname, objname);
-               } else {
-                   f_print(fout, "&%s->%s_val, (u_int *)&%s->%s_len",
-                           objname, name, objname, name);
-               }
-           }
+           print_ifarg_val(objname, name);
+           f_print(fout, ", ");
+           print_ifarg_len(objname, name);
        }
        print_ifarg(amax);
        if (!alt) {