summaryrefslogtreecommitdiff
path: root/usr/iscsiadm.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/iscsiadm.c')
-rw-r--r--usr/iscsiadm.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 39583dd..2ce1cf5 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -524,10 +524,9 @@ login_by_startup(char *mode)
*/
struct iface_rec *pattern_iface, *tmp_iface;
struct node_rec *rec, *tmp_rec;
- struct list_head iface_list;
+ LIST_HEAD(iface_list);
int missed_leading_login = 0;
log_debug(1, "Logging into leading-login portals");
- INIT_LIST_HEAD(&iface_list);
iface_link_ifaces(&iface_list);
list_for_each_entry_safe(pattern_iface, tmp_iface, &iface_list,
list) {
@@ -657,10 +656,9 @@ static int for_each_matched_rec(struct node_rec *rec, void *data,
static int login_portals(struct node_rec *pattern_rec)
{
- struct list_head rec_list;
+ LIST_HEAD(rec_list);
int nr_found, rc, err;
- INIT_LIST_HEAD(&rec_list);
err = for_each_matched_rec(pattern_rec, &rec_list, link_recs);
if (err == ISCSI_ERR_NO_OBJS_FOUND)
return err;
@@ -974,7 +972,7 @@ static int add_static_rec(int *found, char *targetname, int tpgt,
if (rc) {
log_error("Could not read iface %s. Error %d",
iface->name, rc);
- return rc;
+ goto free_drec;
}
iface_copy(&rec->iface, iface);
@@ -987,6 +985,7 @@ static int add_static_rec(int *found, char *targetname, int tpgt,
rec->iface.transport_name, iface_str(&rec->iface),
ip, port, tpgt, targetname);
}
+free_drec:
free(drec);
free_rec:
free(rec);
@@ -1171,11 +1170,10 @@ static int
do_software_sendtargets(discovery_rec_t *drec, struct list_head *ifaces,
int info_level, int do_login, int op, int sync_drec)
{
- struct list_head rec_list;
+ LIST_HEAD(rec_list);
struct node_rec *rec, *tmp;
int rc;
- INIT_LIST_HEAD(&rec_list);
/*
* compat: if the user did not pass any op then we do all
* ops for them
@@ -1221,11 +1219,10 @@ do_software_sendtargets(discovery_rec_t *drec, struct list_head *ifaces,
static int do_isns(discovery_rec_t *drec, struct list_head *ifaces,
int info_level, int do_login, int op)
{
- struct list_head rec_list;
+ LIST_HEAD(rec_list);
struct node_rec *rec, *tmp;
int rc;
- INIT_LIST_HEAD(&rec_list);
/*
* compat: if the user did not pass any op then we do all
* ops for them
@@ -1663,7 +1660,7 @@ static int set_host_chap_info(uint32_t host_no, uint64_t chap_index,
rc = ISCSI_ERR;
}
- goto exit_set_chap;
+ goto free_iovec;
}
ipc->ctldev_close();
@@ -2883,14 +2880,13 @@ out:
static int exec_fw_disc_op(discovery_rec_t *drec, struct list_head *ifaces,
int info_level, int do_login, int op)
{
- struct list_head targets, rec_list, new_ifaces;
+ LIST_HEAD(targets);
+ LIST_HEAD(rec_list);
+ LIST_HEAD(new_ifaces);
struct iface_rec *iface, *tmp_iface;
struct node_rec *rec, *tmp_rec;
int rc = 0;
- INIT_LIST_HEAD(&targets);
- INIT_LIST_HEAD(&rec_list);
- INIT_LIST_HEAD(&new_ifaces);
/*
* compat: if the user did not pass any op then we do all
* ops for them
@@ -2971,13 +2967,11 @@ static int exec_fw_op(discovery_rec_t *drec, struct list_head *ifaces,
int info_level, int do_login, int op)
{
struct boot_context *context;
- struct list_head targets, rec_list;
+ LIST_HEAD(targets);
+ LIST_HEAD(rec_list);
struct node_rec *rec;
int rc = 0;
- INIT_LIST_HEAD(&targets);
- INIT_LIST_HEAD(&rec_list);
-
if (drec)
return exec_fw_disc_op(drec, ifaces, info_level, do_login, op);
@@ -3531,13 +3525,13 @@ main(int argc, char **argv)
int timeout = ISCSID_REQ_TIMEOUT;
struct sigaction sa_old;
struct sigaction sa_new;
- struct list_head ifaces;
+ LIST_HEAD(ifaces);
struct iface_rec *iface = NULL, *tmp;
struct node_rec *rec = NULL;
uint64_t host_no = (uint64_t)MAX_HOST_NO + 1;
uint64_t index = ULLONG_MAX;
struct user_param *param;
- struct list_head params;
+ LIST_HEAD(params);
struct iscsi_context *ctx = NULL;
int librc = LIBISCSI_OK;
struct iscsi_session **ses = NULL;
@@ -3550,8 +3544,6 @@ main(int argc, char **argv)
goto out;
}
- INIT_LIST_HEAD(&params);
- INIT_LIST_HEAD(&ifaces);
/* do not allow ctrl-c for now... */
memset(&sa_old, 0, sizeof(struct sigaction));
memset(&sa_new, 0, sizeof(struct sigaction));