[PATCH 14/21] gendispatch: Cluster, don't capture if not needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We were using parenteses for grouping admin|remote even though we didn't
need to capture what's in it.  That caused some changes to be grater
than needed and, to be honest, some confusion as well.  Let's use it as
it should be used.  It'll also make future changes more consistent.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/rpc/gendispatch.pl | 118 ++++++++++++++++++++++++-------------------------
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 5c99409edb26..29f2c6ac033b 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -523,16 +523,16 @@ elsif ($mode eq "server") {
                     push(@free_list,
                          "    virObjectUnref(snapshot);\n" .
                          "    virObjectUnref(dom);");
-                } elsif ($args_member =~ m/^(?:(admin|remote)_string|remote_uuid) (\S+)<\S+>;/) {
+                } elsif ($args_member =~ m/^(?:(?:admin|remote)_string|remote_uuid) (\S+)<\S+>;/) {
                     push_privconn(\@args_list);
-                    push(@args_list, "args->$2.$2_val");
-                    push(@args_list, "args->$2.$2_len");
-                } elsif ($args_member =~ m/^(?:opaque|(admin|remote)_nonnull_string) (\S+)<\S+>;(.*)$/) {
+                    push(@args_list, "args->$1.$1_val");
+                    push(@args_list, "args->$1.$1_len");
+                } elsif ($args_member =~ m/^(?:opaque|(?:admin|remote)_nonnull_string) (\S+)<\S+>;(.*)$/) {
                     push_privconn(\@args_list);

                     my $cast = "";
-                    my $arg_name = $2;
-                    my $annotation = $3;
+                    my $arg_name = $1;
+                    my $annotation = $2;

                     if ($annotation ne "") {
                         if ($annotation =~ m/\s*\/\*\s*(.*)\s*\*\//) {
@@ -571,16 +571,16 @@ elsif ($mode eq "server") {
                     push_privconn(\@args_list);

                     push(@args_list, "(unsigned char *) args->$1");
-                } elsif ($args_member =~ m/^(admin|remote)_string (\S+);/) {
+                } elsif ($args_member =~ m/^(?:admin|remote)_string (\S+);/) {
                     push_privconn(\@args_list);

-                    push(@vars_list, "char *$2");
-                    push(@optionals_list, "$2");
-                    push(@args_list, "$2");
-                } elsif ($args_member =~ m/^(admin|remote)_nonnull_string (\S+);/) {
+                    push(@vars_list, "char *$1");
+                    push(@optionals_list, "$1");
+                    push(@args_list, "$1");
+                } elsif ($args_member =~ m/^(?:admin|remote)_nonnull_string (\S+);/) {
                     push_privconn(\@args_list);

-                    push(@args_list, "args->$2");
+                    push(@args_list, "args->$1");
                 } elsif ($args_member =~ m/^(unsigned )?int (\S+);/) {
                     push_privconn(\@args_list);

@@ -637,52 +637,52 @@ elsif ($mode eq "server") {
                     } else {
                         die "unhandled type for multi-return-value: $ret_member";
                     }
-                } elsif ($ret_member =~ m/^(admin|remote)_nonnull_string (\S+)<(\S+)>;\s*\/\*\s*insert@(\d+)\s*\*\//) {
+                } elsif ($ret_member =~ m/^(?:admin|remote)_nonnull_string (\S+)<(\S+)>;\s*\/\*\s*insert@(\d+)\s*\*\//) {
                     push(@vars_list, "int len");
-                    splice(@args_list, int($4), 0, ("ret->$2.$2_val"));
-                    push(@ret_list, "ret->$2.$2_len = len;");
-                    push(@free_list_on_error, "VIR_FREE(ret->$2.$2_val);");
+                    splice(@args_list, int($3), 0, ("ret->$1.$1_val"));
+                    push(@ret_list, "ret->$1.$1_len = len;");
+                    push(@free_list_on_error, "VIR_FREE(ret->$1.$1_val);");
                     $single_ret_var = "len";
                     $single_ret_by_ref = 0;
                     $single_ret_check = " < 0";
                     $single_ret_as_list = 1;
-                    $single_ret_list_name = $2;
-                    $single_ret_list_max_var = "max$2";
-                    $single_ret_list_max_define = $3;
+                    $single_ret_list_name = $1;
+                    $single_ret_list_max_var = "max$1";
+                    $single_ret_list_max_define = $2;
                 } elsif ($ret_member =~ m/^(admin|remote)_nonnull_string (\S+)<\S+>;/) {
                     # error out on unannotated arrays
                     die "$1_nonnull_string array without insert@<offset> annotation: $ret_member";
-                } elsif ($ret_member =~ m/^(admin|remote)_nonnull_string (\S+);/) {
+                } elsif ($ret_member =~ m/^(?:admin|remote)_nonnull_string (\S+);/) {
                     if ($call->{ProcName} eq "ConnectGetType") {
                         # SPECIAL: virConnectGetType returns a constant string that must
                         #          not be freed. Therefore, duplicate the string here.
-                        push(@vars_list, "const char *$2");
+                        push(@vars_list, "const char *$1");
                         push(@ret_list, "/* We have to VIR_STRDUP because remoteDispatchClientRequest will");
                         push(@ret_list, " * free this string after it's been serialised. */");
                         push(@ret_list, "if (VIR_STRDUP(ret->type, type) < 0)");
                         push(@ret_list, "    goto cleanup;");
                     } else {
-                        push(@vars_list, "char *$2");
-                        push(@ret_list, "ret->$2 = $2;");
+                        push(@vars_list, "char *$1");
+                        push(@ret_list, "ret->$1 = $1;");
                     }

-                    $single_ret_var = $2;
+                    $single_ret_var = $1;
                     $single_ret_by_ref = 0;
                     $single_ret_check = " == NULL";
-                } elsif ($ret_member =~ m/^(admin|remote)_string (\S+);/) {
-                    push(@vars_list, "char *$2 = NULL");
-                    push(@vars_list, "char **$2_p = NULL");
-                    push(@ret_list, "ret->$2 = $2_p;");
-                    push(@free_list, "    VIR_FREE($2);");
-                    push(@free_list_on_error, "VIR_FREE($2_p);");
+                } elsif ($ret_member =~ m/^(?:admin|remote)_string (\S+);/) {
+                    push(@vars_list, "char *$1 = NULL");
+                    push(@vars_list, "char **$1_p = NULL");
+                    push(@ret_list, "ret->$1 = $1_p;");
+                    push(@free_list, "    VIR_FREE($1);");
+                    push(@free_list_on_error, "VIR_FREE($1_p);");
                     push(@prepare_ret_list,
-                         "if (VIR_ALLOC($2_p) < 0)\n" .
+                         "if (VIR_ALLOC($1_p) < 0)\n" .
                          "        goto cleanup;\n" .
                          "\n" .
-                         "    if (VIR_STRDUP(*$2_p, $2) < 0)\n".
+                         "    if (VIR_STRDUP(*$1_p, $1) < 0)\n".
                          "        goto cleanup;\n");

-                    $single_ret_var = $2;
+                    $single_ret_var = $1;
                     $single_ret_by_ref = 0;
                     $single_ret_check = " == NULL";
                 } elsif ($ret_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|interface|node_device|secret|nwfilter|domain_snapshot) (\S+);/) {
@@ -899,7 +899,7 @@ elsif ($mode eq "server") {

         if ($single_ret_as_list) {
             print "    if (args->$single_ret_list_max_var > $single_ret_list_max_define) {\n";
-            print "        virReportError(VIR_ERR_INTERNAL_ERROR,\n";
+            print "        virReportError(VIR_ERR_RPC,\n";
             print "                       \"%s\", _(\"max$single_ret_list_name > $single_ret_list_max_define\"));\n";
             print "        goto cleanup;\n";
             print "    }\n";
@@ -1140,14 +1140,14 @@ elsif ($mode eq "client") {
                 } elsif ($args_member =~ m/^remote_uuid (\S+);/) {
                     push(@args_list, "const unsigned char *$1");
                     push(@setters_list, "memcpy(args.$1, $1, VIR_UUID_BUFLEN);");
-                } elsif ($args_member =~ m/^(admin|remote)_string (\S+);/) {
-                    push(@args_list, "const char *$2");
-                    push(@setters_list, "args.$2 = $2 ? (char **)&$2 : NULL;");
-                } elsif ($args_member =~ m/^(admin|remote)_nonnull_string (\S+)<(\S+)>;(.*)$/) {
+                } elsif ($args_member =~ m/^(?:admin|remote)_string (\S+);/) {
+                    push(@args_list, "const char *$1");
+                    push(@setters_list, "args.$1 = $1 ? (char **)&$1 : NULL;");
+                } elsif ($args_member =~ m/^(?:admin|remote)_nonnull_string (\S+)<(\S+)>;(.*)$/) {
                     my $type_name = "const char **";
-                    my $arg_name = $2;
-                    my $limit = $3;
-                    my $annotation = $4;
+                    my $arg_name = $1;
+                    my $limit = $2;
+                    my $annotation = $3;

                     if ($annotation ne "") {
                         if ($annotation =~ m/\s*\/\*\s*\((.*)\)\s*\*\//) {
@@ -1161,10 +1161,10 @@ elsif ($mode eq "client") {
                     push(@args_list, "unsigned int ${arg_name}len");
                     push(@setters_list, "args.$arg_name.${arg_name}_val = (char **)$arg_name;");
                     push(@setters_list, "args.$arg_name.${arg_name}_len = ${arg_name}len;");
-                    push(@args_check_list, { name => "\"$arg_name\"", arg => "${arg_name}len", limit => $3 });
-                } elsif ($args_member =~ m/^(admin|remote)_nonnull_string (\S+);/) {
-                    push(@args_list, "const char *$2");
-                    push(@setters_list, "args.$2 = (char *)$2;");
+                    push(@args_check_list, { name => "\"$arg_name\"", arg => "${arg_name}len", limit => $2 });
+                } elsif ($args_member =~ m/^(?:admin|remote)_nonnull_string (\S+);/) {
+                    push(@args_list, "const char *$1");
+                    push(@setters_list, "args.$1 = (char *)$1;");
                 } elsif ($args_member =~ m/^opaque (\S+)<(\S+)>;(.*)$/) {
                     my $type_name = "const char *";
                     my $arg_name = $1;
@@ -1191,9 +1191,9 @@ elsif ($mode eq "client") {
                     push(@setters_list, "args.$arg_name.${arg_name}_val = (char *)$arg_name;");
                     push(@setters_list, "args.$arg_name.${arg_name}_len = ${arg_name}len;");
                     push(@args_check_list, { name => "\"$arg_name\"", arg => "${arg_name}len", limit => $limit });
-                } elsif ($args_member =~ m/^(admin|remote)_string (\S+)<(\S+)>;/) {
-                    my $arg_name = $2;
-                    my $limit = $3;
+                } elsif ($args_member =~ m/^(?:admin|remote)_string (\S+)<(\S+)>;/) {
+                    my $arg_name = $1;
+                    my $limit = $2;

                     push(@args_list, "const char *$arg_name");
                     push(@args_list, "int ${arg_name}len");
@@ -1312,25 +1312,25 @@ elsif ($mode eq "client") {
                         die "unhandled type for multi-return-value for " .
                             "procedure $call->{name}: $ret_member";
                     }
-                } elsif ($ret_member =~ m/^(admin|remote)_nonnull_string (\S+)<(\S+)>;\s*\/\*\s*insert@(\d+)\s*\*\//) {
-                    splice(@args_list, int($4), 0, ("char **const $2"));
-                    push(@ret_list, "rv = ret.$2.$2_len;");
+                } elsif ($ret_member =~ m/^(?:admin|remote)_nonnull_string (\S+)<(\S+)>;\s*\/\*\s*insert@(\d+)\s*\*\//) {
+                    splice(@args_list, int($3), 0, ("char **const $1"));
+                    push(@ret_list, "rv = ret.$1.$1_len;");
                     $single_ret_var = "int rv = -1";
                     $single_ret_type = "int";
                     $single_ret_as_list = 1;
-                    $single_ret_list_name = $2;
-                    $single_ret_list_max_var = "max$2";
-                    $single_ret_list_max_define = $3;
+                    $single_ret_list_name = $1;
+                    $single_ret_list_max_var = "max$1";
+                    $single_ret_list_max_define = $2;
                 } elsif ($ret_member =~ m/^(admin|remote)_nonnull_string (\S+)<\S+>;/) {
                     # error out on unannotated arrays
                     die "$1_nonnull_string array without insert@<offset> annotation: $ret_member";
-                } elsif ($ret_member =~ m/^(admin|remote)_nonnull_string (\S+);/) {
-                    push(@ret_list, "rv = ret.$2;");
+                } elsif ($ret_member =~ m/^(?:admin|remote)_nonnull_string (\S+);/) {
+                    push(@ret_list, "rv = ret.$1;");
                     $single_ret_var = "char *rv = NULL";
                     $single_ret_type = "char *";
-                } elsif ($ret_member =~ m/^(admin|remote)_string (\S+);/) {
-                    push(@ret_list, "rv = ret.$2 ? *ret.$2 : NULL;");
-                    push(@ret_list, "VIR_FREE(ret.$2);");
+                } elsif ($ret_member =~ m/^(?:admin|remote)_string (\S+);/) {
+                    push(@ret_list, "rv = ret.$1 ? *ret.$1 : NULL;");
+                    push(@ret_list, "VIR_FREE(ret.$1);");
                     $single_ret_var = "char *rv = NULL";
                     $single_ret_type = "char *";
                 } elsif ($ret_member =~ m/^remote_nonnull_(domain|network|storage_pool|storage_vol|node_device|interface|secret|nwfilter|domain_snapshot) (\S+);/) {
-- 
2.7.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]