From 96dd0ab6bd31c6385bf40bc36e37607c8eaf2f9d Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Tue, 14 Nov 2023 13:00:08 +0100 Subject: [PATCH] coverity: resource: ubridge: fix potential logical dead code in _cmd_exec_scan --- src/resource/ubridge.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/resource/ubridge.c b/src/resource/ubridge.c index 8b55b14f..eb45edc8 100644 --- a/src/resource/ubridge.c +++ b/src/resource/ubridge.c @@ -4647,16 +4647,17 @@ static int _cmd_exec_scan(sid_resource_t *cmd_res) ucmd_ctx->scan.phase = phase; if (_cmd_scan_phase_regs[phase].exec(cmd_res) < 0) { - log_error(ID(cmd_res), - "%s phase failed. Switching to %s phase.", - _cmd_scan_phase_regs[phase].name, - _cmd_scan_phase_regs[CMD_SCAN_PHASE_ERROR].name); - - ucmd_ctx->scan.phase = phase = CMD_SCAN_PHASE_ERROR; - /* if init or cleanup phase fails, there's nothing else we can do */ - if (phase == CMD_SCAN_PHASE_A_INIT || phase == CMD_SCAN_PHASE_A_CLEANUP) + if (phase == CMD_SCAN_PHASE_A_INIT || phase == CMD_SCAN_PHASE_A_CLEANUP) { + log_error(ID(cmd_res), "%s phase failed.", _cmd_scan_phase_regs[phase].name); return -1; + } else + log_error(ID(cmd_res), + "%s phase failed. Switching to %s phase.", + _cmd_scan_phase_regs[phase].name, + _cmd_scan_phase_regs[CMD_SCAN_PHASE_ERROR].name); + + ucmd_ctx->scan.phase = phase = CMD_SCAN_PHASE_ERROR; /* otherwise, call out modules to handle the error case */ if (_cmd_scan_phase_regs[CMD_SCAN_PHASE_ERROR].exec(cmd_res) < 0)