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

Re: [libvirt] [PATCH 5/7] remote generator: Fix XDR sign mismatch for virNodeGet(Cells)FreeMemory



On Mon, May 23, 2011 at 07:36:08PM +0200, Matthias Bolte wrote:
> virNodeGetFreeMemory used unsigned long long in the public API but
> signed hyper in the XDR protocol. Convert the XDR protocol to use
> unsigned hyper.
> 
> As explained by Eric before, this doesn't affect the on-the-wire protocol.
> ---
>  daemon/remote_generator.pl   |   18 ++++++------------
>  src/remote/remote_protocol.x |    4 ++--
>  src/remote_protocol-structs  |    4 ++--
>  3 files changed, 10 insertions(+), 16 deletions(-)
> 
> diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
> index c405dc8..9143b3a 100755
> --- a/daemon/remote_generator.pl
> +++ b/daemon/remote_generator.pl
> @@ -501,7 +501,7 @@ elsif ($opt_b) {
>                              $single_ret_check = " < 0";
>                          }
>                      }
> -                } elsif ($ret_member =~ m/^hyper (\S+)<(\S+)>;\s*\/\*\s*insert@(\d+)\s*\*\//) {
> +                } elsif ($ret_member =~ m/^(?:unsigned )?hyper (\S+)<(\S+)>;\s*\/\*\s*insert@(\d+)\s*\*\//) {
>                      push(@vars_list, "int len");
>                      push(@ret_list, "ret->$1.$1_len = len;");
>                      push(@free_list_on_error, "VIR_FREE(ret->$1.$1_val);");
> @@ -519,7 +519,7 @@ elsif ($opt_b) {
>                          $single_ret_check = " < 0";
>                          splice(@args_list, int($3), 0, ("ret->$1.$1_val"));
>                      }
> -                } elsif ($ret_member =~ m/^hyper (\S+)<\S+>;/) {
> +                } elsif ($ret_member =~ m/^(?:unsigned )?hyper (\S+)<\S+>;/) {
>                      # error out on unannotated arrays
>                      die "hyper array without insert@<offset> annotation: $ret_member";
>                  } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);/) {
> @@ -1063,20 +1063,14 @@ elsif ($opt_k) {
>                          push(@ret_list, "rv = 0;");
>                          $single_ret_var = "int rv = -1";
>                          $single_ret_type = "int";
> -                    } else {
> -                        push(@ret_list, "rv = ret.$arg_name;");
> -                        $single_ret_var = "unsigned long rv = 0";
> -                        $single_ret_type = "unsigned long";
> -                    }
> -                } elsif ($ret_member =~ m/^hyper (\S+);/) {
> -                    my $arg_name = $1;
> -
> -                    if ($call->{ProcName} eq "NodeGetFreeMemory") {
> +                    } elsif ($call->{ProcName} eq "NodeGetFreeMemory") {
>                          push(@ret_list, "rv = ret.$arg_name;");
>                          $single_ret_var = "unsigned long long rv = 0";
>                          $single_ret_type = "unsigned long long";
>                      } else {
> -                        die "unhandled type for return value: $ret_member";
> +                        push(@ret_list, "rv = ret.$arg_name;");
> +                        $single_ret_var = "unsigned long rv = 0";
> +                        $single_ret_type = "unsigned long";
>                      }
>                  } elsif ($ret_member =~ m/^(\/)?\*/) {
>                      # ignore comments
> diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
> index 5b9300a..f5218cd 100644
> --- a/src/remote/remote_protocol.x
> +++ b/src/remote/remote_protocol.x
> @@ -449,11 +449,11 @@ struct remote_node_get_cells_free_memory_args {
>  };
>  
>  struct remote_node_get_cells_free_memory_ret {
> -    hyper cells<REMOTE_NODE_MAX_CELLS>; /* insert 1 */
> +    unsigned hyper cells<REMOTE_NODE_MAX_CELLS>; /* insert 1 */
>  };
>  
>  struct remote_node_get_free_memory_ret {
> -    hyper freeMem;
> +    unsigned hyper freeMem;
>  };
>  
>  struct remote_domain_get_scheduler_type_args {
> diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
> index 5491f73..fd23fa0 100644
> --- a/src/remote_protocol-structs
> +++ b/src/remote_protocol-structs
> @@ -158,11 +158,11 @@ struct remote_node_get_cells_free_memory_args {
>  struct remote_node_get_cells_free_memory_ret {
>          struct {
>                  u_int              cells_len;
> -                int64_t *          cells_val;
> +                uint64_t *         cells_val;
>          } cells;
>  };
>  struct remote_node_get_free_memory_ret {
> -        int64_t                    freeMem;
> +        uint64_t                   freeMem;
>  };
>  struct remote_domain_get_scheduler_type_args {
>          remote_nonnull_domain      dom;

ACK 


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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