summaryrefslogtreecommitdiffstats
path: root/sbin/hastd/hastd.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2012-01-10 22:39:07 +0000
committerpjd <pjd@FreeBSD.org>2012-01-10 22:39:07 +0000
commitc5fe5a76f24f997008c868c17e6fe6ed1b2aaf7b (patch)
tree2219c6a6a85261711a382939a35cabc647cb7775 /sbin/hastd/hastd.c
parent29f76d890ec6d66428132ae19aece81336519a79 (diff)
downloadFreeBSD-src-c5fe5a76f24f997008c868c17e6fe6ed1b2aaf7b.zip
FreeBSD-src-c5fe5a76f24f997008c868c17e6fe6ed1b2aaf7b.tar.gz
For functions that return -1 on failure check exactly for -1 and not for
any negative number. MFC after: 3 days
Diffstat (limited to 'sbin/hastd/hastd.c')
-rw-r--r--sbin/hastd/hastd.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/sbin/hastd/hastd.c b/sbin/hastd/hastd.c
index bea390a..b4b3c59 100644
--- a/sbin/hastd/hastd.c
+++ b/sbin/hastd/hastd.c
@@ -174,7 +174,7 @@ descriptors_assert(const struct hast_resource *res, int pjdlogmode)
msg[0] = '\0';
maxfd = sysconf(_SC_OPEN_MAX);
- if (maxfd < 0) {
+ if (maxfd == -1) {
pjdlog_init(pjdlogmode);
pjdlog_prefix_set("[%s] (%s) ", res->hr_name,
role2str(res->hr_role));
@@ -452,7 +452,7 @@ resource_reload(const struct hast_resource *res)
pjdlog_error("Unable to allocate header for reload message.");
return;
}
- if (hast_proto_send(res, res->hr_ctrl, nvout, NULL, 0) < 0) {
+ if (hast_proto_send(res, res->hr_ctrl, nvout, NULL, 0) == -1) {
pjdlog_errno(LOG_ERR, "Unable to send reload message");
nv_free(nvout);
return;
@@ -460,7 +460,7 @@ resource_reload(const struct hast_resource *res)
nv_free(nvout);
/* Receive response. */
- if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) < 0) {
+ if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) == -1) {
pjdlog_errno(LOG_ERR, "Unable to receive reload reply");
return;
}
@@ -496,7 +496,7 @@ hastd_reload(void)
*/
if (strcmp(cfg->hc_controladdr, newcfg->hc_controladdr) != 0) {
if (proto_server(newcfg->hc_controladdr,
- &newcfg->hc_controlconn) < 0) {
+ &newcfg->hc_controlconn) == -1) {
pjdlog_errno(LOG_ERR,
"Unable to listen on control address %s",
newcfg->hc_controladdr);
@@ -545,7 +545,7 @@ hastd_reload(void)
"Unable to open or create pidfile %s",
newcfg->hc_pidfile);
}
- } else if (pidfile_write(newpfh) < 0) {
+ } else if (pidfile_write(newpfh) == -1) {
/* Write PID to a file. */
pjdlog_errno(LOG_WARNING,
"Unable to write PID to file %s",
@@ -744,7 +744,7 @@ listen_accept(struct hastd_listen *lst)
proto_local_address(lst->hl_conn, laddr, sizeof(laddr));
pjdlog_debug(1, "Accepting connection to %s.", laddr);
- if (proto_accept(lst->hl_conn, &conn) < 0) {
+ if (proto_accept(lst->hl_conn, &conn) == -1) {
pjdlog_errno(LOG_ERR, "Unable to accept connection %s", laddr);
return;
}
@@ -754,7 +754,7 @@ listen_accept(struct hastd_listen *lst)
pjdlog_info("Connection from %s to %s.", raddr, laddr);
/* Error in setting timeout is not critical, but why should it fail? */
- if (proto_timeout(conn, HAST_TIMEOUT) < 0)
+ if (proto_timeout(conn, HAST_TIMEOUT) == -1)
pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");
nvin = nvout = nverr = NULL;
@@ -773,7 +773,7 @@ listen_accept(struct hastd_listen *lst)
}
/* Ok, remote host can access at least one resource. */
- if (hast_proto_recv_hdr(conn, &nvin) < 0) {
+ if (hast_proto_recv_hdr(conn, &nvin) == -1) {
pjdlog_errno(LOG_ERR, "Unable to receive header from %s",
raddr);
goto close;
@@ -861,7 +861,7 @@ listen_accept(struct hastd_listen *lst)
"Worker process exists (pid=%u), stopping it.",
(unsigned int)res->hr_workerpid);
/* Stop child process. */
- if (kill(res->hr_workerpid, SIGINT) < 0) {
+ if (kill(res->hr_workerpid, SIGINT) == -1) {
pjdlog_errno(LOG_ERR,
"Unable to stop worker process (pid=%u)",
(unsigned int)res->hr_workerpid);
@@ -911,7 +911,7 @@ listen_accept(struct hastd_listen *lst)
strerror(nv_error(nvout)));
goto fail;
}
- if (hast_proto_send(NULL, conn, nvout, NULL, 0) < 0) {
+ if (hast_proto_send(NULL, conn, nvout, NULL, 0) == -1) {
int error = errno;
pjdlog_errno(LOG_ERR, "Unable to send response to %s",
@@ -940,7 +940,7 @@ fail:
"Unable to prepare error header for %s", raddr);
goto close;
}
- if (hast_proto_send(NULL, conn, nverr, NULL, 0) < 0) {
+ if (hast_proto_send(NULL, conn, nverr, NULL, 0) == -1) {
pjdlog_errno(LOG_ERR, "Unable to send error to %s", raddr);
goto close;
}
@@ -965,20 +965,20 @@ connection_migrate(struct hast_resource *res)
PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY);
- if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) {
+ if (proto_recv(res->hr_conn, &val, sizeof(val)) == -1) {
pjdlog_errno(LOG_WARNING,
"Unable to receive connection command");
return;
}
if (proto_client(res->hr_sourceaddr[0] != '\0' ? res->hr_sourceaddr : NULL,
- res->hr_remoteaddr, &conn) < 0) {
+ res->hr_remoteaddr, &conn) == -1) {
val = errno;
pjdlog_errno(LOG_WARNING,
"Unable to create outgoing connection to %s",
res->hr_remoteaddr);
goto out;
}
- if (proto_connect(conn, -1) < 0) {
+ if (proto_connect(conn, -1) == -1) {
val = errno;
pjdlog_errno(LOG_WARNING, "Unable to connect to %s",
res->hr_remoteaddr);
@@ -987,11 +987,11 @@ connection_migrate(struct hast_resource *res)
}
val = 0;
out:
- if (proto_send(res->hr_conn, &val, sizeof(val)) < 0) {
+ if (proto_send(res->hr_conn, &val, sizeof(val)) == -1) {
pjdlog_errno(LOG_WARNING,
"Unable to send reply to connection request");
}
- if (val == 0 && proto_connection_send(res->hr_conn, conn) < 0)
+ if (val == 0 && proto_connection_send(res->hr_conn, conn) == -1)
pjdlog_errno(LOG_WARNING, "Unable to send connection");
pjdlog_prefix_set("%s", "");
@@ -1261,14 +1261,14 @@ main(int argc, char *argv[])
PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
/* Listen on control address. */
- if (proto_server(cfg->hc_controladdr, &cfg->hc_controlconn) < 0) {
+ if (proto_server(cfg->hc_controladdr, &cfg->hc_controlconn) == -1) {
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_OSERR, "Unable to listen on control address %s",
cfg->hc_controladdr);
}
/* Listen for remote connections. */
TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) {
- if (proto_server(lst->hl_addr, &lst->hl_conn) < 0) {
+ if (proto_server(lst->hl_addr, &lst->hl_conn) == -1) {
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_OSERR, "Unable to listen on address %s",
lst->hl_addr);
@@ -1276,7 +1276,7 @@ main(int argc, char *argv[])
}
if (!foreground) {
- if (daemon(0, 0) < 0) {
+ if (daemon(0, 0) == -1) {
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_OSERR, "Unable to daemonize");
}
@@ -1285,7 +1285,7 @@ main(int argc, char *argv[])
pjdlog_mode_set(PJDLOG_MODE_SYSLOG);
/* Write PID to a file. */
- if (pidfile_write(pfh) < 0) {
+ if (pidfile_write(pfh) == -1) {
pjdlog_errno(LOG_WARNING,
"Unable to write PID to a file %s",
cfg->hc_pidfile);
OpenPOWER on IntegriCloud