Skip to content

Commit bf64a6b

Browse files
trgillrichm
authored andcommitted
fix: remove redundant variable initialization flagged by CodeQL
Removed dead store of rc variable in mgr_snapshot_cmd(). The variable was initialized to SnapshotStatus.SNAPSHOT_OK but immediately overwritten by verify_snapset_source_lvs_exist() before ever being used. In the check_mode path, explicitly use SnapshotStatus.SNAPSHOT_OK instead of the rc variable for clarity, since we know rc must be SNAPSHOT_OK at that point (or we would have returned early on line 213-214). This fixes CodeQL alert py/multiple-definition: 'This assignment to rc is unnecessary as it is redefined before this value is used.' Addresses: https://github.com/linux-system-roles/snapshot/security/code-scanning/95 Signed-off-by: Todd Gill <tgill@redhat.com>
1 parent e25e068 commit bf64a6b

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

module_utils/snapshot_lsr/snapmgr.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ def mgr_snapshot_cmd(module, module_args, snapset_json):
206206
logger.info("mgr_snapshot_cmd: %s", snapset_name)
207207
changed = False
208208
message = ""
209-
rc = SnapshotStatus.SNAPSHOT_OK
210209
check_mode = module_args["ansible_check_mode"]
211210

212211
rc, message = verify_snapset_source_lvs_exist(module, snapset_json)
@@ -242,7 +241,7 @@ def mgr_snapshot_cmd(module, module_args, snapset_json):
242241

243242
if check_mode:
244243
return {
245-
"return_code": rc,
244+
"return_code": SnapshotStatus.SNAPSHOT_OK,
246245
"errors": "Would call function manager.create_snapshot_set()",
247246
"changed": False,
248247
}

0 commit comments

Comments
 (0)