diff options
author | Lee Duncan <lduncan@suse.com> | 2022-01-27 09:36:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 09:36:47 -0800 |
commit | 73c77266476bde54b186330c7774c25fee2335ad (patch) | |
tree | dd3e52409489a4596cdf18737930dcc0ccfe34e2 | |
parent | 66bb7ab93ac4bc9749b20b8f4e6d3e1b82983383 (diff) | |
parent | 1cab1efc813f750f9fa68e35dc16e8e54a1ba1e8 (diff) | |
download | open-iscsi-73c77266476bde54b186330c7774c25fee2335ad.tar.gz |
Merge pull request #297 from gonzoleeman/gcc12-fixes
Fix issues discovered by gcc12
-rw-r--r-- | usr/auth.c | 3 | ||||
-rw-r--r-- | usr/discovery.c | 2 | ||||
-rw-r--r-- | usr/iscsi_sysfs.c | 4 | ||||
-rw-r--r-- | usr/login.c | 18 |
4 files changed, 13 insertions, 14 deletions
@@ -109,7 +109,7 @@ acl_chap_auth_request(struct iscsi_acl *client, char *username, unsigned int id, unsigned char verify_data[client->chap_challenge_len]; /* the expected credentials are in the session */ - if (session->username_in == NULL) { + if (session->username_in[0] == '\0') { log_error("failing authentication, no incoming username " "configured to authenticate target %s", session->target_name); @@ -122,7 +122,6 @@ acl_chap_auth_request(struct iscsi_acl *client, char *username, unsigned int id, } if ((session->password_in_length < 1) || - (session->password_in == NULL) || (session->password_in[0] == '\0')) { log_error("failing authentication, no incoming password " "configured to authenticate target %s", diff --git a/usr/discovery.c b/usr/discovery.c index 7dec696..587af6d 100644 --- a/usr/discovery.c +++ b/usr/discovery.c @@ -623,7 +623,7 @@ add_target_record(char *name, char *end, discovery_rec_t *drec, /* if no address is provided, use the default */ if (text >= end) { - if (drec->address == NULL) { + if (drec->address[0] == '\0') { log_error("no default address known for target %s", name); return 0; diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c index 7bb834a..9a591be 100644 --- a/usr/iscsi_sysfs.c +++ b/usr/iscsi_sysfs.c @@ -1416,8 +1416,8 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct session_info *info, char *session) log_debug(7, "found targetname %s address %s pers address %s port %d " "pers port %d driver %s iface name %s ipaddress %s " "netdev %s hwaddress %s iname %s", - info->targetname, info->address ? info->address : "NA", - info->persistent_address ? info->persistent_address : "NA", + info->targetname, info->address[0] ? info->address : "NA", + info->persistent_address[0] ? info->persistent_address : "NA", info->port, info->persistent_port, info->iface.transport_name, info->iface.name, info->iface.ipaddress, info->iface.netdev, info->iface.hwaddress, diff --git a/usr/login.c b/usr/login.c index 8af8756..096deda 100644 --- a/usr/login.c +++ b/usr/login.c @@ -657,7 +657,7 @@ iscsi_process_login_response(iscsi_session_t *session, int cid, struct iscsi_acl *auth_client; iscsi_conn_t *conn = &session->conn[cid]; - auth_client = (session->auth_buffers && session->num_auth_buffers) ? + auth_client = (session->num_auth_buffers > 0) ? (struct iscsi_acl *)session->auth_buffers[0].address : NULL; end = text + ntoh24(login_rsp->dlength) + 1; @@ -1135,7 +1135,7 @@ iscsi_make_login_pdu(iscsi_session_t *session, int cid, struct iscsi_hdr *hdr, struct iscsi_acl *auth_client; iscsi_conn_t *conn = &session->conn[cid]; - auth_client = (session->auth_buffers && session->num_auth_buffers) ? + auth_client = (session->num_auth_buffers > 0) ? (struct iscsi_acl *)session->auth_buffers[0].address : NULL; /* initialize the PDU header */ @@ -1170,7 +1170,7 @@ iscsi_make_login_pdu(iscsi_session_t *session, int cid, struct iscsi_hdr *hdr, return 0; } - if ((session->target_name && session->target_name[0]) && + if ((session->target_name[0] != '\0') && (session->type == ISCSI_SESSION_TYPE_NORMAL)) { if (!iscsi_add_text(hdr, data, max_data_length, "TargetName", session->target_name)) @@ -1248,16 +1248,16 @@ check_for_authentication(iscsi_session_t *session, return LOGIN_FAILED; } - if (session->username && + if ((session->username[0] != '\0') && (acl_set_user_name(auth_client, session->username) != - AUTH_STATUS_NO_ERROR)) { + AUTH_STATUS_NO_ERROR)) { log_error("Couldn't set username"); goto end; } - if (session->password && (acl_set_passwd(auth_client, - session->password, session->password_length) != - AUTH_STATUS_NO_ERROR)) { + if ((session->password[0] != '\0') && + (acl_set_passwd(auth_client, session->password, session->password_length) != + AUTH_STATUS_NO_ERROR)) { log_error("Couldn't set password"); goto end; } @@ -1366,7 +1366,7 @@ iscsi_login_begin(iscsi_session_t *session, iscsi_login_context_t *c) conn->current_stage = ISCSI_INITIAL_LOGIN_STAGE; conn->partial_response = 0; - if (session->auth_buffers && session->num_auth_buffers) { + if (session->num_auth_buffers > 0) { c->ret = check_for_authentication(session, c->auth_client); if (c->ret != LOGIN_OK) return 1; |