From 4ccc3ac4eb3294a0463b9fcd919c96aa9dc66700 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Wed, 21 Oct 2026 13:25:26 +0300 Subject: [PATCH] scst: Make constant-success helper results explicit Make netlink registration and the optional mode-page path check return void and remove callers' unreachable error checks. Neither helper can fail its caller. Preserve success ACKs, the disabled mode-page fallback and all reachable error paths. Return explicit success after the checked portal-address ioctl. Source review also found that scst_cm_ext_copy_exec() never changes its result variable; return SCST_EXEC_COMPLETED directly while preserving command completion callbacks and error paths. Cppcheck reports knownConditionTrueFalse: Condition 'err' is always false. Cppcheck reports identicalConditionAfterEarlyExit: Identical condition and return expression 'ret', return value is always 0 --- iscsi-scst/kernel/event.c | 11 +++-------- iscsi-scst/usr/iscsi_scstd.c | 2 +- scst/src/dev_handlers/scst_vdisk_main.c | 11 +++-------- scst/src/scst_copy_mgr.c | 3 +-- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/iscsi-scst/kernel/event.c b/iscsi-scst/kernel/event.c index 1ac927ab7..01bd4ce2a 100644 --- a/iscsi-scst/kernel/event.c +++ b/iscsi-scst/kernel/event.c @@ -49,7 +49,7 @@ static inline void netlink_ack_backport(struct sk_buff *in_skb, static struct sock *nl; static u32 iscsid_pid; -static int event_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) +static void event_recv_msg(struct sk_buff *skb) { u32 pid; @@ -57,13 +57,10 @@ static int event_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) WARN_ON(pid == 0); iscsid_pid = pid; - - return 0; } static void event_recv_skb(struct sk_buff *skb) { - int err; struct nlmsghdr *nlh; u32 rlen; @@ -74,10 +71,8 @@ static void event_recv_skb(struct sk_buff *skb) rlen = NLMSG_ALIGN(nlh->nlmsg_len); if (rlen > skb->len) rlen = skb->len; - err = event_recv_msg(skb, nlh); - if (err) - netlink_ack(skb, nlh, -err, NULL); - else if (nlh->nlmsg_flags & NLM_F_ACK) + event_recv_msg(skb); + if (nlh->nlmsg_flags & NLM_F_ACK) netlink_ack(skb, nlh, 0, NULL); skb_pull(skb, rlen); } diff --git a/iscsi-scst/usr/iscsi_scstd.c b/iscsi-scst/usr/iscsi_scstd.c index d89e2a559..0e9d6aee0 100644 --- a/iscsi-scst/usr/iscsi_scstd.c +++ b/iscsi-scst/usr/iscsi_scstd.c @@ -319,7 +319,7 @@ static int iser_getsockname(int fd, struct sockaddr *name, socklen_t *namelen) memcpy(name, &addr.addr, addr.addr_len); *namelen = addr.addr_len; - return ret; + return 0; } static int iser_is_discovery(int fd) diff --git a/scst/src/dev_handlers/scst_vdisk_main.c b/scst/src/dev_handlers/scst_vdisk_main.c index c7aa0d94f..0e8f0a799 100644 --- a/scst/src/dev_handlers/scst_vdisk_main.c +++ b/scst/src/dev_handlers/scst_vdisk_main.c @@ -9864,7 +9864,7 @@ static void init_ops(vdisk_op_fn *ops, int count) ops[i] = vdisk_invalid_opcode; } -static int __init vdev_check_mode_pages_path(void) +static void __init vdev_check_mode_pages_path(void) { int res; struct path path; @@ -9880,10 +9880,7 @@ static int __init vdev_check_mode_pages_path(void) vdev_saved_mode_pages_enabled = false; } - res = 0; /* always succeed */ - - TRACE_EXIT_RES(res); - return res; + TRACE_EXIT(); } #define SHARED_OPS \ @@ -10005,9 +10002,7 @@ static int __init init_scst_vdisk_driver(void) init_ops(blockio_ops, ARRAY_SIZE(blockio_ops)); init_ops(nullio_ops, ARRAY_SIZE(nullio_ops)); - res = vdev_check_mode_pages_path(); - if (res != 0) - goto out; + vdev_check_mode_pages_path(); vdisk_cmd_param_cachep = KMEM_CACHE(vdisk_cmd_params, SCST_SLAB_FLAGS | SLAB_HWCACHE_ALIGN); diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index 0eb134b66..830f6a615 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -1584,7 +1584,6 @@ out: enum scst_exec_res scst_cm_ext_copy_exec(struct scst_cmd *ec_cmd) { - enum scst_exec_res res = SCST_EXEC_COMPLETED; int rc; struct scst_cm_ec_cmd_priv *priv = ec_cmd->cmd_data_descriptors; @@ -1606,7 +1605,7 @@ enum scst_exec_res scst_cm_ext_copy_exec(struct scst_cmd *ec_cmd) out: TRACE_EXIT(); - return res; + return SCST_EXEC_COMPLETED; out_local_done: ec_cmd->completed = 1; /* for success */