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
This commit is contained in:
Gleb Chesnokov
2026-10-21 22:12:25 +03:00
parent 93fd830254
commit 4ccc3ac4eb
4 changed files with 8 additions and 19 deletions
+3 -8
View File
@@ -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);
}
+1 -1
View File
@@ -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)
+3 -8
View File
@@ -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);
+1 -2
View File
@@ -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 */