summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorJim Ramsay <jim_ramsay@dell.com>2011-07-20 09:06:46 -0400
committerMike Christie <michaelc@cs.wisc.edu>2011-08-02 00:04:23 -0500
commit1e3d6226e928c0ea2c857de9ab821b550ef0e18b (patch)
tree86b470df355c63673f4479d5b2a0918af938bbec /usr
parent4c93bba5ea9610fce9999ff7dc21f28b90e947d8 (diff)
downloadopen-iscsi-1e3d6226e928c0ea2c857de9ab821b550ef0e18b.tar.gz
iscsi tools: Fix warnings reported by gcc-4.5.2
A majority of these have to deal with ignored return values. Some of the others are just unused variables or functions. One warning remains at link-time for iscsistart: iscsi_util.c:267: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking. Signed-off-by: Jim Ramsay <jim_ramsay@dell.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/auth.c13
-rw-r--r--usr/discovery.c2
-rw-r--r--usr/idbm.c1
-rw-r--r--usr/iface.c3
-rw-r--r--usr/iscsi_util.c15
-rw-r--r--usr/iscsid.c16
-rw-r--r--usr/iscsid_req.c4
-rw-r--r--usr/log.c2
-rw-r--r--usr/mgmt_ipc.c3
9 files changed, 38 insertions, 21 deletions
diff --git a/usr/auth.c b/usr/auth.c
index cc232a0..c924545 100644
--- a/usr/auth.c
+++ b/usr/auth.c
@@ -194,27 +194,20 @@ get_random_bytes(unsigned char *data, unsigned int length)
fd = open("/dev/urandom", O_RDONLY);
while (length > 0) {
- if (fd)
- read(fd, &r, sizeof(long));
- else
+ if (!fd || read(fd, &r, sizeof(long)) != -1)
r = rand();
r = r ^ (r >> 8);
r = r ^ (r >> 4);
n = r & 0x7;
- if (fd)
- read(fd, &r, sizeof(long));
- else
+ if (!fd || read(fd, &r, sizeof(long)) != -1)
r = rand();
r = r ^ (r >> 8);
r = r ^ (r >> 5);
n = (n << 3) | (r & 0x7);
- if (fd)
- read(fd, &r, sizeof(long));
- else
+ if (!fd || read(fd, &r, sizeof(long)) != -1)
r = rand();
-
r = r ^ (r >> 8);
r = r ^ (r >> 5);
n = (n << 2) | (r & 0x3);
diff --git a/usr/discovery.c b/usr/discovery.c
index 3c49aff..a0d073c 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -962,6 +962,7 @@ process_recvd_pdu(struct iscsi_hdr *pdu,
return(rc);
}
+#if 0 /* Unused */
/*
* Make a best effort to logout the session.
*/
@@ -1012,6 +1013,7 @@ static void iscsi_logout(iscsi_session_t * session)
logout_resp.response);
}
}
+#endif /* Unused */
static void iscsi_destroy_session(struct iscsi_session *session)
{
diff --git a/usr/idbm.c b/usr/idbm.c
index 4f78250..875a123 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -1108,7 +1108,6 @@ int idbm_for_each_isns_drec(void *data, idbm_drec_op_fn *fn)
static int __idbm_print_all_by_drec(void *data, struct discovery_rec *drec)
{
int info_level = *(int *)data;
- int rc;
if (info_level >= 1) {
printf("DiscoveryAddress: %s,%d\n",
diff --git a/usr/iface.c b/usr/iface.c
index b10a1d4..a0a6389 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -308,6 +308,7 @@ free_info:
return rc;
}
+#if 0 /* Unused */
static int iface_get_next_id(void)
{
struct stat statb;
@@ -345,6 +346,7 @@ static int iface_get_next_id(void)
free(iface_conf);
return rc;
}
+#endif /* Unused */
struct iface_search {
struct iface_rec *pattern;
@@ -790,7 +792,6 @@ int iface_setup_from_boot_context(struct iface_rec *iface,
{
struct iscsi_transport *t;
uint32_t hostno;
- int rc;
if (strlen(context->initiatorname))
strlcpy(iface->iname, context->initiatorname,
diff --git a/usr/iscsi_util.c b/usr/iscsi_util.c
index 293ec54..270e585 100644
--- a/usr/iscsi_util.c
+++ b/usr/iscsi_util.c
@@ -48,7 +48,8 @@ void daemon_init(void)
dup2(fd, 1);
dup2(fd, 2);
setsid();
- chdir("/");
+ if (chdir("/") < 0)
+ log_debug(1, "Could not chdir to /: %s", strerror(errno));
}
#define ISCSI_OOM_PATH_LEN 48
@@ -59,7 +60,9 @@ int oom_adjust(void)
char path[ISCSI_OOM_PATH_LEN];
struct stat statb;
- nice(-10);
+ if (nice(-10) < 0)
+ log_debug(1, "Could not increase process priority: %s",
+ strerror(errno));
snprintf(path, ISCSI_OOM_PATH_LEN, "/proc/%d/oom_score_adj", getpid());
if (stat(path, &statb)) {
@@ -70,8 +73,12 @@ int oom_adjust(void)
fd = open(path, O_WRONLY);
if (fd < 0)
return -1;
- write(fd, "-16", 3); /* for 2.6.11 */
- write(fd, "-17", 3); /* for Andrea's patch */
+ if (write(fd, "-16", 3) < 0) /* for 2.6.11 */
+ log_debug(1, "Could not set oom score to -16: %s",
+ strerror(errno));
+ if (write(fd, "-17", 3) < 0) /* for Andrea's patch */
+ log_debug(1, "Could not set oom score to -17: %s",
+ strerror(errno));
close(fd);
return 0;
}
diff --git a/usr/iscsid.c b/usr/iscsid.c
index 9df6658..d292f9b 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -450,17 +450,27 @@ int main(int argc, char *argv[])
exit(ISCSI_ERR);
}
- chdir("/");
+ if (chdir("/") < 0)
+ log_debug(1, "Unable to chdir to /");
if (fd > 0) {
if (lockf(fd, F_TLOCK, 0) < 0) {
log_error("Unable to lock pid file");
log_close(log_pid);
exit(ISCSI_ERR);
}
- ftruncate(fd, 0);
+ if (ftruncate(fd, 0) < 0) {
+ log_error("Unable to truncate pid file");
+ log_close(log_pid);
+ exit(ISCSI_ERR);
+ }
sprintf(buf, "%d\n", getpid());
- write(fd, buf, strlen(buf));
+ if (write(fd, buf, strlen(buf)) < 0) {
+ log_error("Unable to write pid file");
+ log_close(log_pid);
+ exit(ISCSI_ERR);
+ }
}
+
daemon_init();
} else {
if ((control_fd = ipc->ctldev_open()) < 0) {
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
index a49b667..0902011 100644
--- a/usr/iscsid_req.c
+++ b/usr/iscsid_req.c
@@ -47,7 +47,9 @@ static void iscsid_startup(void)
return;
}
- system(startup_cmd);
+ if (system(startup_cmd) < 0)
+ log_error("Could not execute '%s' (err %d)",
+ startup_cmd, errno);
}
#define MAXSLEEP 128
diff --git a/usr/log.c b/usr/log.c
index 5747554..26c61d8 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -326,6 +326,7 @@ void log_info(const char *fmt, ...)
va_end(ap);
}
+#if 0 /* Unused */
static void __dump_line(int level, unsigned char *buf, int *cp)
{
char line[16*3+5], *lp = line;
@@ -359,6 +360,7 @@ static void __dump_char(int level, unsigned char *buf, int *cp, int ch)
#define dump_line() __dump_line(level, char_buf, &char_cnt)
#define dump_char(ch) __dump_char(level, char_buf, &char_cnt, ch)
+#endif /* Unused */
static void log_flush(void)
{
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
index 3e4d2ef..5c39c2e 100644
--- a/usr/mgmt_ipc.c
+++ b/usr/mgmt_ipc.c
@@ -435,7 +435,8 @@ mgmt_ipc_write_rsp(queue_task_t *qtask, int err)
}
qtask->rsp.err = err;
- write(qtask->mgmt_ipc_fd, &qtask->rsp, sizeof(qtask->rsp));
+ if (write(qtask->mgmt_ipc_fd, &qtask->rsp, sizeof(qtask->rsp)) < 0)
+ log_error("IPC qtask write failed: %s", strerror(errno));
close(qtask->mgmt_ipc_fd);
mgmt_ipc_destroy_queue_task(qtask);
}