summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Duncan <lduncan@suse.com>2020-01-28 15:19:29 -0800
committerLee Duncan <lduncan@suse.com>2020-01-28 15:50:16 -0800
commitc1270a591ce1ae162a2d58fb7fdbe9ef1b195c19 (patch)
tree47c3028e3029489476bf34dfeaee480e331e828d
parente9c9117b7a84866366691110496984fc651e3e43 (diff)
downloadopen-iscsi-c1270a591ce1ae162a2d58fb7fdbe9ef1b195c19.tar.gz
Enabled compiler checking options, fixed issues.
Enabled -Wextra and -Werror, then fixed all the issues found. *Should* be no functional change.
-rw-r--r--usr/Makefile2
-rw-r--r--usr/actor.c2
-rw-r--r--usr/discovery.c33
-rw-r--r--usr/discoveryd.c21
-rw-r--r--usr/flashnode.c18
-rw-r--r--usr/host.c6
-rw-r--r--usr/host.h2
-rw-r--r--usr/idbm.c12
-rw-r--r--usr/iface.c6
-rw-r--r--usr/initiator.c12
-rw-r--r--usr/initiator.h2
-rw-r--r--usr/initiator_common.c2
-rw-r--r--usr/io.c20
-rw-r--r--usr/iscsi_sysfs.c10
-rw-r--r--usr/iscsiadm.c64
-rw-r--r--usr/iscsid.c3
-rw-r--r--usr/iscsid_req.c9
-rw-r--r--usr/iscsistart.c5
-rw-r--r--usr/log.c14
-rw-r--r--usr/login.c6
-rw-r--r--usr/mgmt_ipc.c22
-rw-r--r--usr/netlink.c8
-rw-r--r--usr/uip_mgmt_ipc.c6
23 files changed, 177 insertions, 108 deletions
diff --git a/usr/Makefile b/usr/Makefile
index 3bb0cb4..7ab1b0b 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -35,7 +35,7 @@ endif
PKG_CONFIG = /usr/bin/pkg-config
CFLAGS ?= -O2 -g
-WARNFLAGS ?= -Wall -Wstrict-prototypes
+WARNFLAGS ?= -Wall -Wextra -Werror -Wstrict-prototypes
CFLAGS += $(WARNFLAGS) -I../include -I. -D_GNU_SOURCE \
-I$(TOPDIR)/libopeniscsiusr
CFLAGS += $(shell $(PKG_CONFIG) --cflags libkmod)
diff --git a/usr/actor.c b/usr/actor.c
index 91a9506..1a0a5ff 100644
--- a/usr/actor.c
+++ b/usr/actor.c
@@ -31,7 +31,7 @@ static LIST_HEAD(ready_list);
static volatile int poll_in_progress;
static uint64_t
-actor_time_left(actor_t *thread, uint64_t current_time)
+actor_time_left(actor_t *thread, time_t current_time)
{
if (current_time > thread->ttschedule)
return 0;
diff --git a/usr/discovery.c b/usr/discovery.c
index 199c160..9ce122e 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -136,7 +136,7 @@ int discovery_isns_query(struct discovery_rec *drec, const char *iname,
isns_simple_t *qry;
isns_client_t *clnt;
uint32_t status;
- int rc, i;
+ int rc;
isns_config.ic_security = 0;
source = isns_source_create_iscsi(iname);
@@ -198,7 +198,7 @@ int discovery_isns_query(struct discovery_rec *drec, const char *iname,
goto free_query;
}
- for (i = 0; i < objects.iol_count; ++i) {
+ for (unsigned int i = 0; i < objects.iol_count; ++i) {
isns_object_t *obj = objects.iol_data[i];
const char *pg_tgt = NULL;
struct in6_addr in_addr;
@@ -378,7 +378,8 @@ retry:
return rc;
}
-int discovery_fw(void *data, struct iface_rec *iface,
+int discovery_fw(void *data,
+ __attribute__((unused))struct iface_rec *iface,
struct list_head *rec_list)
{
struct discovery_rec *drec = data;
@@ -466,8 +467,10 @@ int discovery_offload_sendtargets(int host_no, int do_login,
}
static int
-iscsi_make_text_pdu(iscsi_session_t *session, struct iscsi_hdr *hdr,
- char *data, int max_data_length)
+iscsi_make_text_pdu(iscsi_session_t *session,
+ struct iscsi_hdr *hdr,
+ __attribute__((unused))char *data,
+ __attribute__((unused))int max_data_length)
{
struct iscsi_text *text_pdu = (struct iscsi_text *)hdr;
@@ -866,7 +869,7 @@ iscsi_alloc_session(struct iscsi_sendtargets_config *config,
session->initiator_alias = initiator_alias;
session->portal_group_tag = PORTAL_GROUP_TAG_UNKNOWN;
session->type = ISCSI_SESSION_TYPE_DISCOVERY;
- session->id = -1;
+ session->id = INVALID_SESSION_ID;
/* setup authentication variables for the session*/
*rc = iscsi_setup_authentication(session, &config->auth);
@@ -1021,7 +1024,7 @@ static void iscsi_destroy_session(struct iscsi_session *session)
struct iscsi_conn *conn = &session->conn[0];
int rc;
- if (session->id == -1)
+ if (session->id == INVALID_SESSION_ID)
return;
if (!(t->caps & CAP_TEXT_NEGO)) {
@@ -1064,7 +1067,7 @@ done:
ipc->ctldev_close();
conn->socket_fd = -1;
}
- session->id = -1;
+ session->id = INVALID_SESSION_ID;
}
static int iscsi_create_leading_conn(struct iscsi_session *session)
@@ -1186,7 +1189,7 @@ static int iscsi_create_leading_conn(struct iscsi_session *session)
disconnect:
t->template->ep_disconnect(conn);
- if (session->id != -1 &&
+ if (session->id != INVALID_SESSION_ID &&
iscsi_sysfs_session_has_leadconn(session->id)) {
if (ipc->destroy_conn(session->t->handle, session->id,
conn->id))
@@ -1194,11 +1197,11 @@ disconnect:
session->id, conn->id);
}
- if (session->id != -1) {
+ if (session->id != INVALID_SESSION_ID) {
if (ipc->destroy_session(session->t->handle, session->id))
log_error("Could not safely destroy session %d",
session->id);
- session->id = -1;
+ session->id = INVALID_SESSION_ID;
}
close_ipc:
@@ -1213,7 +1216,8 @@ close_ipc:
}
static struct iscsi_ev_context *
-iscsi_ev_context_get(struct iscsi_conn *conn, int ev_size)
+iscsi_ev_context_get(__attribute__((unused))struct iscsi_conn *conn,
+ int ev_size)
{
log_debug(2, "%s: ev_size %d", __FUNCTION__, ev_size);
@@ -1232,7 +1236,8 @@ static void iscsi_ev_context_put(struct iscsi_ev_context *ev_context)
}
static int iscsi_sched_ev_context(struct iscsi_ev_context *ev_context,
- struct iscsi_conn *conn, unsigned long tmo,
+ struct iscsi_conn *conn,
+ __attribute__((unused))unsigned long tmo,
int event)
{
if (event == EV_CONN_RECV_PDU || event == EV_CONN_LOGIN) {
@@ -1688,7 +1693,7 @@ repoll:
rc = process_recvd_pdu(pdu, drec, rec_list,
session, &sendtargets,
&active, &valid_text, data);
- if (rc == DISCOVERY_NEED_RECONNECT)
+ if (rc == (int)DISCOVERY_NEED_RECONNECT)
goto reconnect;
/* reset timers after receiving a PDU */
diff --git a/usr/discoveryd.c b/usr/discoveryd.c
index 1955ce9..39d3691 100644
--- a/usr/discoveryd.c
+++ b/usr/discoveryd.c
@@ -387,7 +387,7 @@ free_ifaces:
return rc;
}
-static void isns_reg_refresh_with_disc(void *data)
+static void isns_reg_refresh_with_disc(__attribute__((unused))void *data)
{
int retries = 0, rc;
@@ -551,7 +551,7 @@ static int isns_setup_registration_refresh(isns_simple_t *rsp, int poll_inval)
{
isns_object_list_t objs = ISNS_OBJECT_LIST_INIT;
struct isns_refresh_data *refresh_data;
- int status, i, rc = 0;
+ int status, rc = 0;
uint32_t interval = 0;
status = isns_query_response_get_objects(rsp, &objs);
@@ -562,7 +562,7 @@ static int isns_setup_registration_refresh(isns_simple_t *rsp, int poll_inval)
return ISCSI_ERR;
}
- for (i = 0; i < objs.iol_count; ++i) {
+ for (unsigned int i = 0; i < objs.iol_count; ++i) {
isns_object_t *obj = objs.iol_data[i];
if (!isns_object_is_entity(obj))
@@ -605,7 +605,7 @@ static int isns_setup_registration_refresh(isns_simple_t *rsp, int poll_inval)
if (poll_inval > 0) {
/* user wants to override server and do disc */
- if (isns_refresh_interval > poll_inval)
+ if ((int)isns_refresh_interval > poll_inval)
isns_refresh_interval = poll_inval;
isns_add_timer(isns_refresh_interval,
isns_reg_refresh_with_disc,
@@ -831,9 +831,11 @@ done:
return rc;
}
-static void isns_scn_callback(isns_db_t *db, uint32_t bitmap,
- isns_object_template_t *node_type,
- const char *node_name, const char *dst_name)
+static void isns_scn_callback(__attribute__((unused))isns_db_t *db,
+ uint32_t bitmap,
+ __attribute__((unused))isns_object_template_t *node_type,
+ const char *node_name,
+ const char *dst_name)
{
log_error("SCN for initiator: %s (Target: %s, Event: %s.)",
dst_name, node_name, isns_event_string(bitmap));
@@ -1052,7 +1054,7 @@ free_ifaces:
}
}
-static void do_st_disc_and_login(const char *def_iname,
+static void do_st_disc_and_login(__attribute__((unused))const char *def_iname,
struct discovery_rec *drec, int poll_inval)
{
if (poll_inval < 0)
@@ -1067,7 +1069,8 @@ static void do_st_disc_and_login(const char *def_iname,
discoveryd_stop();
}
-static int st_start(void *data, struct discovery_rec *drec)
+static int st_start(__attribute__((unused))void *data,
+ struct discovery_rec *drec)
{
log_debug(1, "st_start %s:%d %d", drec->address, drec->port,
drec->u.sendtargets.use_discoveryd);
diff --git a/usr/flashnode.c b/usr/flashnode.c
index fe5ab57..fd01cd4 100644
--- a/usr/flashnode.c
+++ b/usr/flashnode.c
@@ -48,8 +48,10 @@ char *to_key(const char *fmt)
return key;
}
-int flashnode_info_print_flat(void *data, struct flashnode_rec *fnode,
- uint32_t host_no, uint32_t flashnode_idx)
+int flashnode_info_print_flat(__attribute__((unused))void *data,
+ struct flashnode_rec *fnode,
+ __attribute__((unused))uint32_t host_no,
+ uint32_t flashnode_idx)
{
printf("%s: [%d] ", fnode->transport_name, flashnode_idx);
if (!strlen((char *)fnode->conn[0].ipaddress))
@@ -207,7 +209,8 @@ static int flashnode_fill_ipaddr(struct flashnode_rec *fnode, struct iovec *iov,
return rc;
}
-static int flashnode_fill_uint8(struct flashnode_rec *fnode, struct iovec *iov,
+static int flashnode_fill_uint8(__attribute__((unused))struct flashnode_rec *fnode,
+ struct iovec *iov,
int param_type, uint8_t val)
{
struct iscsi_flashnode_param_info *fnode_param;
@@ -229,7 +232,8 @@ static int flashnode_fill_uint8(struct flashnode_rec *fnode, struct iovec *iov,
return 0;
}
-static int flashnode_fill_uint16(struct flashnode_rec *fnode, struct iovec *iov,
+static int flashnode_fill_uint16(__attribute__((unused))struct flashnode_rec *fnode,
+ struct iovec *iov,
int param_type, uint16_t val)
{
struct iscsi_flashnode_param_info *fnode_param;
@@ -251,7 +255,8 @@ static int flashnode_fill_uint16(struct flashnode_rec *fnode, struct iovec *iov,
return 0;
}
-static int flashnode_fill_uint32(struct flashnode_rec *fnode, struct iovec *iov,
+static int flashnode_fill_uint32(__attribute__((unused))struct flashnode_rec *fnode,
+ struct iovec *iov,
int param_type, uint32_t val)
{
struct iscsi_flashnode_param_info *fnode_param;
@@ -273,7 +278,8 @@ static int flashnode_fill_uint32(struct flashnode_rec *fnode, struct iovec *iov,
return 0;
}
-static int flashnode_fill_str(struct flashnode_rec *fnode, struct iovec *iov,
+static int flashnode_fill_str(__attribute__((unused))struct flashnode_rec *fnode,
+ struct iovec *iov,
int param_type, char *buf, int buflen)
{
struct iscsi_flashnode_param_info *fnode_param;
diff --git a/usr/host.c b/usr/host.c
index c94b6d1..a12577c 100644
--- a/usr/host.c
+++ b/usr/host.c
@@ -92,7 +92,8 @@ static void print_host_info(struct iface_rec *iface, char *prefix)
printf("%sNetdev: %s\n", prefix, UNKNOWN_VALUE);
}
-static int host_info_print_flat(void *data, struct host_info *hinfo)
+static int host_info_print_flat(__attribute__((unused))void *data,
+ struct host_info *hinfo)
{
struct iface_rec *iface = &hinfo->iface;
@@ -310,7 +311,8 @@ int host_info_print(int info_level, uint32_t host_no,
arg.flags = flags;
arg.ses = ses;
arg.se_count = se_count;
- if (host_no != -1) {
+ /* set host_no if not yet done */
+ if (host_no > MAX_HOST_NO) {
struct host_info hinfo;
memset(&hinfo, 0, sizeof(struct host_info));
diff --git a/usr/host.h b/usr/host.h
index f521fd2..88be442 100644
--- a/usr/host.h
+++ b/usr/host.h
@@ -7,7 +7,7 @@
#include "types.h"
#include "config.h"
-#define MAX_HOST_NO UINT_MAX
+#define MAX_HOST_NO UINT32_MAX
#define MAX_CHAP_ENTRIES 2048
#define MAX_CHAP_BUF_SZ 4096
diff --git a/usr/idbm.c b/usr/idbm.c
index e08301c..6309be0 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -169,10 +169,10 @@ static struct idbm *db;
#define __recinfo_int_list(_key,_info,_rec,_name,_show,_tbl,_n,_mod) do { \
_info[_n].type = TYPE_INT_LIST; \
strlcpy(_info[_n].name, _key, NAME_MAXVAL); \
- for(int _i = 0; _i < ARRAY_LEN(_rec->_name); _i++) { \
- if (_rec->_name[_i] != ~0) { \
- for (int _j = 0; _j < ARRAY_LEN(_tbl); _j++) { \
- if (_tbl[_j].value == _rec->_name[_i]) { \
+ for (unsigned long _i = 0; _i < ARRAY_LEN(_rec->_name); _i++) { \
+ if (_rec->_name[_i] != (unsigned)~0) { \
+ for (unsigned long _j = 0; _j < ARRAY_LEN(_tbl); _j++) { \
+ if (_tbl[_j].value == (int)_rec->_name[_i]) { \
strcat(_info[_n].value, _tbl[_j].name); \
strcat(_info[_n].value, ","); \
break; \
@@ -1072,6 +1072,8 @@ setup_passwd_len:
goto updated;
}
}
+ /* internal error if reached ?? */
+ break;
case TYPE_INT_LIST:
if (!info[i].data)
continue;
@@ -1351,7 +1353,7 @@ int idbm_print_flashnode_info(struct flashnode_rec *fnode)
return 0;
}
-int idbm_print_node_flat(void *data, node_rec_t *rec)
+int idbm_print_node_flat(__attribute__((unused))void *data, node_rec_t *rec)
{
if (strchr(rec->conn[0].address, '.'))
printf("%s:%d,%d %s\n", rec->conn[0].address, rec->conn[0].port,
diff --git a/usr/iface.c b/usr/iface.c
index 645b0b8..323f167 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -513,7 +513,8 @@ static int iface_setup_binding_from_kern_iface(void *data,
return 0;
}
-static int __iface_setup_host_bindings(void *data, struct host_info *hinfo)
+static int __iface_setup_host_bindings(__attribute__((unused))void *data,
+ struct host_info *hinfo)
{
struct iface_rec *def_iface;
struct iscsi_transport *t;
@@ -841,7 +842,8 @@ static int iface_print_nodes(void *data, node_rec_t *rec)
* have the binding info. When we store the iface specific node settings
* in the iface record then it will look different.
*/
-int iface_print_tree(void *data, struct iface_rec *iface)
+int iface_print_tree(__attribute__((unused))void *data,
+ struct iface_rec *iface)
{
struct node_rec last_rec;
struct iface_print_node_data print_data;
diff --git a/usr/initiator.c b/usr/initiator.c
index f4c9e02..a07f9aa 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -356,7 +356,7 @@ __session_create(node_rec_t *rec, struct iscsi_transport *t, int *rc)
INIT_LIST_HEAD(&session->list);
session->t = t;
session->reopen_qtask.mgmt_ipc_fd = -1;
- session->id = -1;
+ session->id = INVALID_SESSION_ID;
session->use_ipc = 1;
/* save node record. we might need it for redirection */
@@ -476,7 +476,7 @@ session_conn_shutdown(iscsi_conn_t *conn, queue_task_t *qtask,
if (session->t->template->ep_disconnect)
session->t->template->ep_disconnect(conn);
- if (session->id == -1)
+ if (session->id == INVALID_SESSION_ID)
goto cleanup;
if (!iscsi_sysfs_session_has_leadconn(session->id))
@@ -502,7 +502,7 @@ session_conn_shutdown(iscsi_conn_t *conn, queue_task_t *qtask,
}
cleanup:
- if (session->id != -1) {
+ if (session->id != INVALID_SESSION_ID) {
log_debug(2, "kdestroy session %u", session->id);
session->r_stage = R_STAGE_SESSION_DESTOYED;
if (ipc->destroy_session(session->t->handle, session->id)) {
@@ -1558,7 +1558,7 @@ static void session_conn_poll(void *data)
memset(c, 0, sizeof(iscsi_login_context_t));
/* do not allocate new connection in case of reopen */
- if (session->id == -1) {
+ if (session->id == INVALID_SESSION_ID) {
if (conn->id == 0 && session_ipc_create(session)) {
log_error("Can't create session.");
err = ISCSI_ERR_INTERNAL;
@@ -2137,7 +2137,9 @@ invalid_state:
}
int
-iscsi_host_send_targets(queue_task_t *qtask, int host_no, int do_login,
+iscsi_host_send_targets(__attribute__((unused))queue_task_t *qtask,
+ int host_no,
+ __attribute__((unused))int do_login,
struct sockaddr_storage *ss)
{
struct iscsi_transport *t;
diff --git a/usr/initiator.h b/usr/initiator.h
index 6a49ea6..dbf6f2b 100644
--- a/usr/initiator.h
+++ b/usr/initiator.h
@@ -266,6 +266,8 @@ typedef struct iscsi_session {
queue_task_t *notify_qtask;
} iscsi_session_t;
+#define INVALID_SESSION_ID (uint32_t)-1
+
/* login.c */
#define ISCSI_SESSION_TYPE_NORMAL 0
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
index 81da8fd..6cf26c1 100644
--- a/usr/initiator_common.c
+++ b/usr/initiator_common.c
@@ -53,7 +53,7 @@ struct iscsi_session *session_find_by_sid(uint32_t sid)
return NULL;
}
-const static unsigned int align_32_down(unsigned int param)
+static unsigned int align_32_down(unsigned int param)
{
return param & ~0x3;
}
diff --git a/usr/io.c b/usr/io.c
index e4d00ae..210a10a 100644
--- a/usr/io.c
+++ b/usr/io.c
@@ -58,7 +58,7 @@ do { \
static int timedout;
static void
-sigalarm_handler(int unused)
+sigalarm_handler(__attribute__((unused))int unused)
{
timedout = 1;
}
@@ -503,8 +503,12 @@ iscsi_log_text(struct iscsi_hdr *pdu, char *data)
}
int
-iscsi_io_send_pdu(iscsi_conn_t *conn, struct iscsi_hdr *hdr,
- int hdr_digest, char *data, int data_digest, int timeout)
+iscsi_io_send_pdu(iscsi_conn_t *conn,
+ struct iscsi_hdr *hdr,
+ __attribute__((unused))int hdr_digest,
+ char *data,
+ __attribute__((unused))int data_digest,
+ int timeout)
{
int rc, ret = 0;
char *header = (char *) hdr;
@@ -665,9 +669,13 @@ iscsi_io_send_pdu(iscsi_conn_t *conn, struct iscsi_hdr *hdr,
}
int
-iscsi_io_recv_pdu(iscsi_conn_t *conn, struct iscsi_hdr *hdr,
- int hdr_digest, char *data, int max_data_length, int data_digest,
- int timeout)
+iscsi_io_recv_pdu(iscsi_conn_t *conn,
+ struct iscsi_hdr *hdr,
+ __attribute__((unused))int hdr_digest,
+ char *data,
+ int max_data_length,
+ __attribute__((unused))int data_digest,
+ int timeout)
{
uint32_t h_bytes = 0;
uint32_t ahs_bytes = 0;
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 418f51b..435c576 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -1781,8 +1781,8 @@ struct iscsi_transport *iscsi_sysfs_get_transport_by_hba(uint32_t host_no)
char id[NAME_SIZE];
int rc;
- if (host_no == -1)
- return NULL;
+ if (host_no > MAX_HOST_NO)
+ return NULL; /* not set? */
snprintf(id, sizeof(id), ISCSI_HOST_ID, host_no);
rc = sysfs_get_str(id, SCSI_HOST_SUBSYS, "proc_name", name,
@@ -1914,7 +1914,8 @@ void iscsi_sysfs_set_queue_depth(void *data, int hostno, int target, int lun)
log_error("Could not queue depth for LUN %d err %d.", lun, err);
}
-void iscsi_sysfs_set_device_online(void *data, int hostno, int target, int lun)
+void iscsi_sysfs_set_device_online(__attribute__((unused))void *data,
+ int hostno, int target, int lun)
{
char *write_buf = "running\n";
char id[NAME_SIZE];
@@ -1930,7 +1931,8 @@ void iscsi_sysfs_set_device_online(void *data, int hostno, int target, int lun)
log_error("Could not online LUN %d err %d.", lun, err);
}
-void iscsi_sysfs_rescan_device(void *data, int hostno, int target, int lun)
+void iscsi_sysfs_rescan_device(__attribute__((unused))void *data,
+ int hostno, int target, int lun)
{
char *write_buf = "1";
char id[NAME_SIZE];
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 2ce1cf5..9bb7f49 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -787,7 +787,7 @@ static int print_nodes_config(struct iscsi_context *ctx, bool show_secret,
(strlen(address) != 0) &&
(strcmp(address, iscsi_node_conn_address_get(node)) != 0))
match = false;
- if ((port != -1) && (port != iscsi_node_conn_port_get(node)))
+ if ((port != -1) && (port != (int32_t)iscsi_node_conn_port_get(node)))
match = false;
if ((iface_name != NULL) &&
(strlen(iface_name) != 0) &&
@@ -931,7 +931,7 @@ session_stats(void *data, struct session_info *info)
if (rsp.u.getstats.stats.custom_length)
printf( "iSCSI Extended:\n");
- for (i = 0; i < rsp.u.getstats.stats.custom_length; i++) {
+ for (i = 0; i < (int)rsp.u.getstats.stats.custom_length; i++) {
printf("\t%s: %llu\n", rsp.u.getstats.stats.custom[i].desc,
(unsigned long long)rsp.u.getstats.stats.custom[i].value);
}
@@ -994,7 +994,8 @@ done:
}
static int add_static_portal(int *found, void *data, char *targetname,
- int tpgt, char *ip, int port, bool ruw_lock)
+ int tpgt, char *ip, int port,
+ __attribute__((unused))bool ruw_lock)
{
node_rec_t *rec = data;
@@ -1009,8 +1010,8 @@ static int add_static_portal(int *found, void *data, char *targetname,
&rec->iface);
}
-static int add_static_node(int *found, void *data,
- char *targetname, bool ruw_lock)
+static int add_static_node(int *found, void *data, char *targetname,
+ __attribute__((unused))bool ruw_lock)
{
node_rec_t *rec = data;
@@ -1066,7 +1067,8 @@ do_offload_sendtargets(discovery_rec_t *drec, int host_no, int do_login)
return discovery_offload_sendtargets(host_no, do_login, drec);
}
-static int delete_node(void *data, struct node_rec *rec)
+static int delete_node(__attribute__((unused))void *data,
+ struct node_rec *rec)
{
if (iscsi_check_for_running_session(rec)) {
/*
@@ -1343,7 +1345,7 @@ verify_mode_params(int argc, char **argv, char *allowed, int skip_m)
return ret;
}
-static void catch_sigint( int signo ) {
+static void catch_sigint(__attribute__((unused))int signo) {
log_warning("caught SIGINT, exiting...");
exit(1);
}
@@ -1401,7 +1403,7 @@ static int iface_apply_net_config(struct iface_rec *iface, int op)
}
host_no = iscsi_sysfs_get_host_no_from_hwinfo(iface, &rc);
- if (host_no == -1) {
+ if (host_no == 0) {
log_error("Can't find host_no.");
goto free_buf;
}
@@ -1442,7 +1444,7 @@ static int get_host_chap_info(uint32_t host_no)
uint32_t num_entries;
uint16_t chap_tbl_idx = 0;
int rc = 0;
- int fd, i = 0;
+ int fd;
t = iscsi_sysfs_get_transport_by_hba(host_no);
if (!t) {
@@ -1487,7 +1489,7 @@ get_chap:
(crec + (valid_chap_entries - 1))->chap_tbl_idx + 1;
/* print chap info */
- for (i = 0; i < valid_chap_entries; i++) {
+ for (uint32_t i = 0; i < valid_chap_entries; i++) {
idbm_print_host_chap_info(crec);
crec++;
}
@@ -1725,8 +1727,11 @@ exit_delete_chap:
return rc;
}
-static int exec_host_chap_op(int op, int info_level, uint32_t host_no,
- uint64_t chap_index, struct list_head *params)
+static int exec_host_chap_op(int op,
+ __attribute__((unused))int info_level,
+ uint32_t host_no,
+ uint64_t chap_index,
+ struct list_head *params)
{
int rc = ISCSI_ERR_INVAL;
@@ -1766,7 +1771,8 @@ static int get_flashnode_info(uint32_t host_no, uint32_t flashnode_idx)
return rc;
}
-static int list_flashnodes(int info_level, uint32_t host_no)
+static int list_flashnodes(__attribute__((unused))int info_level,
+ uint32_t host_no)
{
int rc = 0;
int num_found = 0;
@@ -2307,7 +2313,9 @@ static void print_host_stats(struct iscsi_offload_host_stats *host_stats)
(unsigned long long)host_stats->iscsi_sequence_error);
}
-static int exec_host_stats_op(int op, int info_level, uint32_t host_no)
+static int exec_host_stats_op(__attribute__((unused))int op,
+ __attribute__((unused))int info_level,
+ uint32_t host_no)
{
struct iscsi_transport *t = NULL;
char *req_buf = NULL;
@@ -2533,9 +2541,13 @@ static inline void list_splice_tail(struct list_head *list, struct list_head *he
}
/* TODO: merge iter helpers and clean them up, so we can use them here */
-static int exec_iface_op(struct iscsi_context *ctx, int op, int do_show,
- int info_level, struct iface_rec *iface,
- uint64_t host_no, struct list_head *params)
+static int exec_iface_op(struct iscsi_context *ctx,
+ int op,
+ __attribute__((unused))int do_show,
+ int info_level,
+ struct iface_rec *iface,
+ uint64_t host_no,
+ struct list_head *params)
{
struct host_info hinfo;
struct node_rec *rec = NULL;
@@ -3204,9 +3216,15 @@ done:
return rc;
}
-static int exec_disc_op(int disc_type, char *ip, int port,
- struct list_head *ifaces, int info_level, int do_login,
- int do_discover, int op, struct list_head *params,
+static int exec_disc_op(int disc_type,
+ char *ip,
+ int port,
+ struct list_head *ifaces,
+ int info_level,
+ int do_login,
+ int do_discover,
+ int op,
+ __attribute__((unused))struct list_head *params,
int do_show)
{
struct discovery_rec drec;
@@ -3383,7 +3401,7 @@ static char *iscsi_ping_stat_strs[] = {
static char *iscsi_ping_stat_to_str(uint32_t status)
{
- if (status < 0 || status > ISCSI_PING_NO_ARP_RECEIVED) {
+ if (status == 0 || status > ISCSI_PING_NO_ARP_RECEIVED) {
log_error("Invalid ping status %u", status);
return NULL;
}
@@ -3449,7 +3467,7 @@ static int exec_ping_op(struct iface_rec *iface, char *ip, int size, int count,
}
host_no = iscsi_sysfs_get_host_no_from_hwinfo(iface, &rc);
- if (host_no == -1) {
+ if (host_no == 0) {
log_error("Can't find host_no.");
rc = ISCSI_ERR_INVAL;
goto ping_exit;
@@ -3528,7 +3546,7 @@ main(int argc, char **argv)
LIST_HEAD(ifaces);
struct iface_rec *iface = NULL, *tmp;
struct node_rec *rec = NULL;
- uint64_t host_no = (uint64_t)MAX_HOST_NO + 1;
+ uint32_t host_no = MAX_HOST_NO + 1;
uint64_t index = ULLONG_MAX;
struct user_param *param;
LIST_HEAD(params);
diff --git a/usr/iscsid.c b/usr/iscsid.c
index 8f1c597..99d27ab 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -189,7 +189,8 @@ setup_rec_from_negotiated_values(node_rec_t *rec, struct session_info *info)
}
}
-static int sync_session(void *data, struct session_info *info)
+static int sync_session(__attribute__((unused))void *data,
+ struct session_info *info)
{
node_rec_t rec, sysfsrec;
iscsiadm_req_t req;
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
index d872eb7..4e5e3da 100644
--- a/usr/iscsid_req.c
+++ b/usr/iscsid_req.c
@@ -256,7 +256,8 @@ int uip_broadcast(void *buf, size_t buf_len, int fd_flags, uint32_t *status)
iscsid_uip_rsp_t rsp;
int flags;
int count;
-
+ size_t write_res;
+
err = uip_connect(&fd);
if (err) {
log_warning("uIP daemon is not up");
@@ -266,10 +267,10 @@ int uip_broadcast(void *buf, size_t buf_len, int fd_flags, uint32_t *status)
log_debug(3, "connected to uIP daemon");
/* Send the data to uIP */
- err = write(fd, buf, buf_len);
- if (err != buf_len) {
+ write_res = write(fd, buf, buf_len);
+ if (write_res != buf_len) {
log_error("got write error (%d/%d), daemon died?",
- err, errno);
+ (int)write_res, errno);
close(fd);
return ISCSI_ERR_ISCSID_COMM_ERR;
}
diff --git a/usr/iscsistart.c b/usr/iscsistart.c
index d3616ea..00a9c78 100644
--- a/usr/iscsistart.c
+++ b/usr/iscsistart.c
@@ -295,7 +295,10 @@ static int setup_session(void)
return rc;
}
-int session_in_use(int sid) { return 0; }
+int session_in_use(__attribute__((unused))int sid)
+{
+ return 0;
+}
static void catch_signal(int signo)
{
diff --git a/usr/log.c b/usr/log.c
index b730642..f29b54b 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -186,7 +186,7 @@ int log_enqueue (int prio, const char * fmt, va_list ap)
/* not enough space on tail : rewind */
if (la->head <= la->tail &&
- (len + sizeof(struct logmsg)) > (la->end - la->tail)) {
+ (long)(len + sizeof(struct logmsg)) > (la->end - la->tail)) {
logdbg(stderr, "enqueue: rewind tail to %p\n", la->tail);
la->tail = la->start;
@@ -196,7 +196,7 @@ int log_enqueue (int prio, const char * fmt, va_list ap)
/* not enough space on head : drop msg */
if (la->head > la->tail &&
- (len + sizeof(struct logmsg)) > (la->head - la->tail)) {
+ (long)(len + sizeof(struct logmsg)) > (la->head - la->tail)) {
logdbg(stderr, "enqueue: log area overrun, drop msg\n");
if (!la->empty)
@@ -262,7 +262,10 @@ static void log_syslog (void * buff)
syslog(msg->prio, "%s", (char *)&msg->str);
}
-void log_do_log_daemon(int prio, void *priv, const char *fmt, va_list ap)
+void log_do_log_daemon(int prio,
+ __attribute__((unused))void *priv,
+ const char *fmt,
+ va_list ap)
{
struct sembuf ops[1];
@@ -282,7 +285,10 @@ void log_do_log_daemon(int prio, void *priv, const char *fmt, va_list ap)
syslog(LOG_ERR, "semop up failed");
}
-void log_do_log_std(int prio, void *priv, const char *fmt, va_list ap)
+void log_do_log_std(int prio,
+ __attribute__((unused))void *priv,
+ const char *fmt,
+ va_list ap)
{
if (prio == LOG_INFO) {
vfprintf(stdout, fmt, ap);
diff --git a/usr/login.c b/usr/login.c
index 1251e61..2508c48 100644
--- a/usr/login.c
+++ b/usr/login.c
@@ -62,14 +62,14 @@ iscsi_add_text(struct iscsi_hdr *pdu, char *data, int max_data_length,
}
/* param */
- strncpy(text, param, param_len);
+ memcpy(text, param, param_len);
text += param_len;
/* separator */
*text++ = ISCSI_TEXT_SEPARATOR;
/* value */
- strncpy(text, value, value_len);
+ memcpy(text, value, value_len);
text += value_len;
/* NUL */
@@ -399,7 +399,7 @@ get_op_params_text_keys(iscsi_session_t *session, int cid,
* what the target gave us.
*/
if (!conn_rec->iscsi.MaxXmitDataSegmentLength ||
- tgt_max_xmit < conn->max_xmit_dlength)
+ tgt_max_xmit < (int)conn->max_xmit_dlength)
conn->max_xmit_dlength = tgt_max_xmit;
}
text = value_end;
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
index 1ffcda9..51267c1 100644
--- a/usr/mgmt_ipc.c
+++ b/usr/mgmt_ipc.c
@@ -84,7 +84,7 @@ int mgmt_ipc_systemd(void)
env = getenv("LISTEN_PID");
- if (!env || (strtoul(env, NULL, 10) != getpid()))
+ if (!env || ((pid_t)strtoul(env, NULL, 10) != getpid()))
return -EINVAL;
env = getenv("LISTEN_FDS");
@@ -211,7 +211,7 @@ mgmt_ipc_cfg_filename(queue_task_t *qtask)
}
static int
-mgmt_ipc_conn_add(queue_task_t *qtask)
+mgmt_ipc_conn_add(__attribute__((unused))queue_task_t *qtask)
{
return ISCSI_ERR;
}
@@ -224,7 +224,7 @@ mgmt_ipc_immediate_stop(queue_task_t *qtask)
}
static int
-mgmt_ipc_conn_remove(queue_task_t *qtask)
+mgmt_ipc_conn_remove(__attribute__((unused))queue_task_t *qtask)
{
return ISCSI_ERR;
}
@@ -300,25 +300,29 @@ mgmt_ipc_notify_common(queue_task_t *qtask, int (*handler)(int, char **))
/* Replace these dummies as you implement them
elsewhere */
static int
-iscsi_discovery_add_node(int argc, char **argv)
+iscsi_discovery_add_node(__attribute__((unused))int argc,
+ __attribute__((unused))char **argv)
{
return ISCSI_SUCCESS;
}
static int
-iscsi_discovery_del_node(int argc, char **argv)
+iscsi_discovery_del_node(__attribute__((unused))int argc,
+ __attribute__((unused))char **argv)
{
return ISCSI_SUCCESS;
}
static int
-iscsi_discovery_add_portal(int argc, char **argv)
+iscsi_discovery_add_portal(__attribute__((unused))int argc,
+ __attribute__((unused))char **argv)
{
return ISCSI_SUCCESS;
}
static int
-iscsi_discovery_del_portal(int argc, char **argv)
+iscsi_discovery_del_portal(__attribute__((unused))int argc,
+ __attribute__((unused))char **argv)
{
return ISCSI_SUCCESS;
}
@@ -509,8 +513,10 @@ void mgmt_ipc_handle(int accept_fd)
command = qtask->req.command;
qtask->rsp.command = command;
- if (0 <= command && command < __MGMT_IPC_MAX_COMMAND)
+ if (command > 0 &&
+ command < __MGMT_IPC_MAX_COMMAND)
handler = mgmt_ipc_functions[command];
+
if (handler != NULL) {
/* If the handler returns OK, this means it
* already sent the reply. */
diff --git a/usr/netlink.c b/usr/netlink.c
index f1aab52..662b621 100644
--- a/usr/netlink.c
+++ b/usr/netlink.c
@@ -581,7 +581,7 @@ ksend_pdu_begin(uint64_t transport_handle, uint32_t sid, uint32_t cid,
exit(-EIO);
}
- if (total_xmitlen > PDU_SENDBUF_DEFAULT_MAX) {
+ if (total_xmitlen > (int)PDU_SENDBUF_DEFAULT_MAX) {
log_error("BUG: Cannot send %d bytes.", total_xmitlen);
exit(-EINVAL);
}
@@ -603,8 +603,8 @@ ksend_pdu_begin(uint64_t transport_handle, uint32_t sid, uint32_t cid,
}
static int
-ksend_pdu_end(uint64_t transport_handle, uint32_t sid, uint32_t cid,
- int *retcode)
+ksend_pdu_end(__attribute__((unused))uint64_t transport_handle,
+ uint32_t sid, uint32_t cid, int *retcode)
{
int rc;
struct iscsi_uevent *ev;
@@ -929,7 +929,7 @@ ktransport_ep_disconnect(iscsi_conn_t *conn)
log_debug(7, "in %s", __FUNCTION__);
- if (conn->transport_ep_handle == -1)
+ if (conn->transport_ep_handle == (uint64_t)-1)
return;
memset(&ev, 0, sizeof(struct iscsi_uevent));
diff --git a/usr/uip_mgmt_ipc.c b/usr/uip_mgmt_ipc.c
index 2f74657..003fe42 100644
--- a/usr/uip_mgmt_ipc.c
+++ b/usr/uip_mgmt_ipc.c
@@ -22,9 +22,9 @@
#include "iscsid_req.h"
#include "iscsi_err.h"
-int uip_broadcast_params(struct iscsi_transport *t,
+int uip_broadcast_params(__attribute__((unused))struct iscsi_transport *t,
struct iface_rec *iface,
- struct iscsi_session *session)
+ __attribute__((unused))struct iscsi_session *session)
{
struct iscsid_uip_broadcast broadcast;
@@ -42,7 +42,7 @@ int uip_broadcast_params(struct iscsi_transport *t,
sizeof(*iface), O_NONBLOCK, NULL);
}
-int uip_broadcast_ping_req(struct iscsi_transport *t,
+int uip_broadcast_ping_req(__attribute__((unused))struct iscsi_transport *t,
struct iface_rec *iface, int datalen,
struct sockaddr_storage *dst_addr, uint32_t *status)
{