[pve-devel] [Patch container] fix #1792: Do not assign vars in conditional statement
Wolfgang Link
w.link at proxmox.com
Tue Jun 5 12:58:47 CEST 2018
If a variable is defined and assigned in a conditional statement,
it is not defined behavior in Perl.
For more inforamtion about this behavior see
https://perldoc.perl.org/perlsyn.html#Statement-Modifiers
"NOTE: The behaviour of a my, state, or our modified with a statement
modifier conditional or loop construct (for example, my $x if ... )
is undefined.
The value of the my variable may be undef, any previously assigned
value, or possibly anything else.
Don't rely on it. Future versions of perl might do something different
from the version of perl you try it out on. Here be dragons."
---
src/PVE/LXC.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index bfca9c1..4be1579 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1208,7 +1208,8 @@ sub mountpoint_mount {
}
my $readonly = $mountpoint->{ro};
- my @extra_opts = ('-o', $optstring) if $optstring;
+ my @extra_opts;
+ @extra_opts = ('-o', $optstring) if $optstring;
if ($storage) {
--
2.11.0
More information about the pve-devel
mailing list