diff options
author | Lee Duncan <lduncan@suse.com> | 2018-09-24 16:30:34 -0700 |
---|---|---|
committer | Lee Duncan <lduncan@suse.com> | 2018-09-26 10:53:45 -0700 |
commit | 7df5edbb427c79337bdd651c2bcdda8eb05f077b (patch) | |
tree | d2205dd849d0b554e9a9c03533d6c82332310bf8 | |
parent | d8298fc54eb69d3989878be46e9c7d6ec2055650 (diff) | |
download | open-iscsi-7df5edbb427c79337bdd651c2bcdda8eb05f077b.tar.gz |
Fix incorrect sysfs logic for port and ip address.
If "port" is available and "persistent_port" is not, then
correctly use the one that is present for both values.
Likewise for "address" and "persistent_address".
-rw-r--r-- | libopeniscsiusr/session.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c index f8c89c3..98601dc 100644 --- a/libopeniscsiusr/session.c +++ b/libopeniscsiusr/session.c @@ -208,22 +208,20 @@ int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid, _sysfs_prop_get_i32(ctx, sysfs_con_dir_path, "port", &((*se)->port), -1, true); - if ((strcmp((*se)->address, "") == 0) && - (strcmp((*se)->persistent_address, "") != 0)) - _strncpy((*se)->persistent_address, (*se)->address, - sizeof((*se)->persistent_address) / sizeof(char)); - if ((strcmp((*se)->address, "") != 0) && (strcmp((*se)->persistent_address, "") == 0)) + _strncpy((*se)->persistent_address, (*se)->address, + sizeof((*se)->persistent_address) / sizeof(char)); + else if ((strcmp((*se)->address, "") == 0) && + (strcmp((*se)->persistent_address, "") != 0)) _strncpy((*se)->address, (*se)->persistent_address, sizeof((*se)->address) / sizeof(char)); - if (((*se)->persistent_port != -1) && - ((*se)->port == -1)) + if (((*se)->persistent_port == -1) && + ((*se)->port != -1)) (*se)->persistent_port = (*se)->port; - - if (((*se)->persistent_port != -1) && - ((*se)->port == -1)) + else if (((*se)->persistent_port != -1) && + ((*se)->port == -1)) (*se)->port = (*se)->persistent_port; _good(_iscsi_host_id_of_session(ctx, sid, &host_id), rc, out); |