[pve-devel] [PATCH v1 pve-common 14/18] pbsclient: prohibit implicit return

Max Carrara m.carrara at proxmox.com
Fri Aug 2 15:26:52 CEST 2024


.. for the `set_password`, `set_encryption_key` and
`do_raw_client_cmd` methods.

This makes it very clear that these methods aren't supposed to return
anything. In the case of `do_raw_client_cmd` in particular, the
implicit return of `0` on success (would be `undef` if the command
failed) was never depended on either, so prevent future code from
doing so.

Signed-off-by: Max Carrara <m.carrara at proxmox.com>
---
 src/PVE/PBSClient.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/PVE/PBSClient.pm b/src/PVE/PBSClient.pm
index a701542..4ffdd04 100644
--- a/src/PVE/PBSClient.pm
+++ b/src/PVE/PBSClient.pm
@@ -223,6 +223,7 @@ sub set_password {
     });
 
     PVE::Tools::file_set_contents($pwfile, "$password\n", 0600);
+    return;
 };
 
 =pod
@@ -309,6 +310,7 @@ sub set_encryption_key {
     });
 
     PVE::Tools::file_set_contents($encfile, "$key\n", 0600);
+    return;
 };
 
 =pod
@@ -416,6 +418,7 @@ my sub do_raw_client_cmd {
     }
 
     run_command($cmd, %opts);
+    return;
 }
 
 my sub run_raw_client_cmd : prototype($$$%) {
-- 
2.39.2





More information about the pve-devel mailing list