scstadmin: Eliminate use of uninitialized value in numeric error

Using scstadmin to reload a configuration with fewer targets can result
in a "Use of uninitialized value in numeric ne" error.  Rectify by adding
a check for the undefined value and handling the situation (by disabling
the target in question, unless the driver is copy_manager).
This commit is contained in:
Brian Meagher
2024-01-24 15:06:15 -08:00
committed by Gleb Chesnokov
parent 2f9a82bb87
commit f4f8da8b4d

View File

@@ -2831,10 +2831,17 @@ sub applyConfigEnableTargets {
my $t_attributes;
($t_attributes, $errorString) = $SCST->targetAttributes($driver, $target);
if (defined($$t_attributes{'enabled'}) &&
($$t_attributes{'enabled'}->{'value'} != $$attributes{'enabled'})) {
setTargetAttribute($driver, $target, 'enabled', $$attributes{'enabled'});
$changes++;
if (defined($$attributes{'enabled'})) {
if (defined($$t_attributes{'enabled'}) &&
($$t_attributes{'enabled'}->{'value'} != $$attributes{'enabled'})) {
setTargetAttribute($driver, $target, 'enabled', $$attributes{'enabled'});
$changes++;
}
} else {
if ($driver ne 'copy_manager') {
setTargetAttribute($driver, $target, 'enabled', 0);
$changes++;
}
}
}
}