diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index 6cec2d400..74c547ac0 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -235,7 +235,8 @@ static int get_conn_info(struct iscsi_target *target, unsigned long ptr) struct conn_info info; struct iscsi_conn *conn; - if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0) + err = copy_from_user(&info, (void *) ptr, sizeof(info)); + if (err < 0) return err; session = session_lookup(target, info.sid); @@ -260,10 +261,12 @@ static int add_conn(struct iscsi_target *target, unsigned long ptr) struct iscsi_session *session; struct conn_info info; - if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0) + err = copy_from_user(&info, (void *) ptr, sizeof(info)); + if (err < 0) return err; - if (!(session = session_lookup(target, info.sid))) + session = session_lookup(target, info.sid); + if (!session) return -ENOENT; return conn_add(session, &info); @@ -276,10 +279,12 @@ static int del_conn(struct iscsi_target *target, unsigned long ptr) struct iscsi_session *session; struct conn_info info; - if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0) + err = copy_from_user(&info, (void *) ptr, sizeof(info)); + if (err < 0) return err; - if (!(session = session_lookup(target, info.sid))) + session = session_lookup(target, info.sid); + if (!session) return -ENOENT; return conn_del(session, &info); @@ -292,7 +297,8 @@ static int get_session_info(struct iscsi_target *target, unsigned long ptr) struct iscsi_session *session; struct session_info info; - if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0) + err = copy_from_user(&info, (void *) ptr, sizeof(info)); + if (err < 0) return err; session = session_lookup(target, info.sid); @@ -314,7 +320,8 @@ static int add_session(struct iscsi_target *target, unsigned long ptr) int err; struct session_info info; - if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0) + err = copy_from_user(&info, (void *) ptr, sizeof(info)); + if (err < 0) return err; info.initiator_name[ISCSI_NAME_LEN-1] = '\0'; @@ -329,7 +336,8 @@ static int del_session(struct iscsi_target *target, unsigned long ptr) int err; struct session_info info; - if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0) + err = copy_from_user(&info, (void *) ptr, sizeof(info)); + if (err < 0) return err; return session_del(target, info.sid); @@ -341,10 +349,12 @@ static int iscsi_param_config(struct iscsi_target *target, unsigned long ptr, in int err; struct iscsi_param_info info; - if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0) + err = copy_from_user(&info, (void *) ptr, sizeof(info)); + if (err < 0) goto out; - if ((err = iscsi_param_set(target, &info, set)) < 0) + err = iscsi_param_set(target, &info, set); + if (err < 0) goto out; if (!set) @@ -360,10 +370,12 @@ static int add_target(unsigned long ptr) int err; struct target_info info; - if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0) + err = copy_from_user(&info, (void *) ptr, sizeof(info)); + if (err < 0) return err; - if (!(err = target_add(&info))) + err = target_add(&info); + if (!err) err = copy_to_user((void *) ptr, &info, sizeof(info)); return err; @@ -431,10 +443,12 @@ static long ioctl(struct file *file, unsigned int cmd, unsigned long arg) goto out; } - if ((err = get_user(id, (u32 *) arg)) != 0) + err = get_user(id, (u32 *) arg); + if (err != 0) goto out; - if ((err = mutex_lock_interruptible(&target_mgmt_mutex)) < 0) + err = mutex_lock_interruptible(&target_mgmt_mutex); + if (err < 0) goto out; if (cmd == DEL_TARGET) { diff --git a/iscsi-scst/kernel/event.c b/iscsi-scst/kernel/event.c index 7d8f8cb99..68739a206 100644 --- a/iscsi-scst/kernel/event.c +++ b/iscsi-scst/kernel/event.c @@ -56,7 +56,8 @@ static void event_recv_skb(struct sk_buff *skb) rlen = NLMSG_ALIGN(nlh->nlmsg_len); if (rlen > skb->len) rlen = skb->len; - if ((err = event_recv_msg(skb, nlh))) + err = event_recv_msg(skb, nlh); + if (err) netlink_ack(skb, nlh, -err); else if (nlh->nlmsg_flags & NLM_F_ACK) netlink_ack(skb, nlh, 0); @@ -91,7 +92,8 @@ static int notify(void *data, int len, int gfp_mask) struct nlmsghdr *nlh; static u32 seq; - if (!(skb = alloc_skb(NLMSG_SPACE(len), gfp_mask))) + skb = alloc_skb(NLMSG_SPACE(len), gfp_mask); + if (!skb) return -ENOMEM; nlh = __nlmsg_put(skb, iscsid_pid, seq++, NLMSG_DONE, len - sizeof(*nlh), 0); diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 41783266a..946d8b605 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -932,7 +932,8 @@ static void cmnd_prepare_get_rejected_cmd_data(struct iscsi_cmnd *cmnd) iscsi_extracheck_is_rd_thread(conn); - if (!(size = cmnd->pdu.datasize)) + size = cmnd->pdu.datasize; + if (!size) return; if (sg == NULL) { @@ -1210,13 +1211,17 @@ static int noop_out_start(struct iscsi_cmnd *cmnd) spin_unlock(&conn->session->sn_lock); if (unlikely(err)) goto out; - } else if (unlikely((err = cmnd_insert_hash(cmnd)) < 0)) { - PRINT_ERROR("Can't insert in hash: ignore this request %x", - cmnd_itt(cmnd)); - goto out; + } else { + err = cmnd_insert_hash(cmnd); + if (unlikely(err < 0)) { + PRINT_ERROR("Can't insert in hash: ignore this request %x", + cmnd_itt(cmnd)); + goto out; + } } - if ((size = cmnd->pdu.datasize)) { + size = cmnd->pdu.datasize; + if (size) { size = (size + 3) & -4; conn->read_msg.msg_iov = conn->read_iov; if (cmnd->pdu.bhs.itt != cpu_to_be32(ISCSI_RESERVED_TAG)) { @@ -1615,7 +1620,8 @@ static int cmnd_abort(struct iscsi_cmnd *req) goto out; } - if ((cmnd = cmnd_find_hash_get(session, req_hdr->rtt, ISCSI_RESERVED_TAG))) { + cmnd = cmnd_find_hash_get(session, req_hdr->rtt, ISCSI_RESERVED_TAG); + if (cmnd) { struct iscsi_conn *conn = cmnd->conn; struct iscsi_scsi_cmd_hdr *hdr = cmnd_hdr(cmnd); @@ -2909,13 +2915,15 @@ static int __init iscsi_init(void) "degraded mode. Refer README file for details"); #endif - if ((ctr_major = register_chrdev(0, ctr_name, &ctr_fops)) < 0) { + ctr_major = register_chrdev(0, ctr_name, &ctr_fops); + if (ctr_major < 0) { PRINT_ERROR("failed to register the control device %d", ctr_major); err = ctr_major; goto out_callb; } - if ((err = event_init()) < 0) + err = event_init(); + if (err < 0) goto out_reg; iscsi_cmnd_cache = KMEM_CACHE(iscsi_cmnd, SCST_SLAB_FLAGS); @@ -2930,7 +2938,8 @@ static int __init iscsi_init(void) iscsi_template_registered = 1; - if ((err = iscsi_procfs_init()) < 0) + err = iscsi_procfs_init(); + if (err < 0) goto out_reg_tmpl; num = max(num_online_cpus(), 2); diff --git a/iscsi-scst/kernel/param.c b/iscsi-scst/kernel/param.c index 0a64fedbe..61ca57efb 100644 --- a/iscsi-scst/kernel/param.c +++ b/iscsi-scst/kernel/param.c @@ -213,7 +213,8 @@ static int sess_param(struct iscsi_target *target, struct iscsi_param_info *info sess_param_check(info); if (info->sid) { - if (!(session = session_lookup(target, info->sid))) + session = session_lookup(target, info->sid); + if (!session) goto out; if (set && !list_empty(&session->conn_list)) { err = -EBUSY; diff --git a/iscsi-scst/kernel/session.c b/iscsi-scst/kernel/session.c index 004874524..34d6f10ea 100644 --- a/iscsi-scst/kernel/session.c +++ b/iscsi-scst/kernel/session.c @@ -35,7 +35,8 @@ static int iscsi_session_alloc(struct iscsi_target *target, struct session_info struct iscsi_session *session; char *name = NULL; - if (!(session = kzalloc(sizeof(*session), GFP_KERNEL))) + session = kzalloc(sizeof(*session), GFP_KERNEL); + if (!session) return -ENOMEM; session->target = target; diff --git a/iscsi-scst/kernel/target.c b/iscsi-scst/kernel/target.c index c6f0b9a40..c05000d49 100644 --- a/iscsi-scst/kernel/target.c +++ b/iscsi-scst/kernel/target.c @@ -87,7 +87,8 @@ static int iscsi_target_create(struct target_info *info, u32 tid) TRACE_MGMT_DBG("Creating target tid %u, name %s", tid, name); - if (!(len = strlen(name))) { + len = strlen(name); + if (!len) { PRINT_ERROR("The length of the target name is zero %u", tid); goto out; } @@ -97,7 +98,8 @@ static int iscsi_target_create(struct target_info *info, u32 tid) goto out; } - if (!(target = kzalloc(sizeof(*target), GFP_KERNEL))) { + target = kzalloc(sizeof(*target), GFP_KERNEL); + if (!target) { err = -ENOMEM; goto out_put; } @@ -161,7 +163,8 @@ int target_add(struct target_info *info) tid = next_target_id; } - if (!(err = iscsi_target_create(info, tid))) + err = iscsi_target_create(info, tid); + if (!err) nr_targets++; out: return err; @@ -184,7 +187,8 @@ int target_del(u32 id) struct iscsi_target *target; int err; - if (!(target = target_lookup_by_id(id))) { + target = target_lookup_by_id(id); + if (!target) { err = -ENOENT; goto out; } @@ -277,7 +281,8 @@ int iscsi_info_show(struct seq_file *seq, iscsi_show_info_t *func) int err; struct iscsi_target *target; - if ((err = mutex_lock_interruptible(&target_mgmt_mutex)) < 0) + err = mutex_lock_interruptible(&target_mgmt_mutex); + if (err < 0) return err; list_for_each_entry(target, &target_list, target_list_entry) { diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 5c9145940..cfec7dcca 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -244,8 +244,7 @@ do { \ #define PRINT_WARNING(format, args...) \ do { \ - if (strcmp(INFO_FLAG, LOG_FLAG)) \ - { \ + if (strcmp(INFO_FLAG, LOG_FLAG)) { \ PRINT_LOG_FLAG(LOG_FLAG, "***WARNING*** " format, args); \ } \ PRINT_LOG_FLAG(INFO_FLAG, "***WARNING*** " format, args); \ diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index e3e051224..5c1f3053b 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -111,7 +111,7 @@ struct scst_user_cmd { struct page **data_pages; struct sgv_pool_obj *sgv; - /* + /* * Special flags, which can be accessed asynchronously (hence "long"). * Protected by cmd_lists.cmd_list_lock. */ @@ -983,15 +983,15 @@ static void dev_user_add_to_ready(struct scst_user_cmd *ucmd) if ((ucmd->state == UCMD_STATE_PARSING) || (ucmd->state == UCMD_STATE_BUF_ALLOCING)) { - /* - * If we don't put such commands in the queue head, then under - * high load we might delay threads, waiting for memory - * allocations, for too long and start loosing NOPs, which - * would lead to consider us by remote initiators as - * unresponsive and stuck => broken connections, etc. If none - * of our commands completed in NOP timeout to allow the head - * commands to go, then we are really overloaded and/or stuck. - */ + /* + * If we don't put such commands in the queue head, then under + * high load we might delay threads, waiting for memory + * allocations, for too long and start loosing NOPs, which + * would lead to consider us by remote initiators as + * unresponsive and stuck => broken connections, etc. If none + * of our commands completed in NOP timeout to allow the head + * commands to go, then we are really overloaded and/or stuck. + */ TRACE_DBG("Adding ucmd %p (state %d) to head of ready " "cmd list", ucmd, ucmd->state); list_add(&ucmd->ready_cmd_list_entry, diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 1c2b531aa..e2f5bbc4f 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -1171,7 +1171,8 @@ static ssize_t scst_proc_scsi_dev_handler_write(struct file *file, const char __ goto out; } - if (!(buffer = (char *)__get_free_page(GFP_KERNEL))) { + buffer = (char *)__get_free_page(GFP_KERNEL); + if (!buffer) { res = -ENOMEM; goto out; } diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 655bc694e..e46ccddf1 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -541,7 +541,7 @@ static int scst_parse_cmd(struct scst_cmd *cmd) } if (unlikely(cmd->bufflen != cmd->expected_transfer_len)) { static int repd; - + if (repd < 100) { /* * Intentionally unlocked. Few messages more