[pve-devel] [PATCH common] change coderef invocations from &$coderef() to $coderef->()

Stoiko Ivanov s.ivanov at proxmox.com
Fri Jun 1 16:04:23 CEST 2018


Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
Based on a suggestion from Dietmar to my patchset with subject
"add print_text_table" sent last Tuesday I went ahead and uniformly replaced
the way codrefs are invoked in pve-common.

The patch applies on top of the mentioned patchset.

src/PVE/CLIHandler.pm      | 40 +++++++++++++--------------
 src/PVE/Daemon.pm          | 68 +++++++++++++++++++++++-----------------------
 src/PVE/INotify.pm         | 42 ++++++++++++++--------------
 src/PVE/JSONSchema.pm      | 44 +++++++++++++++---------------
 src/PVE/Network.pm         | 64 +++++++++++++++++++++----------------------
 src/PVE/ProcFSTools.pm     | 12 ++++----
 src/PVE/RESTEnvironment.pm | 20 +++++++-------
 src/PVE/RESTHandler.pm     | 14 +++++-----
 src/PVE/SectionConfig.pm   | 12 ++++----
 src/PVE/Tools.pm           | 26 +++++++++---------
 10 files changed, 171 insertions(+), 171 deletions(-)

diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
index 512926c..ddb7d93 100644
--- a/src/PVE/CLIHandler.pm
+++ b/src/PVE/CLIHandler.pm
@@ -132,7 +132,7 @@ sub generate_usage_str {
 	my $str = '';
 	if (ref($def) eq 'HASH') {
 	    my $oldclass = undef;
-	    foreach my $cmd (&$sortfunc($def)) {
+	    foreach my $cmd ($sortfunc->($def)) {
 
 		if (ref($def->{$cmd}) eq 'ARRAY') {
 		    my ($class, $name, $arg_param, $fixed_param) = @{$def->{$cmd}};
@@ -314,7 +314,7 @@ my $print_bash_completion = sub {
 	($cmd, $def, $args, my $expaned) = resolve_cmd($args);
 
 	if (ref($def) eq 'HASH') {
-	    &$print_result(@{$get_commands->($def)});
+	    $print_result->(@{$get_commands->($def)});
 	    return;
 	}
 	if (my $expanded_cmd = $expaned->{$cur}) {
@@ -351,12 +351,12 @@ my $print_bash_completion = sub {
 	    my $vt = ref($d->{completion});
 	    if ($vt eq 'CODE') {
 		my $res = $d->{completion}->($cmd, $pname, $cur, $args);
-		&$print_result(@$res);
+		$print_result->(@$res);
 	    }
 	} elsif ($d->{type} eq 'boolean') {
-	    &$print_result('0', '1');
+	    $print_result->('0', '1');
 	} elsif ($d->{enum}) {
-	    &$print_result(@{$d->{enum}});
+	    $print_result->(@{$d->{enum}});
 	}
     };
 
@@ -364,7 +364,7 @@ my $print_bash_completion = sub {
     $pos++ if $simple_cmd;
     if ($pos < scalar(@$arg_param)) {
 	my $pname = $arg_param->[$pos];
-	&$print_parameter_completion($pname);
+	$print_parameter_completion->($pname);
 	return;
     }
 
@@ -375,17 +375,17 @@ my $print_bash_completion = sub {
     }
 
     if ($cur =~ m/^-/) {
-	&$print_result(@option_list);
+	$print_result->(@option_list);
 	return;
     }
 
     if ($prev =~ m/^--?(.+)$/ && $prop->{$1}) {
 	my $pname = $1;
-	&$print_parameter_completion($pname);
+	$print_parameter_completion->($pname);
 	return;
     }
 
-    &$print_result(@option_list);
+    $print_result->(@option_list);
 };
 
 sub verify_api {
@@ -410,7 +410,7 @@ sub generate_bash_completions {
 
     # generate bash completion config
 
-    $exename = &$get_exe_name($class);
+    $exename = $get_exe_name->($class);
 
     print <<__EOD__;
 # $exename bash completion
@@ -434,7 +434,7 @@ sub generate_asciidoc_synopsis {
 
     $cli_handler_class = $class;
 
-    $exename = &$get_exe_name($class);
+    $exename = $get_exe_name->($class);
 
     no strict 'refs';
     my $def = ${"${class}::cmddef"};
@@ -475,21 +475,21 @@ my $handle_cmd  = sub {
     $cli_handler_class->setup_environment();
 
     if ($cmd eq 'bashcomplete') {
-	&$print_bash_completion(undef, @$cmd_args);
+	$print_bash_completion->(undef, @$cmd_args);
 	return;
     }
 
     # checked special commands, if def is still a hash we got an incomplete sub command
     $abort->("incomplete command '$cmd_str'") if ref($def) eq 'HASH';
 
-    &$preparefunc() if $preparefunc;
+    $preparefunc->() if $preparefunc;
 
     my ($class, $name, $arg_param, $uri_param, $outsub) = @{$def || []};
     $abort->("unknown command '$cmd_str'") if !$class;
 
     my ($res,$info) = $class->cli_handler($cmd_str, $name, $cmd_args, $arg_param, $uri_param, $read_password_func, $param_mapping_func);
 
-    &$outsub($res, $info) if $outsub;
+    $outsub->($res, $info) if $outsub;
 };
 
 my $handle_simple_cmd = sub {
@@ -515,16 +515,16 @@ my $handle_simple_cmd = sub {
     if (scalar(@$args) >= 1) {
 	if ($args->[0] eq 'bashcomplete') {
 	    shift @$args;
-	    &$print_bash_completion($name, @$args);
+	    $print_bash_completion->($name, @$args);
 	    return;
 	}
     }
 
-    &$preparefunc() if $preparefunc;
+    $preparefunc->() if $preparefunc;
 
     my ($res, $info) = $class->cli_handler($name, $name, \@ARGV, $arg_param, $uri_param, $read_password_func, $param_mapping_func);
 
-    &$outsub($res,$info) if $outsub;
+    $outsub->($res,$info) if $outsub;
 };
 
 sub run_cli_handler {
@@ -547,7 +547,7 @@ sub run_cli_handler {
     my $param_mapping_func = $cli_handler_class->can('param_mapping') ||
 	$class->can('string_param_file_mapping');
 
-    $exename = &$get_exe_name($class);
+    $exename = $get_exe_name->($class);
 
     initlog($exename);
 
@@ -555,9 +555,9 @@ sub run_cli_handler {
     $cmddef = ${"${class}::cmddef"};
 
     if (ref($cmddef) eq 'ARRAY') {
-	&$handle_simple_cmd(\@ARGV, $read_password_func, $preparefunc, $param_mapping_func);
+	$handle_simple_cmd->(\@ARGV, $read_password_func, $preparefunc, $param_mapping_func);
     } else {
-	&$handle_cmd(\@ARGV, $read_password_func, $preparefunc, $param_mapping_func);
+	$handle_cmd->(\@ARGV, $read_password_func, $preparefunc, $param_mapping_func);
     }
 
     exit 0;
diff --git a/src/PVE/Daemon.pm b/src/PVE/Daemon.pm
index dcc4d34..6f40f3d 100644
--- a/src/PVE/Daemon.pm
+++ b/src/PVE/Daemon.pm
@@ -58,7 +58,7 @@ my $log_err = sub {
 sub after_fork_cleanup {
     my ($self) = @_;
 
-    &$close_daemon_lock($self);
+    $close_daemon_lock->($self);
 
     PVE::INotify::inotify_close();
 
@@ -97,7 +97,7 @@ my $lockpidfile = sub {
     }
 
     if (!flock ($self->{daemon_lock_fh}, LOCK_EX|LOCK_NB)) {
-	&$close_daemon_lock($self);
+	$close_daemon_lock->($self);
 	my $err = $!;
 
 	my ($running, $pid) = $self->running();
@@ -296,7 +296,7 @@ my $server_run = sub {
     my ($self, $debug) = @_;
 
     # fixme: handle restart lockfd
-    &$lockpidfile($self);
+    $lockpidfile->($self);
 
     # remove FD_CLOEXEC bit to reuse on exec
     $self->{daemon_lock_fh}->fcntl(Fcntl::F_SETFD(), 0);
@@ -329,7 +329,7 @@ my $server_run = sub {
     if ($self->{env_restart_pve_daemon}) {
 	syslog('info' , "restarting server");
     } else {
-	&$writepidfile($self);
+	$writepidfile->($self);
 	syslog('info' , "starting server");
     }
 
@@ -341,18 +341,18 @@ my $server_run = sub {
     local $SIG{TERM} = sub {
 	local ($@, $!, $?); # do not overwrite error vars
 	syslog('info', "received signal TERM");
-	&$terminate_server($self, 0);
-	&$server_cleanup($self);
-	&$old_sig_term(@_) if $old_sig_term;
+	$terminate_server->($self, 0);
+	$server_cleanup->($self);
+	$old_sig_term->(@_) if $old_sig_term;
     };
 
     my $old_sig_quit = $SIG{QUIT};
     local $SIG{QUIT} = sub {
 	local ($@, $!, $?); # do not overwrite error vars
 	syslog('info', "received signal QUIT");
-	&$terminate_server($self, 0);
-	&$server_cleanup($self);
-	&$old_sig_quit(@_) if $old_sig_quit;
+	$terminate_server->($self, 0);
+	$server_cleanup->($self);
+	$old_sig_quit->(@_) if $old_sig_quit;
     };
 
     my $old_sig_int = $SIG{INT};
@@ -360,9 +360,9 @@ my $server_run = sub {
 	local ($@, $!, $?); # do not overwrite error vars
 	syslog('info', "received signal INT");
 	$SIG{INT} = 'DEFAULT'; # allow to terminate now
-	&$terminate_server($self, 0);
-	&$server_cleanup($self);
-	&$old_sig_int(@_) if $old_sig_int;
+	$terminate_server->($self, 0);
+	$server_cleanup->($self);
+	$old_sig_int->(@_) if $old_sig_int;
     };
 
     $SIG{HUP} = sub {
@@ -370,7 +370,7 @@ my $server_run = sub {
 	syslog('info', "received signal HUP");
 	$self->{got_hup_signal} = 1;
 	if ($self->{max_workers}) {
-	    &$terminate_server($self, 1);
+	    $terminate_server->($self, 1);
 	} elsif ($self->can('hup')) {
 	    eval { $self->hup() };
 	    warn $@ if $@;
@@ -382,16 +382,16 @@ my $server_run = sub {
 	    my $old_sig_chld = $SIG{CHLD};
 	    local $SIG{CHLD} = sub {
 		local ($@, $!, $?); # do not overwrite error vars
-		&$finish_workers($self);
-		&$old_sig_chld(@_) if $old_sig_chld;
+		$finish_workers->($self);
+		$old_sig_chld->(@_) if $old_sig_chld;
 	    };
 
 	    # now loop forever (until we receive terminate signal)
 	    for (;;) { 
-		&$start_workers($self);
+		$start_workers->($self);
 		sleep(5);
-		&$terminate_old_workers($self);
-		&$finish_workers($self);
+		$terminate_old_workers->($self);
+		$finish_workers->($self);
 		last if $self->{terminate};
 	    }
 
@@ -404,7 +404,7 @@ my $server_run = sub {
     if ($err) {
 	syslog ('err', "ERROR: $err");
 
-	&$terminate_server($self, 1);
+	$terminate_server->($self, 1);
 
 	if (my $wait_time = $self->{restart_on_error}) {
 	    $self->restart_daemon($wait_time);
@@ -466,7 +466,7 @@ sub new {
 	$0 = $name;
     };
     if (my $err = $@) {
-	&$log_err($err);
+	$log_err->($err);
 	exit(-1);
     }
 
@@ -478,7 +478,7 @@ sub exit_daemon {
 
     syslog("info", "server stopped");
 
-    &$server_cleanup($self);
+    $server_cleanup->($self);
 
     exit($status);
 }
@@ -549,10 +549,10 @@ sub start {
 
     eval  {
 	$self->setup();
-	&$server_run($self, $debug);
+	$server_run->($self, $debug);
     };
     if (my $err = $@) {
-	&$log_err("start failed - $err");
+	$log_err->("start failed - $err");
 	exit(-1);
     }
 }
@@ -584,7 +584,7 @@ my $init_ppid = sub {
 sub running {
     my ($self) = @_;
 
-    my $pid = &$read_pid($self);
+    my $pid = $read_pid->($self);
 
     if ($pid) {
 	my $res = PVE::ProcFSTools::check_process_running($pid) ? 1 : 0;
@@ -597,7 +597,7 @@ sub running {
 sub stop {
     my ($self) = @_;
 
-    my $pid = &$read_pid($self);
+    my $pid = $read_pid->($self);
 
     return if !$pid;
 
@@ -622,11 +622,11 @@ sub stop {
     if (-f $self->{pidfile}) {
 	eval {
 	    # try to get the lock
-	    &$lockpidfile($self);
-	    &$server_cleanup($self);
+	    $lockpidfile->($self);
+	    $server_cleanup->($self);
 	};
 	if (my $err = $@) {
-	    &$log_err("cleanup failed - $err");
+	    $log_err->("cleanup failed - $err");
 	}
     }
 }
@@ -657,7 +657,7 @@ sub register_start_command {
 	code => sub {
 	    my ($param) = @_;
 
-            if (&$init_ppid() || $param->{debug}) {
+            if ($init_ppid->() || $param->{debug}) {
                 $self->start($param->{debug});
             } else {
                 PVE::Tools::run_command(['systemctl', 'start', $self->{name}]);
@@ -707,8 +707,8 @@ sub register_restart_command {
 	code => sub {
 	    my ($param) = @_;
 
-	    if (&$init_ppid()) {
-		&$reload_daemon($self, $use_hup);
+	    if ($init_ppid->()) {
+		$reload_daemon->($self, $use_hup);
 	    } else {
 		PVE::Tools::run_command(['systemctl', $use_hup ? 'reload-or-restart' : 'restart', $self->{name}]);
 	    }
@@ -736,7 +736,7 @@ sub register_reload_command {
 	code => sub {
 	    my ($param) = @_;
 
-	    &$reload_daemon($self, 1);
+	    $reload_daemon->($self, 1);
 
 	    return undef;
 	}});		   
@@ -761,7 +761,7 @@ sub register_stop_command {
 	code => sub {
 	    my ($param) = @_;
 	    
-	    if (&$init_ppid()) {
+	    if ($init_ppid->()) {
 		$self->stop();
 	    } else {
 		PVE::Tools::run_command(['systemctl', 'stop', $self->{name}]);
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 445c034..a273011 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -118,7 +118,7 @@ sub write_file {
 	my $fh = IO::File->new($tmpname, O_WRONLY|O_CREAT, $perm);
 	die "unable to open file '$tmpname' - $!\n" if !$fh;
 
-	$res = &$writer($filename, $fh, $data);
+	$res = $writer->($filename, $fh, $data);
 
 	die "closing file '$tmpname' failed - $!\n" unless close $fh;
     };
@@ -168,7 +168,7 @@ sub update_file {
 
 	$fd = IO::File->new ($filename, "r");
 	
-	my $new = &$update($filename, $fd, $data, @args);
+	my $new = $update->($filename, $fd, $data, @args);
 
 	if (defined($new)) {
 	    PVE::Tools::file_set_contents($filename, $new, $ccinfo->{perm});
@@ -269,7 +269,7 @@ sub read_file {
 	$diff = ccache_compute_diff ($filename, $shadow);
     }
 
-    my $res = &$parser($filename, $fd);
+    my $res = $parser->($filename, $fd);
 
     if (!$ccinfo->{nocache}) {
 	$ccinfo->{version} = $cver;
@@ -707,7 +707,7 @@ my $parse_ovs_option = sub {
 my $set_ovs_option = sub {
     my ($d, %params) = @_;
 
-    my $opts = &$parse_ovs_option($d->{ovs_options});
+    my $opts = $parse_ovs_option->($d->{ovs_options});
 
     foreach my $k (keys %params) {
 	my $v = $params{$k};
@@ -735,7 +735,7 @@ my $set_ovs_option = sub {
 my $extract_ovs_option = sub {
     my ($d, $name) = @_;
 
-    my $opts = &$parse_ovs_option($d->{ovs_options});
+    my $opts = $parse_ovs_option->($d->{ovs_options});
 
     my $v = delete $opts->{$name};
 
@@ -934,8 +934,8 @@ sub __read_etc_network_interfaces {
 	    } elsif ($d->{ovs_type} eq 'OVSBond') {
 		$d->{type} = $d->{ovs_type};
 		# translate: ovs_options => bond_mode
-		$d->{'bond_mode'} = &$extract_ovs_option($d, 'bond_mode');
-		my $lacp = &$extract_ovs_option($d, 'lacp');
+		$d->{'bond_mode'} = $extract_ovs_option->($d, 'bond_mode');
+		my $lacp = $extract_ovs_option->($d, 'lacp');
 		if ($lacp && $lacp eq 'active') {
 		    if ($d->{'bond_mode'} eq 'balance-slb') {
 			$d->{'bond_mode'} = 'lacp-balance-slb';
@@ -945,7 +945,7 @@ sub __read_etc_network_interfaces {
 		if ($d->{'bond_mode'} eq 'balance-tcp') {
 		    $d->{'bond_mode'} = 'lacp-balance-tcp';
 		}
-		my $tag = &$extract_ovs_option($d, 'tag');
+		my $tag = $extract_ovs_option->($d, 'tag');
 		$d->{ovs_tag} = $tag if defined($tag);
 	    } else {
 		$d->{type} = 'unknown';
@@ -986,7 +986,7 @@ sub __read_etc_network_interfaces {
 		$d->{type} = 'eth';
 	    } elsif ($d->{ovs_type} eq 'OVSPort') {
 		$d->{type} = $d->{ovs_type};
-		my $tag = &$extract_ovs_option($d, 'tag');
+		my $tag = $extract_ovs_option->($d, 'tag');
 		$d->{ovs_tag} = $tag if defined($tag);
 	    } else {
 		$d->{type} = 'unknown';
@@ -998,7 +998,7 @@ sub __read_etc_network_interfaces {
 		$d->{type} = 'unknown';
 	    } elsif ($d->{ovs_type} eq 'OVSIntPort') {
 		$d->{type} = $d->{ovs_type};
-		my $tag = &$extract_ovs_option($d, 'tag');
+		my $tag = $extract_ovs_option->($d, 'tag');
 		$d->{ovs_tag} = $tag if defined($tag);
 	    }
 	}
@@ -1113,7 +1113,7 @@ sub __interface_to_string {
 	$d->{autostart} = 0; # started by the bridge
 
 	if (defined($d->{ovs_tag})) {
-	    &$set_ovs_option($d, tag => $d->{ovs_tag});
+	    $set_ovs_option->($d, tag => $d->{ovs_tag});
 	}
 	$done->{ovs_tag} = 1;
 
@@ -1125,14 +1125,14 @@ sub __interface_to_string {
 		die "OVS does not support bond mode '$d->{bond_mode}\n";
 
 	    if ($d->{bond_mode} eq 'lacp-balance-slb') {
-		&$set_ovs_option($d, lacp => 'active');
-		&$set_ovs_option($d, bond_mode => 'balance-slb');
+		$set_ovs_option->($d, lacp => 'active');
+		$set_ovs_option->($d, bond_mode => 'balance-slb');
 	    } elsif ($d->{bond_mode} eq 'lacp-balance-tcp') {
-		&$set_ovs_option($d, lacp => 'active');
-		&$set_ovs_option($d, bond_mode => 'balance-tcp');
+		$set_ovs_option->($d, lacp => 'active');
+		$set_ovs_option->($d, bond_mode => 'balance-tcp');
 	    } else {
-		&$set_ovs_option($d, lacp => undef);
-		&$set_ovs_option($d, bond_mode => $d->{bond_mode});
+		$set_ovs_option->($d, lacp => undef);
+		$set_ovs_option->($d, bond_mode => $d->{bond_mode});
 	    }
 	    $done->{bond_mode} = 1;
 
@@ -1313,8 +1313,8 @@ NETWORKDOC
     foreach my $iface (sort {
 	my $ref1 = $ifaces->{$a};
 	my $ref2 = $ifaces->{$b};
-	my $tp1 = &$lookup_type_prio($a);
-	my $tp2 = &$lookup_type_prio($b);
+	my $tp1 = $lookup_type_prio->($a);
+	my $tp2 = $lookup_type_prio->($b);
 
 	# Only recognized types are in relation to each other. If one type
 	# is unknown then only consider the interfaces' priority attributes.
@@ -1415,7 +1415,7 @@ my $format_apt_auth_data = sub {
 sub write_apt_auth {
     my ($filename, $fh, $data) = @_;
 
-    my $raw = &$format_apt_auth_data($data);
+    my $raw = $format_apt_auth_data->($data);
 
     die "write failed: $!" unless print $fh "$raw\n";
    
@@ -1431,7 +1431,7 @@ sub update_apt_auth {
 	$orig->{$machine} = $data->{$machine};
     }
 
-    return &$format_apt_auth_data($orig);
+    return $format_apt_auth_data->($orig);
 }
 
 register_file('apt-auth', "/etc/apt/auth.conf",  
diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 0e722b8..df1d39e 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -487,7 +487,7 @@ sub check_format {
 
 	# Note: we allow empty lists
 	foreach my $v (split_list($value)) {
-	    &$code($v);
+	    $code->($v);
 	}
 
     } elsif ($format =~ m/^(.*)-opt$/) {
@@ -498,7 +498,7 @@ sub check_format {
 
 	return if !$value; # allow empty string
 
- 	&$code($value);
+ 	$code->($value);
 
    } else {
 
@@ -507,7 +507,7 @@ sub check_format {
 	die "undefined format '$format'\n" if !$code;
 
 	return parse_property_string($code, $value, $path) if ref($code) eq 'HASH';
-	&$code($value);
+	$code->($value);
     }
 } 
 
@@ -1411,7 +1411,7 @@ sub get_options {
     if (my $pd = $schema->{properties}->{password}) {
 	if ($pd->{type} ne 'boolean' && $pwcallback) {
 	    if ($opts->{password} || !$pd->{optional}) {
-		$opts->{password} = &$pwcallback(); 
+		$opts->{password} = $pwcallback->(); 
 	    }
 	}
     }
@@ -1576,7 +1576,7 @@ my $find_schema_default_key = sub {
 sub generate_typetext {
     my ($format, $list_enums) = @_;
 
-    my ($default_key, $keyAliasProps) = &$find_schema_default_key($format);
+    my ($default_key, $keyAliasProps) = $find_schema_default_key->($format);
 
     my $res = '';
     my $add_sep = 0;
@@ -1623,9 +1623,9 @@ sub generate_typetext {
 	}
 
 	if (defined($default_key) && ($default_key eq $key)) {
-	    &$add_option_string("[$keytext=]$typetext", $phash->{optional});
+	    $add_option_string->("[$keytext=]$typetext", $phash->{optional});
 	} else {
-	    &$add_option_string("$keytext=$typetext", $phash->{optional});
+	    $add_option_string->("$keytext=$typetext", $phash->{optional});
 	}
     };
 
@@ -1644,25 +1644,25 @@ sub generate_typetext {
 
 	return if $phash->{alias};
 
-	&$format_key_value($key, $phash);
+	$format_key_value->($key, $phash);
 
     };
 
-    &$cond_add_key($default_key) if defined($default_key);
+    $cond_add_key->($default_key) if defined($default_key);
 
     # add required keys first
     foreach my $key (sort keys %$format) {
 	my $phash = $format->{$key};
-	&$cond_add_key($key) if $phash && !$phash->{optional};
+	$cond_add_key->($key) if $phash && !$phash->{optional};
     }
 
     # add the rest
     foreach my $key (sort keys %$format) {
-	&$cond_add_key($key);
+	$cond_add_key->($key);
     }
 
     foreach my $keyAlias (sort keys %$keyAliasProps) {
-	&$add_option_string("<$keyAlias>=<$keyAliasProps->{$keyAlias }>", 1);
+	$add_option_string->("<$keyAlias>=<$keyAliasProps->{$keyAlias }>", 1);
     }
 
     return $res;
@@ -1683,7 +1683,7 @@ sub print_property_string {
 	raise "format error", errors => $errors;
     }
 
-    my ($default_key, $keyAliasProps) = &$find_schema_default_key($format);
+    my ($default_key, $keyAliasProps) = $find_schema_default_key->($format);
 
     my $res = '';
     my $add_sep = 0;
@@ -1726,9 +1726,9 @@ sub print_property_string {
 	if (my $combine = $keyAliasProps->{$key}) {
 	    if (defined(my $combine_value = $data->{$combine})) {
 		my $combine_format = $format->{$combine}->{format};
-		my $value_str = &$format_value($key, $value, $phash->{format});
-		my $combine_str = &$format_value($combine, $combine_value, $combine_format);
-		&$add_option_string("${value_str}=${combine_str}");
+		my $value_str = $format_value->($key, $value, $phash->{format});
+		my $combine_str = $format_value->($combine, $combine_value, $combine_format);
+		$add_option_string->("${value_str}=${combine_str}");
 		$done->{$combine} = 1;
 		return;
 	    }
@@ -1741,26 +1741,26 @@ sub print_property_string {
 	die "invalid key '$key'\n" if !$phash;
 	die "internal error" if defined($phash->{alias});
 
-	my $value_str = &$format_value($key, $value, $phash->{format});
+	my $value_str = $format_value->($key, $value, $phash->{format});
 	if ($isdefault) {
-	    &$add_option_string($value_str);
+	    $add_option_string->($value_str);
 	} else {
-	    &$add_option_string("$key=${value_str}");
+	    $add_option_string->("$key=${value_str}");
 	}
     };
 
     # add default key first
-    &$cond_add_key($default_key, 1) if defined($default_key);
+    $cond_add_key->($default_key, 1) if defined($default_key);
 
     # add required keys first
     foreach my $key (sort keys %$data) {
 	my $phash = $format->{$key};
-	&$cond_add_key($key) if $phash && !$phash->{optional};
+	$cond_add_key->($key) if $phash && !$phash->{optional};
     }
 
     # add the rest
     foreach my $key (sort keys %$data) {
-	&$cond_add_key($key);
+	$cond_add_key->($key);
     }
 
     return $res;
diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
index 3421532..f9aab88 100644
--- a/src/PVE/Network.pm
+++ b/src/PVE/Network.pm
@@ -273,7 +273,7 @@ sub tap_create {
 
     die "unable to get bridge setting\n" if !$bridge;
 
-    my $bridgemtu = &$read_bridge_mtu($bridge);
+    my $bridgemtu = $read_bridge_mtu->($bridge);
 
     eval { 
 	disable_ipv6($iface);
@@ -287,7 +287,7 @@ sub veth_create {
 
     die "unable to get bridge setting\n" if !$bridge;
 
-    my $bridgemtu = &$read_bridge_mtu($bridge);
+    my $bridgemtu = $read_bridge_mtu->($bridge);
 
     # create veth pair
     if (! -d "/sys/class/net/$veth") {
@@ -299,8 +299,8 @@ sub veth_create {
     # up vethpair
     disable_ipv6($veth);
     disable_ipv6($vethpeer);
-    &$activate_interface($veth);
-    &$activate_interface($vethpeer);
+    $activate_interface->($veth);
+    $activate_interface->($vethpeer);
 }
 
 sub veth_delete {
@@ -315,49 +315,49 @@ sub veth_delete {
 my $create_firewall_bridge_linux = sub {
     my ($iface, $bridge, $tag, $trunks) = @_;
 
-    my ($vmid, $devid) = &$parse_tap_device_name($iface);
-    my ($fwbr, $vethfw, $vethfwpeer) = &$compute_fwbr_names($vmid, $devid);
+    my ($vmid, $devid) = $parse_tap_device_name->($iface);
+    my ($fwbr, $vethfw, $vethfwpeer) = $compute_fwbr_names->($vmid, $devid);
 
-    &$cond_create_bridge($fwbr);
-    &$activate_interface($fwbr);
+    $cond_create_bridge->($fwbr);
+    $activate_interface->($fwbr);
 
     copy_bridge_config($bridge, $fwbr);
     veth_create($vethfw, $vethfwpeer, $bridge);
 
-    &$bridge_add_interface($fwbr, $vethfw);
-    &$bridge_add_interface($bridge, $vethfwpeer, $tag, $trunks);
+    $bridge_add_interface->($fwbr, $vethfw);
+    $bridge_add_interface->($bridge, $vethfwpeer, $tag, $trunks);
 
-    &$bridge_add_interface($fwbr, $iface);
+    $bridge_add_interface->($fwbr, $iface);
 };
 
 my $create_firewall_bridge_ovs = sub {
     my ($iface, $bridge, $tag, $trunks) = @_;
 
-    my ($vmid, $devid) = &$parse_tap_device_name($iface);
-    my ($fwbr, undef, undef, $ovsintport) = &$compute_fwbr_names($vmid, $devid);
+    my ($vmid, $devid) = $parse_tap_device_name->($iface);
+    my ($fwbr, undef, undef, $ovsintport) = $compute_fwbr_names->($vmid, $devid);
 
-    my $bridgemtu = &$read_bridge_mtu($bridge);
+    my $bridgemtu = $read_bridge_mtu->($bridge);
 
-    &$cond_create_bridge($fwbr);
-    &$activate_interface($fwbr);
+    $cond_create_bridge->($fwbr);
+    $activate_interface->($fwbr);
 
-    &$bridge_add_interface($fwbr, $iface);
+    $bridge_add_interface->($fwbr, $iface);
 
-    &$ovs_bridge_add_port($bridge, $ovsintport, $tag, 1, $trunks);
-    &$activate_interface($ovsintport);
+    $ovs_bridge_add_port->($bridge, $ovsintport, $tag, 1, $trunks);
+    $activate_interface->($ovsintport);
 
     # set the same mtu for ovs int port
     PVE::Tools::run_command(['/sbin/ip', 'link', 'set', $ovsintport, 'mtu', $bridgemtu]);
     
-    &$bridge_add_interface($fwbr, $ovsintport);
+    $bridge_add_interface->($fwbr, $ovsintport);
 };
 
 my $cleanup_firewall_bridge = sub {
     my ($iface) = @_;
 
-    my ($vmid, $devid) = &$parse_tap_device_name($iface, 1);
+    my ($vmid, $devid) = $parse_tap_device_name->($iface, 1);
     return if !defined($vmid);  
-    my ($fwbr, $vethfw, $vethfwpeer, $ovsintport) = &$compute_fwbr_names($vmid, $devid);
+    my ($fwbr, $vethfw, $vethfwpeer, $ovsintport) = $compute_fwbr_names->($vmid, $devid);
 
     # cleanup old port config from any openvswitch bridge
     if (-d "/sys/class/net/$ovsintport") {
@@ -380,7 +380,7 @@ sub tap_plug {
     eval {run_command("/usr/bin/ovs-vsctl del-port $iface", outfunc => sub {}, errfunc => sub {}) };
 
     if (-d "/sys/class/net/$bridge/bridge") {
-	&$cleanup_firewall_bridge($iface); # remove stale devices
+	$cleanup_firewall_bridge->($iface); # remove stale devices
 
 	my $vlan_aware = PVE::Tools::file_read_firstline("/sys/class/net/$bridge/bridge/vlan_filtering");
 
@@ -393,18 +393,18 @@ sub tap_plug {
 	}
 
 	if ($firewall) {
-	    &$create_firewall_bridge_linux($iface, $bridge, $tag, $trunks);
+	    $create_firewall_bridge_linux->($iface, $bridge, $tag, $trunks);
 	} else {
-	    &$bridge_add_interface($bridge, $iface, $tag, $trunks);
+	    $bridge_add_interface->($bridge, $iface, $tag, $trunks);
 	}
 
     } else {
-	&$cleanup_firewall_bridge($iface); # remove stale devices
+	$cleanup_firewall_bridge->($iface); # remove stale devices
 
 	if ($firewall) {
-	    &$create_firewall_bridge_ovs($iface, $bridge, $tag, $trunks);
+	    $create_firewall_bridge_ovs->($iface, $bridge, $tag, $trunks);
 	} else {
-	    &$ovs_bridge_add_port($bridge, $iface, $tag, undef, $trunks);
+	    $ovs_bridge_add_port->($bridge, $iface, $tag, undef, $trunks);
 	}
     }
 
@@ -423,7 +423,7 @@ sub tap_unplug {
 	iface_set_master($iface, undef);
     }
     
-    &$cleanup_firewall_bridge($iface);
+    $cleanup_firewall_bridge->($iface);
     #cleanup old port config from any openvswitch bridge
     eval {run_command("/usr/bin/ovs-vsctl del-port $iface", outfunc => sub {}, errfunc => sub {}) };
 }
@@ -462,7 +462,7 @@ sub activate_bridge_vlan_slave {
     }
 
     # be sure to have the $ifacevlan up
-    &$activate_interface($ifacevlan);
+    $activate_interface->($ifacevlan);
 
     # test if $vlaniface is already enslaved in another bridge
     my $path= "/sys/class/net/$ifacevlan/brport/bridge";
@@ -477,7 +477,7 @@ sub activate_bridge_vlan_slave {
     }
 
     # add $ifacevlan to the bridge
-    &$bridge_add_interface($bridgevlan, $ifacevlan);
+    $bridge_add_interface->($bridgevlan, $ifacevlan);
 }
 
 sub activate_bridge_vlan {
@@ -517,7 +517,7 @@ sub activate_bridge_vlan {
 	# remove ipv6 link-local address before activation
 	disable_ipv6($bridgevlan);
 	# be sure to have the bridge up
-	&$activate_interface($bridgevlan);
+	$activate_interface->($bridgevlan);
     });
     return $bridgevlan;
 }
diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm
index 80c0425..e5db86b 100644
--- a/src/PVE/ProcFSTools.pm
+++ b/src/PVE/ProcFSTools.pm
@@ -279,9 +279,9 @@ sub read_proc_net_route {
        next if $line =~/^Iface\s+Destination/; # skip head
        my ($iface, $dest, $gateway, $metric, $mask, $mtu) = (split(/\s+/, $line))[0,1,2,6,7,8];
        push @$res, {
-           dest => &$int_to_quad(hex($dest)),
-           gateway => &$int_to_quad(hex($gateway)),
-           mask => &$int_to_quad(hex($mask)),
+           dest => $int_to_quad->(hex($dest)),
+           gateway => $int_to_quad->(hex($gateway)),
+           mask => $int_to_quad->(hex($mask)),
            metric => $metric,
            mtu => $mtu,
 	   iface => $iface,
@@ -349,9 +349,9 @@ sub read_proc_net_ipv6_route {
     while (defined(my $line = <$fh>)) {
 	my ($dest, $prefix, $nexthop, $metric, $iface) = (split(/\s+/, $line))[0,1,4,5,9];
 	push @$res, {
-	    dest => &$read_v6addr($dest),
+	    dest => $read_v6addr->($dest),
 	    prefix => hex("$prefix"),
-	    gateway => &$read_v6addr($nexthop),
+	    gateway => $read_v6addr->($nexthop),
 	    metric => hex("$metric"),
 	    iface => $iface
 	};
@@ -372,7 +372,7 @@ sub upid_wait {
     while (check_process_running($task->{pid}, $task->{pstart})) {
 
 	if (time >= $next_time && $waitfunc && ref($waitfunc) eq 'CODE'){
-	    &$waitfunc($task);
+	    $waitfunc->($task);
 	    $next_time = time + $sleep_intervall;
 	}
 
diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
index 32ffdd1..e0d03f1 100644
--- a/src/PVE/RESTEnvironment.pm
+++ b/src/PVE/RESTEnvironment.pm
@@ -23,7 +23,7 @@ my $rest_env;
 
 # save $SIG{CHLD} handler implementation.
 # simply set $SIG{CHLD} = $worker_reaper;
-# and register forked processes with &$register_worker(pid)
+# and register forked processes with $register_worker->(pid)
 # Note: using $SIG{CHLD} = 'IGNORE' or $SIG{CHLD} = sub { wait (); } or ...
 # has serious side effects, because perls built in system() and open()
 # functions can't get the correct exit status of a child. So we cant use
@@ -71,7 +71,7 @@ my $worker_reaper = sub {
         if (defined($waitpid) && ($waitpid == $pid)) {
 	    my $info = $WORKER_PIDS->{$pid};
 	    if ($info && $info->{upid} && $info->{user}) {
-		&$log_task_result($info->{upid}, $info->{user}, $?);
+		$log_task_result->($info->{upid}, $info->{user}, $?);
 	    }
             delete ($WORKER_PIDS->{$pid});
 	}
@@ -259,14 +259,14 @@ sub active_workers  {
 	    my $upid = $task->{upid};
 	    next if $thash->{$upid};
 	    $thash->{$upid} = $task;
-	    &$check_task($task);
+	    $check_task->($task);
 	}
 
 	if ($new_upid && !(my $task = $thash->{$new_upid})) {
 	    $task = PVE::Tools::upid_decode($new_upid);
 	    $task->{upid} = $new_upid;
 	    $thash->{$new_upid} = $task;
-	    &$check_task($task, $nocheck);
+	    $check_task->($task, $nocheck);
 	}
 
 
@@ -366,7 +366,7 @@ sub check_worker {
     return 0 if !$running;
 
     if ($killit) {
-	&$kill_process_group($task->{pid});
+	$kill_process_group->($task->{pid});
 	return 0;
     }
 
@@ -510,7 +510,7 @@ sub fork_worker {
 	    PVE::INotify::inotify_close();
 
 	    if (my $atfork = $self->{atfork}) {
-		&$atfork();
+		$atfork->();
 	    }
 
 	    # same algorythm as used inside SA
@@ -570,7 +570,7 @@ sub fork_worker {
 	    if ($self->{type} eq 'ha') {
 		print "task started by HA resource agent\n";
 	    }
-	    &$function($upid);
+	    $function->($upid);
 	};
 	my $err = $@;
 	if ($err) {
@@ -602,7 +602,7 @@ sub fork_worker {
 
     if (!$sync) {
 	POSIX::close($psync[0]);
-	&$register_worker($cpid, $user, $upid);
+	$register_worker->($cpid, $user, $upid);
     } else {
 	chomp $readbuf;
     }
@@ -647,13 +647,13 @@ sub fork_worker {
 
 	$tee_worker->($psync[0], $ctrlfd[0], $outfh, $cpid);
 
-	&$kill_process_group($cpid, $pstart); # make sure it gets killed
+	$kill_process_group->($cpid, $pstart); # make sure it gets killed
 
 	close($outfh);
 
 	waitpid($cpid, 0);
 	$res = $?;
-	&$log_task_result($upid, $user, $res);
+	$log_task_result->($upid, $user, $res);
     }
 
     return wantarray ? ($upid, $res) : $upid;
diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm
index a99ed47..1a18356 100644
--- a/src/PVE/RESTHandler.pm
+++ b/src/PVE/RESTHandler.pm
@@ -411,7 +411,7 @@ sub handle {
 	$param->{'extra-args'} = [map { /^(.*)$/ } @$extra] if $extra;
     }
 
-    my $result = &$func($param); 
+    my $result = $func->($param); 
 
     # todo: this is only to be safe - disable?
     if (my $schema = $info->{returns}) {
@@ -609,7 +609,7 @@ sub usage_str {
     foreach my $k (@$arg_param) {
 	next if defined($fixed_param->{$k}); # just to be sure
 	next if !$prop->{$k}; # just to be sure
-	$argdescr .= &$get_property_description($k, 'fixed', $prop->{$k}, $format, 0);
+	$argdescr .= $get_property_description->($k, 'fixed', $prop->{$k}, $format, 0);
     }
 
     my $idx_param = {}; # -vlan\d+ -scsi\d+
@@ -633,10 +633,10 @@ sub usage_str {
 	    }
 	}
 
-	my $param_mapping_hash = $compute_param_mapping_hash->(&$param_mapping_func($name))
+	my $param_mapping_hash = $compute_param_mapping_hash->($param_mapping_func->($name))
 	    if $param_mapping_func;
 
-	$opts .= &$get_property_description($base, 'arg', $prop->{$k}, $format,
+	$opts .= $get_property_description->($base, 'arg', $prop->{$k}, $format,
 					    $hidepw, $param_mapping_hash->{$k});
 
 	if (!$prop->{$k}->{optional}) {
@@ -687,7 +687,7 @@ sub dump_properties {
     foreach my $k (sort keys %$prop) {
 	my $phash = $prop->{$k};
 
-	next if defined($filterFn) && &$filterFn($k, $phash);
+	next if defined($filterFn) && $filterFn->($k, $phash);
 	next if $phash->{alias};
 
 	my $base = $k;
@@ -700,7 +700,7 @@ sub dump_properties {
 	    }
 	}
 
-	$raw .= &$get_property_description($base, $style, $phash, $format, 0);
+	$raw .= $get_property_description->($base, $style, $phash, $format, 0);
 
 	next if $style ne 'config';
 
@@ -743,7 +743,7 @@ sub cli_handler {
 	my $param = PVE::JSONSchema::get_options($info->{parameters}, $args, $arg_param, $fixed_param, $read_password_func, $param_mapping_hash);
 
 	if (defined($param_mapping_hash)) {
-	    &$replace_file_names_with_contents($param, $param_mapping_hash);
+	    $replace_file_names_with_contents->($param, $param_mapping_hash);
 	}
 
 	$res = $self->handle($info, $param);
diff --git a/src/PVE/SectionConfig.pm b/src/PVE/SectionConfig.pm
index cc03aea..5e49c2b 100644
--- a/src/PVE/SectionConfig.pm
+++ b/src/PVE/SectionConfig.pm
@@ -90,7 +90,7 @@ sub createSchema {
 
 	if ($required) {
 	    # make a copy, because we modify the optional property
-	    my $res = &$copy_property($propertyList->{$p});
+	    my $res = $copy_property->($propertyList->{$p});
 	    $res->{optional} = 0;
 	    $props->{$p} = $res;
 	} else {
@@ -308,7 +308,7 @@ sub parse_config {
 	}
     };
 
-    while (my $line = &$nextline()) {
+    while (my $line = $nextline->()) {
 	my $errprefix = "file $filename line $lineno";
 
 	my ($type, $sectionId, $errmsg, $config) = $class->parse_section_header($line);
@@ -331,7 +331,7 @@ sub parse_config {
 		}
 	    }
 
-	    while ($line = &$nextline()) {
+	    while ($line = $nextline->()) {
 		next if $ignore; # skip
 
 		$errprefix = "file $filename line $lineno";
@@ -454,7 +454,7 @@ sub write_config {
 	if ($scfg->{comment} && !$done_hash->{comment}) {
 	    my $k = 'comment';
 	    my $v = $class->encode_value($type, $k, $scfg->{$k});
-	    $data .= &$format_config_line($propertyList->{$k}, $k, $v);
+	    $data .= $format_config_line->($propertyList->{$k}, $k, $v);
 	}
 
 	$data .= "\tdisable\n" if $scfg->{disable} && !$done_hash->{disable};
@@ -471,7 +471,7 @@ sub write_config {
 	    die "section '$sectionId' - missing value for required option '$k'\n"
 		if !defined ($v);
 	    $v = $class->encode_value($type, $k, $v);
-	    $data .= &$format_config_line($propertyList->{$k}, $k, $v);
+	    $data .= $format_config_line->($propertyList->{$k}, $k, $v);
 	}
 
 	foreach my $k (@option_keys) {
@@ -479,7 +479,7 @@ sub write_config {
 	    my $v = $scfg->{$k};
 	    next if !defined($v);
 	    $v = $class->encode_value($type, $k, $v);
-	    $data .= &$format_config_line($propertyList->{$k}, $k, $v);
+	    $data .= $format_config_line->($propertyList->{$k}, $k, $v);
 	}
 
 	$out .= "$data\n";
diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 1c5b502..b973409 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -106,7 +106,7 @@ sub run_with_timeout {
 
 	alarm($timeout);
 
-	eval { $res = &$code(@param); };
+	eval { $res = $code->(@param); };
 
 	alarm(0); # avoid race conditions
 
@@ -201,7 +201,7 @@ sub lock_file_full {
 	}
 	$check = 1;
     }
-    $res = eval { &$code(@param); };
+    $res = eval { $code->(@param); };
     return undef if $@;
     return $res;
 }
@@ -408,7 +408,7 @@ sub run_command {
 	    $errfunc = sub {
 		if ($laststderr) {
 		    if ($origerrfunc) {
-			&$origerrfunc("$laststderr\n");
+			$origerrfunc->("$laststderr\n");
 		    } else {
 			print STDERR "$laststderr\n" if $laststderr;
 		    }
@@ -455,7 +455,7 @@ sub run_command {
 	local $SIG{ALRM} = sub { die "got timeout\n"; } if $timeout;
 	$oldtimeout = alarm($timeout) if $timeout;
 
-	&$afterfork() if $afterfork;
+	$afterfork->() if $afterfork;
 
 	if (ref($writer)) {
 	    print $writer $input if defined $input;
@@ -490,8 +490,8 @@ sub run_command {
 			    $outlog .= $buf;
 			    while ($outlog =~ s/^([^\010\r\n]*)(\r|\n|(\010)+|\r\n)//s) {
 				my $line = $1;
-				&$outfunc($line) if $outfunc;
-				&$logfunc($line) if $logfunc;
+				$outfunc->($line) if $outfunc;
+				$logfunc->($line) if $logfunc;
 			    }
 			};
 			my $err = $@;
@@ -510,8 +510,8 @@ sub run_command {
 			    $errlog .= $buf;
 			    while ($errlog =~ s/^([^\010\r\n]*)(\r|\n|(\010)+|\r\n)//s) {
 				my $line = $1;
-				&$errfunc($line) if $errfunc;
-				&$logfunc($line) if $logfunc;
+				$errfunc->($line) if $errfunc;
+				$logfunc->($line) if $logfunc;
 			    }
 			};
 			my $err = $@;
@@ -528,11 +528,11 @@ sub run_command {
 	    }
 	}
 
-	&$outfunc($outlog) if $outfunc && $outlog;
-	&$logfunc($outlog) if $logfunc && $outlog;
+	$outfunc->($outlog) if $outfunc && $outlog;
+	$logfunc->($outlog) if $logfunc && $outlog;
 
-	&$errfunc($errlog) if $errfunc && $errlog;
-	&$logfunc($errlog) if $logfunc && $errlog;
+	$errfunc->($errlog) if $errfunc && $errlog;
+	$logfunc->($errlog) if $logfunc && $errlog;
 
 	waitpid ($pid, 0);
 
@@ -559,7 +559,7 @@ sub run_command {
     alarm(0);
 
     if ($errmsg && $laststderr) {
-	&$errfunc(undef); # flush laststderr
+	$errfunc->(undef); # flush laststderr
     }
 
     umask ($old_umask) if defined($old_umask);
-- 
2.11.0




More information about the pve-devel mailing list