From 46ad98f0725ffc7bff31ea2543344cad6c277d61 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Thu, 28 Jul 2022 20:27:07 +0300 Subject: [PATCH] scst: Remove else after a break or return Remove the else because the if statement has a break or return statement. This patch fixes the following checkpatch warnings: WARNING:UNNECESSARY_ELSE: else is not generally useful after a break or return. --- iscsi-scst/kernel/digest.c | 4 +-- iscsi-scst/kernel/nthread.c | 6 ++--- scst/include/scst.h | 18 ++++++-------- scst/src/dev_handlers/scst_vdisk.c | 16 ++++++------ scst/src/scst_copy_mgr.c | 10 ++++---- scst/src/scst_lib.c | 40 ++++++++++++++---------------- scst/src/scst_pres.c | 5 ++-- scst/src/scst_targ.c | 7 +++--- 8 files changed, 50 insertions(+), 56 deletions(-) diff --git a/iscsi-scst/kernel/digest.c b/iscsi-scst/kernel/digest.c index 463840ce0..baca70b0d 100644 --- a/iscsi-scst/kernel/digest.c +++ b/iscsi-scst/kernel/digest.c @@ -139,10 +139,10 @@ int digest_rx_header(struct iscsi_cmnd *cmnd) if (unlikely(crc != cmnd->hdigest)) { PRINT_ERROR("%s", "RX header digest failed"); return -EIO; - } else { - TRACE_DBG("RX header digest OK for cmd %p", cmnd); } + TRACE_DBG("RX header digest OK for cmd %p", cmnd); + return 0; } diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 5d4626d14..e91a88541 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -1020,10 +1020,10 @@ void req_add_to_write_timeout_list(struct iscsi_cmnd *req) &r->write_timeout_list_entry); inserted = true; break; - } else { - TRACE_DBG("Skipping op %x req %p (tt %ld)", - cmnd_opcode(r), r, tt); } + + TRACE_DBG("Skipping op %x req %p (tt %ld)", + cmnd_opcode(r), r, tt); } if (!inserted) { TRACE_DBG("Add NOP IN req %p in the tail", req); diff --git a/scst/include/scst.h b/scst/include/scst.h index 142b726ec..d9b1ec3a2 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -4675,10 +4675,9 @@ static inline uint16_t scst_cmd_get_dif_exp_app_tag(struct scst_cmd *cmd) #endif if (cmd->cdb_len == 32) return get_unaligned_be16(&cmd->cdb[24]); - else { - /* cmd->dev must be alive at this point */ - return be16_to_cpu(cmd->dev->dev_dif_static_app_tag); - } + + /* cmd->dev must be alive at this point */ + return be16_to_cpu(cmd->dev->dev_dif_static_app_tag); } /* @@ -4693,12 +4692,11 @@ static inline uint16_t scst_cmd_get_dif_app_tag_mask(struct scst_cmd *cmd) #endif if (cmd->cdb_len == 32) return get_unaligned_be16(&cmd->cdb[26]); - else { - if (scst_get_dif_checks(cmd->cmd_dif_actions) & SCST_DIF_CHECK_APP_TAG) - return 0xFFFF; - else - return 0; - } + + if (scst_get_dif_checks(cmd->cmd_dif_actions) & SCST_DIF_CHECK_APP_TAG) + return 0xFFFF; + + return 0; } /* diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 2e3b302f7..de23faab4 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3182,9 +3182,9 @@ static void fileio_async_complete(struct kiocb *iocb, long ret w->cmd = cmd; schedule_work(&w->work); return; - } else { - scst_set_busy(cmd); } + + scst_set_busy(cmd); } cmd->completed = 1; cmd->scst_cmd_done(cmd, SCST_CMD_STATE_DEFAULT, scst_estimate_context()); @@ -6978,8 +6978,8 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev, } if (dd == NULL) break; - else - *dd = '|'; + + *dd = '|'; d = dd+1; } TRACE_DBG("DIF DEV mode %x", virt_dev->dif_mode); @@ -9007,13 +9007,13 @@ static ssize_t vdev_sysfs_naa_id_store(struct kobject *kobj, case 2 * 8: if (strchr("235", buf[0])) break; - else - goto out; + + goto out; case 2 * 16: if (strchr("6", buf[0])) break; - else - goto out; + + goto out; default: goto out; } diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index 7355fff81..8b52974dc 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -1946,12 +1946,12 @@ static struct scst_cm_list_id *scst_cm_add_list_id(struct scst_cmd *cmd, if (l->cm_list_id_state == SCST_CM_LIST_ID_STATE_PENDING_FREE) { scst_cm_del_free_list_id(l); break; - } else { - TRACE_DBG("List id %d already exists", list_id); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_operation_in_progress)); - goto out_unlock_free; } + + TRACE_DBG("List id %d already exists", list_id); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_operation_in_progress)); + goto out_unlock_free; } } diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 37bbdbd8a..b25e2a866 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -3201,11 +3201,11 @@ const char *scst_get_opcode_name(struct scst_cmd *cmd) { if (cmd->op_name) return cmd->op_name; - else { - scnprintf(cmd->not_parsed_op_name, - sizeof(cmd->not_parsed_op_name), "0x%x", cmd->cdb[0]); - return cmd->not_parsed_op_name; - } + + scnprintf(cmd->not_parsed_op_name, + sizeof(cmd->not_parsed_op_name), "0x%x", cmd->cdb[0]); + + return cmd->not_parsed_op_name; } EXPORT_SYMBOL(scst_get_opcode_name); #endif @@ -7036,14 +7036,12 @@ static void scst_send_release(struct scst_device *dev) sense, 15, 0, 0); TRACE_DBG("RELEASE done: %x", rc); - if (scsi_status_is_good(rc)) { + if (scsi_status_is_good(rc)) break; - } else { - PRINT_ERROR("RELEASE failed: %d", rc); - PRINT_BUFFER("RELEASE sense", sense, sizeof(sense)); - scst_check_internal_sense(dev, rc, sense, - sizeof(sense)); - } + + PRINT_ERROR("RELEASE failed: %d", rc); + PRINT_BUFFER("RELEASE sense", sense, sizeof(sense)); + scst_check_internal_sense(dev, rc, sense, sizeof(sense)); } out: @@ -11407,13 +11405,12 @@ static int get_cdb_info_read_10(struct scst_cmd *cmd, if (res != 0) return res; - else { + #ifdef CONFIG_SCST_DIF_INJECT_CORRUPTED_TAGS - EXTRACHECKS_BUG_ON(cmd->cdb[0] != READ_10); - cmd->cmd_corrupt_dif_tag = (cmd->cdb[6] & 0xE0) >> 5; + EXTRACHECKS_BUG_ON(cmd->cdb[0] != READ_10); + cmd->cmd_corrupt_dif_tag = (cmd->cdb[6] & 0xE0) >> 5; #endif - return scst_parse_rdprotect(cmd); - } + return scst_parse_rdprotect(cmd); } static int get_cdb_info_lba_4_len_2_wrprotect(struct scst_cmd *cmd, @@ -11474,13 +11471,12 @@ static int get_cdb_info_read_16(struct scst_cmd *cmd, if (res != 0) return res; - else { + #ifdef CONFIG_SCST_DIF_INJECT_CORRUPTED_TAGS - EXTRACHECKS_BUG_ON(cmd->cdb[0] != READ_16); - cmd->cmd_corrupt_dif_tag = (cmd->cdb[14] & 0xE0) >> 5; + EXTRACHECKS_BUG_ON(cmd->cdb[0] != READ_16); + cmd->cmd_corrupt_dif_tag = (cmd->cdb[14] & 0xE0) >> 5; #endif - return scst_parse_rdprotect(cmd); - } + return scst_parse_rdprotect(cmd); } static int get_cdb_info_lba_8_len_4_wrprotect(struct scst_cmd *cmd, diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 4173ac7ab..268ec9da0 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -169,8 +169,9 @@ bool tid_equal(const uint8_t *tid_a, const uint8_t *tid_b) if (tolower(tid_a[i]) != tolower(tid_b[i])) return false; return true; - } else - len = TID_COMMON_SIZE; + } + + len = TID_COMMON_SIZE; return memcmp(tid_a, tid_b, len) == 0; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index f64acb7a9..9f222e8a7 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -4937,10 +4937,9 @@ again: if (++thr_cnt == 2) break; - else { - spin_lock_irq(&thr->thr_cmd_list_lock); - thr_locked = true; - } + + spin_lock_irq(&thr->thr_cmd_list_lock); + thr_locked = true; } } while (someth_done);