diff --git a/iscsi-scst/usr/chap.c b/iscsi-scst/usr/chap.c index 8a0e869cf..14cb033fe 100644 --- a/iscsi-scst/usr/chap.c +++ b/iscsi-scst/usr/chap.c @@ -527,7 +527,8 @@ static int chap_initiator_auth_check_response(struct connection *conn) goto out; } - if (!(value = text_key_find(conn, "CHAP_N"))) { + value = text_key_find(conn, "CHAP_N"); + if (!value) { retval = CHAP_INITIATOR_ERROR; goto out; } @@ -544,12 +545,14 @@ static int chap_initiator_auth_check_response(struct connection *conn) goto out; } - if (!(value = text_key_find(conn, "CHAP_R"))) { + value = text_key_find(conn, "CHAP_R"); + if (!value) { retval = CHAP_INITIATOR_ERROR; goto out; } - if ((encoding_format = chap_check_encoding_format(value)) < 0) { + encoding_format = chap_check_encoding_format(value); + if (encoding_format < 0) { retval = CHAP_INITIATOR_ERROR; goto out; } @@ -650,7 +653,8 @@ static int chap_target_auth_create_response(struct connection *conn) int challenge_len = 0, digest_len = 0, retval = 0; int res; - if (!(value = text_key_find(conn, "CHAP_I"))) { + value = text_key_find(conn, "CHAP_I"); + if (!value) { /* Initiator doesn't want target auth!? */ conn->state = STATE_SECURITY_DONE; retval = 0; @@ -666,14 +670,16 @@ static int chap_target_auth_create_response(struct connection *conn) goto out; } - if (!(value = text_key_find(conn, "CHAP_C"))) { + value = text_key_find(conn, "CHAP_C"); + if (!value) { log_warning("CHAP target auth.: got no challenge from initiator %s", conn->initiator); retval = CHAP_INITIATOR_ERROR; goto out; } - if ((encoding_format = chap_check_encoding_format(value)) < 0) { + encoding_format = chap_check_encoding_format(value); + if (encoding_format < 0) { retval = CHAP_INITIATOR_ERROR; goto out; } diff --git a/iscsi-scst/usr/config.c b/iscsi-scst/usr/config.c index 1c47a77e8..acc096afe 100644 --- a/iscsi-scst/usr/config.c +++ b/iscsi-scst/usr/config.c @@ -387,7 +387,8 @@ int config_account_query(u32 tid, int dir, const char *name, char *pass) { struct iscsi_attr *user; - if (!(user = account_lookup_by_name(tid, dir, name))) + user = account_lookup_by_name(tid, dir, name); + if (!user) return -ENOENT; iscsi_strscpy(pass, ISCSI_USER_PASS(user), ISCSI_NAME_LEN); @@ -706,13 +707,15 @@ static int __initiator_match(int fd, char *str) if (*p == '[') { p++; - if (!(q = strchr(p, ']'))) + q = strchr(p, ']'); + if (!q) return 0; *(q++) = '\0'; } else q = p; - if ((q = strchr(q, '/'))) + q = strchr(q, '/'); + if (q) *(q++) = '\0'; memset(&hints, 0, sizeof(hints)); @@ -742,7 +745,8 @@ static int initiator_match(u32 tid, int fd, const char *filename) FILE *fp; char buf[BUFSIZE], *p; - if (!(fp = fopen(filename, "r"))) + fp = fopen(filename, "r"); + if (!fp) return err; /* @@ -816,7 +820,8 @@ int config_target_destroy(u32 tid) { int err; - if ((err = target_del(tid, 0)) < 0) + err = target_del(tid, 0); + if (err < 0) return err; return err; diff --git a/iscsi-scst/usr/ctldev.c b/iscsi-scst/usr/ctldev.c index 2ef7cb3e3..114b12739 100644 --- a/iscsi-scst/usr/ctldev.c +++ b/iscsi-scst/usr/ctldev.c @@ -165,7 +165,8 @@ int kernel_target_create(struct target *target, u32 *tid, u32 cookie) log_debug(1, "Adding target %s (attrs_num %d)", target->name, info.attrs_num); - if ((err = ioctl(ctrl_fd, ADD_TARGET, &info)) < 0) { + err = ioctl(ctrl_fd, ADD_TARGET, &info); + if (err < 0) { err = -errno; log_error("Can't create target %s: %s\n", target->name, strerror(errno)); @@ -262,7 +263,8 @@ int kernel_initiator_allowed(u32 tid, const char *full_initiator_name) iscsi_strscpy(info.full_initiator_name, full_initiator_name, sizeof(info.full_initiator_name)); - if ((err = ioctl(ctrl_fd, ISCSI_INITIATOR_ALLOWED, &info)) < 0) { + err = ioctl(ctrl_fd, ISCSI_INITIATOR_ALLOWED, &info); + if (err < 0) { err = -errno; log_error("Can't find out initiator %s permissions (%s, " "tid %u", full_initiator_name, strerror(errno), tid); @@ -280,7 +282,8 @@ int kernel_conn_destroy(u32 tid, u64 sid, u32 cid) info.sid = sid; info.cid = cid; - if ((err = ioctl(ctrl_fd, DEL_CONN, &info)) < 0) { + err = ioctl(ctrl_fd, DEL_CONN, &info); + if (err < 0) { err = -errno; log_debug(2, "Can't destroy conn (%s, tid %u, sid 0x%" PRIx64 ", cid %u\n", strerror(errno), tid, sid, cid); @@ -305,7 +308,8 @@ int kernel_params_get(u32 tid, u64 sid, int type, struct iscsi_param *params) info.sid = sid; info.params_type = type; - if ((err = ioctl(ctrl_fd, ISCSI_PARAM_GET, &info)) < 0) { + err = ioctl(ctrl_fd, ISCSI_PARAM_GET, &info); + if (err < 0) { err = -errno; log_debug(1, "Can't get session params for session 0x%" PRIx64 " (tid %u, err %d): %s\n", sid, tid, err, strerror(errno)); @@ -347,7 +351,8 @@ int kernel_params_set(u32 tid, u64 sid, int type, u32 partial, for (i = 0; i < target_key_last; i++) info.target_params[i] = params[i].val; - if ((err = ioctl(ctrl_fd, ISCSI_PARAM_SET, &info)) < 0) { + err = ioctl(ctrl_fd, ISCSI_PARAM_SET, &info); + if (err < 0) { err = -errno; log_error("Can't set session params for session 0x%" PRIx64 " (tid %u, type %d, partial %d, err %d): %s\n", sid, diff --git a/iscsi-scst/usr/event.c b/iscsi-scst/usr/event.c index be9992825..f9542995e 100644 --- a/iscsi-scst/usr/event.c +++ b/iscsi-scst/usr/event.c @@ -172,7 +172,8 @@ static int handle_e_add_target(int fd, const struct iscsi_kern_event *event) offs = sprintf(buf, "Target "); while (1) { - if ((rc = nl_read(fd, &buf[offs], event->param1_size, true)) < 0) { + rc = nl_read(fd, &buf[offs], event->param1_size, true); + if (rc < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue; log_error("read netlink fd (%d) failed: %s", fd, @@ -188,7 +189,8 @@ static int handle_e_add_target(int fd, const struct iscsi_kern_event *event) if (event->param2_size > 0) { while (1) { - if ((rc = nl_read(fd, &buf[offs], event->param2_size, true)) < 0) { + rc = nl_read(fd, &buf[offs], event->param2_size, true); + if (rc < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue; log_error("read netlink fd (%d) failed: %s", fd, @@ -409,7 +411,8 @@ static int handle_e_mgmt_cmd(int fd, const struct iscsi_kern_event *event) } while (1) { - if ((rc = nl_read(fd, buf, event->param1_size, true)) < 0) { + rc = nl_read(fd, buf, event->param1_size, true); + if (rc < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue; log_error("read netlink fd (%d) failed: %s", fd, @@ -501,7 +504,8 @@ static int handle_e_get_attr_value(int fd, const struct iscsi_kern_event *event) } while (1) { - if ((rc = nl_read(fd, buf, event->param1_size, true)) < 0) { + rc = nl_read(fd, buf, event->param1_size, true); + if (rc < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue; log_error("read netlink fd (%d) failed: %s", fd, @@ -818,7 +822,8 @@ static int handle_e_set_attr_value(int fd, const struct iscsi_kern_event *event) } while (1) { - if ((rc = nl_read(fd, buf, event->param1_size, true)) < 0) { + rc = nl_read(fd, buf, event->param1_size, true); + if (rc < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue; log_error("read netlink fd (%d) failed: %s", fd, @@ -833,7 +838,8 @@ static int handle_e_set_attr_value(int fd, const struct iscsi_kern_event *event) offs += sprintf(&buf[offs], " "); while (1) { - if ((rc = nl_read(fd, &buf[offs], event->param2_size, true)) < 0) { + rc = nl_read(fd, &buf[offs], event->param2_size, true); + if (rc < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue; log_error("read netlink fd (%d) failed: %s", fd, diff --git a/iscsi-scst/usr/iscsi_adm.c b/iscsi-scst/usr/iscsi_adm.c index 645c118de..2812fc3b8 100644 --- a/iscsi-scst/usr/iscsi_adm.c +++ b/iscsi-scst/usr/iscsi_adm.c @@ -221,12 +221,14 @@ static int iscsid_request(struct iscsi_adm_req *req, void *rsp_data, { int fd, err; - if ((fd = iscsid_connect()) < 0) { + fd = iscsid_connect(); + if (fd < 0) { err = fd; goto out_close; } - if ((err = iscsid_request_send(fd, req)) < 0) + err = iscsid_request_send(fd, req); + if (err < 0) goto out_report; err = iscsid_response_recv(fd, req, rsp_data, rsp_data_sz); @@ -283,11 +285,13 @@ static int parse_trgt_params(struct msg_trgt *msg, char *params) if (!*p) continue; - if (!(q = strchr(p, '='))) + q = strchr(p, '='); + if (!q) continue; *q++ = '\0'; - if (!((idx = params_index_by_name(p, target_keys)) < 0)) { + idx = params_index_by_name(p, target_keys); + if (idx >= 0) { if (params_str_to_val(target_keys, idx, q, &val)) { fprintf(stderr, "Invalid %s value \"%s\".\n", @@ -302,7 +306,8 @@ static int parse_trgt_params(struct msg_trgt *msg, char *params) continue; } - if (!((idx = params_index_by_name(p, session_keys)) < 0)) { + idx = params_index_by_name(p, session_keys); + if (idx >= 0) { if (params_str_to_val(session_keys, idx, q, &val)) { fprintf(stderr, "Invalid %s value \"%s\".\n", @@ -418,7 +423,8 @@ static int parse_user_params(char *params, u32 *auth_dir, char **user, if (!*p) continue; - if (!(q = strchr(p, '='))) + q = strchr(p, '='); + if (!q) continue; *q++ = '\0'; if (isspace(*q)) diff --git a/iscsi-scst/usr/iscsi_scstd.c b/iscsi-scst/usr/iscsi_scstd.c index 54128470f..a1154f236 100644 --- a/iscsi-scst/usr/iscsi_scstd.c +++ b/iscsi-scst/usr/iscsi_scstd.c @@ -441,7 +441,8 @@ static void accept_connection(int listen) char target_portal[ISCSI_PORTAL_LEN], target_portal_port[NI_MAXSERV]; namesize = sizeof(from); - if ((fd = accept(listen, &from.sa, &namesize)) < 0) { + fd = accept(listen, &from.sa, &namesize); + if (fd < 0) { switch (errno) { case EINTR: case EAGAIN: @@ -952,12 +953,14 @@ int main(int argc, char **argv) } } - if ((ctrl_fd = kernel_open()) < 0) + ctrl_fd = kernel_open(); + if (ctrl_fd < 0) exit(-1); init_max_params(); - if ((nl_fd = nl_open()) < 0) { + nl_fd = nl_open(); + if (nl_fd < 0) { perror("netlink open failed"); exit(-1); } @@ -982,7 +985,8 @@ int main(int argc, char **argv) if (err != 0) exit(err); - if ((ipc_fd = iscsi_adm_request_listen()) < 0) { + ipc_fd = iscsi_adm_request_listen(); + if (ipc_fd < 0) { perror("Opening AF_LOCAL socket failed"); exit(-1); } diff --git a/iscsi-scst/usr/iscsid.c b/iscsi-scst/usr/iscsid.c index edea333f2..18f037ab3 100644 --- a/iscsi-scst/usr/iscsid.c +++ b/iscsi-scst/usr/iscsid.c @@ -85,7 +85,8 @@ static char *next_key(char **data, int *datasize, char **value) char *key, *p, *q; int size = *datasize; - key = p = *data; + p = *data; + key = p; for (; size > 0 && *p != '='; p++, size--) ; if (!size) diff --git a/iscsi-scst/usr/isns.c b/iscsi-scst/usr/isns.c index f1fea4523..c4b3fd4cf 100644 --- a/iscsi-scst/usr/isns.c +++ b/iscsi-scst/usr/isns.c @@ -117,7 +117,8 @@ static int isns_get_ip(int fd) case AF_INET: addr = lss.sin.sin_addr.s_addr; - ip[10] = ip[11] = 0xff; + ip[11] = 0xff; + ip[10] = 0xff; ip[15] = 0xff & (addr >> 24); ip[14] = 0xff & (addr >> 16); ip[13] = 0xff & (addr >> 8); diff --git a/iscsi-scst/usr/message.c b/iscsi-scst/usr/message.c index 341fbbf08..23a45481b 100644 --- a/iscsi-scst/usr/message.c +++ b/iscsi-scst/usr/message.c @@ -40,12 +40,14 @@ int iscsi_adm_request_listen(void) memcpy((char *) &addr.sun_path + 1, ISCSI_ADM_NAMESPACE, strlen(ISCSI_ADM_NAMESPACE)); - if ((err = bind(fd, (struct sockaddr *) &addr, sizeof(addr))) < 0) { + err = bind(fd, (struct sockaddr *) &addr, sizeof(addr)); + if (err < 0) { close(fd); return err; } - if ((err = listen(fd, 32)) < 0) { + err = listen(fd, 32); + if (err < 0) { close(fd); return err; } @@ -161,7 +163,8 @@ int iscsi_adm_request_handle(int accept_fd) memset(&rsp, 0, sizeof(rsp)); len = sizeof(addr); - if ((fd = accept(accept_fd, (struct sockaddr *) &addr, &len)) < 0) { + fd = accept(accept_fd, (struct sockaddr *) &addr, &len); + if (fd < 0) { if (errno == EINTR) err = -EINTR; else @@ -171,7 +174,8 @@ int iscsi_adm_request_handle(int accept_fd) } len = sizeof(cred); - if ((err = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, (void *) &cred, &len)) < 0) { + err = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, (void *) &cred, &len); + if (err < 0) { rsp.err = -EPERM; goto send; } @@ -181,7 +185,8 @@ int iscsi_adm_request_handle(int accept_fd) goto send; } - if ((err = read(fd, &req, sizeof(req))) != sizeof(req)) { + err = read(fd, &req, sizeof(req)); + if (err != sizeof(req)) { if (err >= 0) err = -EIO; goto out; diff --git a/iscsi-scst/usr/misc.c b/iscsi-scst/usr/misc.c index 24643ab2a..c4ee3bba6 100644 --- a/iscsi-scst/usr/misc.c +++ b/iscsi-scst/usr/misc.c @@ -84,7 +84,8 @@ int create_and_open_dev(const char *dev, int readonly) else flags = O_RDWR; - err = ctlfd = open(devname, flags); + ctlfd = open(devname, flags); + err = ctlfd; if (ctlfd < 0) { err = -errno; printf("cannot open %s %s\n", devname, strerror(errno)); diff --git a/iscsi-scst/usr/param.c b/iscsi-scst/usr/param.c index 23fe8725c..7c5d28877 100644 --- a/iscsi-scst/usr/param.c +++ b/iscsi-scst/usr/param.c @@ -226,7 +226,8 @@ static int digest_str_to_val(const char *str, unsigned int *val) break; } - if ((q = strchr(p, ','))) + q = strchr(p, ','); + if (q) p = q + 1; } while (q); diff --git a/iscsi-scst/usr/session.c b/iscsi-scst/usr/session.c index efe1bf1d7..2d82c0400 100644 --- a/iscsi-scst/usr/session.c +++ b/iscsi-scst/usr/session.c @@ -38,7 +38,8 @@ static int session_alloc(u32 tid, struct session **psess) goto out; } - if (!(session = malloc(sizeof(*session)))) { + session = malloc(sizeof(*session)); + if (!session) { res = -ENOMEM; goto out; } @@ -60,7 +61,8 @@ struct session *session_find_name(u32 tid, const char *iname, union iscsi_sid si struct session *session; struct target *target; - if (!(target = target_find_by_id(tid))) { + target = target_find_by_id(tid); + if (!target) { log_error("Target tid %d not found", tid); return NULL; } @@ -81,7 +83,8 @@ struct session *session_find_id(u32 tid, u64 sid) struct session *session; struct target *target; - if (!(target = target_find_by_id(tid))) + target = target_find_by_id(tid); + if (!target) return NULL; log_debug(1, "Searching for sid %#" PRIx64, sid); @@ -99,7 +102,8 @@ static bool session_id_exists(u32 tid, u64 sid, struct session *exclude) struct session *session; struct target *target; - if (!(target = target_find_by_id(tid))) + target = target_find_by_id(tid); + if (!target) return false; log_debug(1, "Searching for sid %#" PRIx64, sid); diff --git a/iscsi-scst/usr/target.c b/iscsi-scst/usr/target.c index 71c9c9581..21e627890 100644 --- a/iscsi-scst/usr/target.c +++ b/iscsi-scst/usr/target.c @@ -491,7 +491,8 @@ bool target_redirected(struct target *target, struct connection *conn) goto out; } - if ((p = strrchr(tmp, '%'))) + p = strrchr(tmp, '%'); + if (p) *p = '\0'; if (sa.sa.sa_family == AF_INET6) diff --git a/scst/include/backport.h b/scst/include/backport.h index 7b77f4cc0..991be62c4 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -2266,7 +2266,8 @@ static inline void scsi_req_init(struct request *rq) rq->cmd_type = REQ_TYPE_BLOCK_PC; rq->__data_len = 0; rq->__sector = (sector_t) -1; - rq->bio = rq->biotail = NULL; + rq->biotail = NULL; + rq->bio = NULL; memset(rq->__cmd, 0, sizeof(rq->__cmd)); rq->cmd = rq->__cmd; #else diff --git a/scst/src/dev_handlers/scst_vdisk_main.c b/scst/src/dev_handlers/scst_vdisk_main.c index 8ffb2e9ea..387537715 100644 --- a/scst/src/dev_handlers/scst_vdisk_main.c +++ b/scst/src/dev_handlers/scst_vdisk_main.c @@ -5901,9 +5901,10 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua) vdisk_bio_set_hoq(bio); if (!hbio) - hbio = tbio = bio; + hbio = bio; else - tbio = tbio->bi_next = bio; + tbio->bi_next = bio; + tbio = bio; } bytes = min_t(unsigned int, len, PAGE_SIZE - off); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 108b21143..6d15b0055 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -16123,9 +16123,11 @@ static void __scst_update_latency_stats(struct scst_cmd *cmd, stat->maxc = deltac; #endif } else { - stat->min = stat->max = delta; + stat->max = delta; + stat->min = delta; #ifdef SCST_MEASURE_CLOCK_CYCLES - stat->minc = stat->maxc = deltac; + stat->maxc = deltac; + stat->minc = deltac; #endif } stat->sum += delta;