]> git.proxmox.com Git - pve-installer.git/commitdiff
stdio connected UI: drop perl prototype definitions
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 24 Feb 2024 16:56:26 +0000 (17:56 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 24 Feb 2024 17:00:17 +0000 (18:00 +0100)
The prototypes where completely circumvented by calling those two
methods by reference via &, and that probably happened as the send_msg
one was just wrong, it forced scalar context for the second parameter,
while that was a list (or well hash, but the difference there can be
blurry).

Anyhow, prototypes are not always of help, and can be a PITA with
side-effects too, and especially for such small modules it has not
that much use to declare them for privately-scoped methods, so just
drop them and fix the calling style.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Proxmox/UI/StdIO.pm

index 25d1c8296ae16c0f3d6063ca1fe74b445ebc7383..2838fcbb78a65e1299f52d313d1d2772cf391984 100644 (file)
@@ -9,14 +9,14 @@ use base qw(Proxmox::UI::Base);
 
 use Proxmox::Log;
 
-my sub send_msg : prototype($$) {
+my sub send_msg {
     my ($type, %values) = @_;
 
     my $json = to_json({ type => $type, %values }, { utf8 => 1, canonical => 1 });
     print STDOUT "$json\n";
 }
 
-my sub recv_msg : prototype() {
+my sub recv_msg {
     my $response = <STDIN> // ''; # FIXME: error handling?
     chomp($response);
 
@@ -32,14 +32,14 @@ sub init {
 sub message {
     my ($self, $msg) = @_;
 
-    &send_msg('message', message => $msg);
+    send_msg('message', message => $msg);
 }
 
 sub error {
     my ($self, $msg) = @_;
 
     log_error("error: $msg");
-    &send_msg('error', message => $msg);
+    send_msg('error', message => $msg);
 }
 
 sub finished {
@@ -47,14 +47,14 @@ sub finished {
 
     my $state = $success ? 'ok' : 'err';
     log_info("finished: $state, $msg");
-    &send_msg('finished', state => $state, message => $msg);
+    send_msg('finished', state => $state, message => $msg);
 }
 
 sub prompt {
     my ($self, $query) = @_;
 
-    &send_msg('prompt', query => $query);
-    my $response = &recv_msg();
+    send_msg('prompt', query => $query);
+    my $response = recv_msg();
 
     if (defined($response) && $response->{type} eq 'prompt-answer') {
        return lc($response->{answer}) eq 'ok';
@@ -72,7 +72,7 @@ sub progress {
 
     $text = '' if !defined($text);
 
-    &send_msg('progress', ratio => $ratio, text => $text);
+    send_msg('progress', ratio => $ratio, text => $text);
 }
 
 sub process_events {