[pve-devel] [PATCH manager 1/3] pvesubscription: add missing return statement

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jan 10 10:29:50 CET 2024


any reason this is relevant you might want to add to the commit
message here?

Am 09/01/2024 um 15:23 schrieb Alexander Zeidler:
> Signed-off-by: Alexander Zeidler <a.zeidler at proxmox.com>
> ---
>  PVE/CLI/pvesubscription.pm | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/PVE/CLI/pvesubscription.pm b/PVE/CLI/pvesubscription.pm
> index 2eb26cb4..2fd641d0 100755
> --- a/PVE/CLI/pvesubscription.pm
> +++ b/PVE/CLI/pvesubscription.pm
> @@ -47,6 +47,8 @@ __PACKAGE__->register_method({
>  	PVE::API2::Subscription::check_key($info->{key}, PVE::API2::Subscription::get_sockets());
>  
>  	PVE::API2::Subscription::write_etc_subscription($info);
> +
> +	return undef;

simple

return;

is slightly preferred for returning undef, as there is a very rare, but
 nasty bug one can hit with returning undef.
I.e., if the call site forces list-context and checks if something is
returned then the `return` works but return undef returns a single undef
element in a (defined) list, thus causing a false-positive fora check like
`if (my @foo = bar()) { ... }`.

As said, this is rather seldom and forced-list context is not that often
used so we do not need to clean up existing code, but for new one it makes
sense to default to a plain `return;` in such cases.

>  }});
>  
>  our $cmddef = {





More information about the pve-devel mailing list