diff options
Diffstat (limited to 'sbin/hastd')
-rw-r--r-- | sbin/hastd/control.c | 16 | ||||
-rw-r--r-- | sbin/hastd/ebuf.c | 4 | ||||
-rw-r--r-- | sbin/hastd/event.c | 8 | ||||
-rw-r--r-- | sbin/hastd/hast_proto.c | 14 | ||||
-rw-r--r-- | sbin/hastd/hastd.c | 40 | ||||
-rw-r--r-- | sbin/hastd/hooks.c | 10 | ||||
-rw-r--r-- | sbin/hastd/metadata.c | 10 | ||||
-rw-r--r-- | sbin/hastd/nv.c | 12 | ||||
-rw-r--r-- | sbin/hastd/primary.c | 76 | ||||
-rw-r--r-- | sbin/hastd/proto.c | 6 | ||||
-rw-r--r-- | sbin/hastd/proto_common.c | 4 | ||||
-rw-r--r-- | sbin/hastd/proto_socketpair.c | 2 | ||||
-rw-r--r-- | sbin/hastd/proto_tcp.c | 16 | ||||
-rw-r--r-- | sbin/hastd/proto_uds.c | 12 | ||||
-rw-r--r-- | sbin/hastd/secondary.c | 32 | ||||
-rw-r--r-- | sbin/hastd/subr.c | 8 |
16 files changed, 135 insertions, 135 deletions
diff --git a/sbin/hastd/control.c b/sbin/hastd/control.c index 2e99366..925fd32 100644 --- a/sbin/hastd/control.c +++ b/sbin/hastd/control.c @@ -115,7 +115,7 @@ control_set_role_common(struct hastd_config *cfg, struct nv *nvout, * doing that work. */ if (res->hr_workerpid != 0) { - if (kill(res->hr_workerpid, SIGTERM) < 0) { + if (kill(res->hr_workerpid, SIGTERM) == -1) { pjdlog_errno(LOG_WARNING, "Unable to kill worker process %u", (unsigned int)res->hr_workerpid); @@ -167,7 +167,7 @@ control_status_worker(struct hast_resource *res, struct nv *nvout, "Unable to prepare control header"); goto end; } - if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) < 0) { + if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) == -1) { error = errno; pjdlog_errno(LOG_ERR, "Unable to send control header"); goto end; @@ -176,7 +176,7 @@ control_status_worker(struct hast_resource *res, struct nv *nvout, /* * Receive response. */ - if (hast_proto_recv_hdr(res->hr_ctrl, &cnvin) < 0) { + if (hast_proto_recv_hdr(res->hr_ctrl, &cnvin) == -1) { error = errno; pjdlog_errno(LOG_ERR, "Unable to receive control header"); goto end; @@ -293,7 +293,7 @@ control_handle(struct hastd_config *cfg) uint8_t cmd, role; int error; - if (proto_accept(cfg->hc_controlconn, &conn) < 0) { + if (proto_accept(cfg->hc_controlconn, &conn) == -1) { pjdlog_errno(LOG_ERR, "Unable to accept control connection"); return; } @@ -302,7 +302,7 @@ control_handle(struct hastd_config *cfg) nvin = nvout = NULL; role = HAST_ROLE_UNDEF; - if (hast_proto_recv_hdr(conn, &nvin) < 0) { + if (hast_proto_recv_hdr(conn, &nvin) == -1) { pjdlog_errno(LOG_ERR, "Unable to receive control header"); nvin = NULL; goto close; @@ -395,7 +395,7 @@ fail: if (error != 0) nv_add_int16(nvout, error, "error"); - if (hast_proto_send(NULL, conn, nvout, NULL, 0) < 0) + if (hast_proto_send(NULL, conn, nvout, NULL, 0) == -1) pjdlog_errno(LOG_ERR, "Unable to send control response"); close: if (nvin != NULL) @@ -417,7 +417,7 @@ ctrl_thread(void *arg) uint8_t cmd; for (;;) { - if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) < 0) { + if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) == -1) { if (sigexit_received) pthread_exit(NULL); pjdlog_errno(LOG_ERR, @@ -481,7 +481,7 @@ ctrl_thread(void *arg) nv_free(nvout); continue; } - if (hast_proto_send(NULL, res->hr_ctrl, nvout, NULL, 0) < 0) { + if (hast_proto_send(NULL, res->hr_ctrl, nvout, NULL, 0) == -1) { pjdlog_errno(LOG_ERR, "Unable to send reply to control message"); } diff --git a/sbin/hastd/ebuf.c b/sbin/hastd/ebuf.c index f5908a4..1ae2a26 100644 --- a/sbin/hastd/ebuf.c +++ b/sbin/hastd/ebuf.c @@ -116,7 +116,7 @@ ebuf_add_head(struct ebuf *eb, const void *data, size_t size) * We can't add more entries at the front, so we have to extend * our buffer. */ - if (ebuf_head_extend(eb, size) < 0) + if (ebuf_head_extend(eb, size) == -1) return (-1); } PJDLOG_ASSERT(size <= (size_t)(eb->eb_used - eb->eb_start)); @@ -143,7 +143,7 @@ ebuf_add_tail(struct ebuf *eb, const void *data, size_t size) * We can't add more entries at the back, so we have to extend * our buffer. */ - if (ebuf_tail_extend(eb, size) < 0) + if (ebuf_tail_extend(eb, size) == -1) return (-1); } PJDLOG_ASSERT(size <= diff --git a/sbin/hastd/event.c b/sbin/hastd/event.c index d895f67..ef65df1 100644 --- a/sbin/hastd/event.c +++ b/sbin/hastd/event.c @@ -61,11 +61,11 @@ event_send(const struct hast_resource *res, int event) "Unable to prepare event header"); goto done; } - if (hast_proto_send(res, res->hr_event, nvout, NULL, 0) < 0) { + if (hast_proto_send(res, res->hr_event, nvout, NULL, 0) == -1) { pjdlog_errno(LOG_ERR, "Unable to send event header"); goto done; } - if (hast_proto_recv_hdr(res->hr_event, &nvin) < 0) { + if (hast_proto_recv_hdr(res->hr_event, &nvin) == -1) { pjdlog_errno(LOG_ERR, "Unable to receive event header"); goto done; } @@ -92,7 +92,7 @@ event_recv(const struct hast_resource *res) nvin = nvout = NULL; - if (hast_proto_recv_hdr(res->hr_event, &nvin) < 0) { + if (hast_proto_recv_hdr(res->hr_event, &nvin) == -1) { /* * First error log as debug. This is because worker process * most likely exited. @@ -145,7 +145,7 @@ event_recv(const struct hast_resource *res) "Unable to prepare event header"); goto fail; } - if (hast_proto_send(res, res->hr_event, nvout, NULL, 0) < 0) { + if (hast_proto_send(res, res->hr_event, nvout, NULL, 0) == -1) { pjdlog_errno(LOG_ERR, "Unable to send event header"); goto fail; } diff --git a/sbin/hastd/hast_proto.c b/sbin/hastd/hast_proto.c index 439b0f3..039e767 100644 --- a/sbin/hastd/hast_proto.c +++ b/sbin/hastd/hast_proto.c @@ -114,13 +114,13 @@ hast_proto_send(const struct hast_resource *res, struct proto_conn *conn, hdr.version = HAST_PROTO_VERSION; hdr.size = htole32((uint32_t)ebuf_size(eb)); - if (ebuf_add_head(eb, &hdr, sizeof(hdr)) < 0) + if (ebuf_add_head(eb, &hdr, sizeof(hdr)) == -1) goto end; hptr = ebuf_data(eb, &hsize); - if (proto_send(conn, hptr, hsize) < 0) + if (proto_send(conn, hptr, hsize) == -1) goto end; - if (data != NULL && proto_send(conn, dptr, size) < 0) + if (data != NULL && proto_send(conn, dptr, size) == -1) goto end; ret = 0; @@ -141,7 +141,7 @@ hast_proto_recv_hdr(const struct proto_conn *conn, struct nv **nvp) eb = NULL; nv = NULL; - if (proto_recv(conn, &hdr, sizeof(hdr)) < 0) + if (proto_recv(conn, &hdr, sizeof(hdr)) == -1) goto fail; if (hdr.version != HAST_PROTO_VERSION) { @@ -154,11 +154,11 @@ hast_proto_recv_hdr(const struct proto_conn *conn, struct nv **nvp) eb = ebuf_alloc(hdr.size); if (eb == NULL) goto fail; - if (ebuf_add_tail(eb, NULL, hdr.size) < 0) + if (ebuf_add_tail(eb, NULL, hdr.size) == -1) goto fail; hptr = ebuf_data(eb, NULL); PJDLOG_ASSERT(hptr != NULL); - if (proto_recv(conn, hptr, hdr.size) < 0) + if (proto_recv(conn, hptr, hdr.size) == -1) goto fail; nv = nv_ntoh(eb); if (nv == NULL) @@ -196,7 +196,7 @@ hast_proto_recv_data(const struct hast_resource *res, struct proto_conn *conn, } else if (dsize == 0) { (void)nv_set_error(nv, 0); } else { - if (proto_recv(conn, data, dsize) < 0) + if (proto_recv(conn, data, dsize) == -1) goto end; for (ii = sizeof(pipeline) / sizeof(pipeline[0]); ii > 0; ii--) { 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); diff --git a/sbin/hastd/hooks.c b/sbin/hastd/hooks.c index 60d48d1..b1886ca 100644 --- a/sbin/hastd/hooks.c +++ b/sbin/hastd/hooks.c @@ -105,26 +105,26 @@ descriptors(void) * Redirect stdin, stdout and stderr to /dev/null. */ fd = open(_PATH_DEVNULL, O_RDONLY); - if (fd < 0) { + if (fd == -1) { pjdlog_errno(LOG_WARNING, "Unable to open %s for reading", _PATH_DEVNULL); } else if (fd != STDIN_FILENO) { - if (dup2(fd, STDIN_FILENO) < 0) { + if (dup2(fd, STDIN_FILENO) == -1) { pjdlog_errno(LOG_WARNING, "Unable to duplicate descriptor for stdin"); } close(fd); } fd = open(_PATH_DEVNULL, O_WRONLY); - if (fd < 0) { + if (fd == -1) { pjdlog_errno(LOG_WARNING, "Unable to open %s for writing", _PATH_DEVNULL); } else { - if (fd != STDOUT_FILENO && dup2(fd, STDOUT_FILENO) < 0) { + if (fd != STDOUT_FILENO && dup2(fd, STDOUT_FILENO) == -1) { pjdlog_errno(LOG_WARNING, "Unable to duplicate descriptor for stdout"); } - if (fd != STDERR_FILENO && dup2(fd, STDERR_FILENO) < 0) { + if (fd != STDERR_FILENO && dup2(fd, STDERR_FILENO) == -1) { pjdlog_errno(LOG_WARNING, "Unable to duplicate descriptor for stderr"); } diff --git a/sbin/hastd/metadata.c b/sbin/hastd/metadata.c index ad6c75b..6d9f366 100644 --- a/sbin/hastd/metadata.c +++ b/sbin/hastd/metadata.c @@ -61,14 +61,14 @@ metadata_read(struct hast_resource *res, bool openrw) * Is this first metadata_read() call for this resource? */ if (res->hr_localfd == -1) { - if (provinfo(res, openrw) < 0) { + if (provinfo(res, openrw) == -1) { rerrno = errno; goto fail; } opened_here = true; pjdlog_debug(1, "Obtained info about %s.", res->hr_localpath); if (openrw) { - if (flock(res->hr_localfd, LOCK_EX | LOCK_NB) < 0) { + if (flock(res->hr_localfd, LOCK_EX | LOCK_NB) == -1) { rerrno = errno; if (errno == EOPNOTSUPP) { pjdlog_warning("Unable to lock %s (operation not supported), but continuing.", @@ -91,7 +91,7 @@ metadata_read(struct hast_resource *res, bool openrw) "Unable to allocate memory to read metadata"); goto fail; } - if (ebuf_add_tail(eb, NULL, METADATA_SIZE) < 0) { + if (ebuf_add_tail(eb, NULL, METADATA_SIZE) == -1) { rerrno = errno; pjdlog_errno(LOG_ERR, "Unable to allocate memory to read metadata"); @@ -101,7 +101,7 @@ metadata_read(struct hast_resource *res, bool openrw) buf = ebuf_data(eb, NULL); PJDLOG_ASSERT(buf != NULL); done = pread(res->hr_localfd, buf, METADATA_SIZE, 0); - if (done < 0 || done != METADATA_SIZE) { + if (done == -1 || done != METADATA_SIZE) { rerrno = errno; pjdlog_errno(LOG_ERR, "Unable to read metadata"); ebuf_free(eb); @@ -213,7 +213,7 @@ metadata_write(struct hast_resource *res) PJDLOG_ASSERT(size < METADATA_SIZE); bcopy(ptr, buf, size); done = pwrite(res->hr_localfd, buf, METADATA_SIZE, 0); - if (done < 0 || done != METADATA_SIZE) { + if (done == -1 || done != METADATA_SIZE) { pjdlog_errno(LOG_ERR, "Unable to write metadata"); goto end; } diff --git a/sbin/hastd/nv.c b/sbin/hastd/nv.c index 89c174a..a884a3c 100644 --- a/sbin/hastd/nv.c +++ b/sbin/hastd/nv.c @@ -385,7 +385,7 @@ nv_ntoh(struct ebuf *eb) nv->nv_ebuf = eb; nv->nv_magic = NV_MAGIC; - if (nv_validate(nv, &extra) < 0) { + if (nv_validate(nv, &extra) == -1) { rerrno = errno; nv->nv_magic = 0; free(nv); @@ -480,7 +480,7 @@ nv_add_stringv(struct nv *nv, const char *name, const char *valuefmt, ssize_t size; size = vasprintf(&value, valuefmt, valueap); - if (size < 0) { + if (size == -1) { if (nv->nv_error == 0) nv->nv_error = ENOMEM; return; @@ -627,7 +627,7 @@ nv_dump(struct nv *nv) unsigned int ii; bool swap; - if (nv_validate(nv, NULL) < 0) { + if (nv_validate(nv, NULL) == -1) { printf("error: %d\n", errno); return; } @@ -784,7 +784,7 @@ nv_add(struct nv *nv, const unsigned char *value, size_t vsize, int type, bcopy(name, nvh->nvh_name, namesize); /* Add header first. */ - if (ebuf_add_tail(nv->nv_ebuf, nvh, NVH_HSIZE(nvh)) < 0) { + if (ebuf_add_tail(nv->nv_ebuf, nvh, NVH_HSIZE(nvh)) == -1) { PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; @@ -793,7 +793,7 @@ nv_add(struct nv *nv, const unsigned char *value, size_t vsize, int type, } free(nvh); /* Add the actual data. */ - if (ebuf_add_tail(nv->nv_ebuf, value, vsize) < 0) { + if (ebuf_add_tail(nv->nv_ebuf, value, vsize) == -1) { PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; @@ -804,7 +804,7 @@ nv_add(struct nv *nv, const unsigned char *value, size_t vsize, int type, if (vsize == 0) return; PJDLOG_ASSERT(vsize > 0 && vsize <= sizeof(align)); - if (ebuf_add_tail(nv->nv_ebuf, align, vsize) < 0) { + if (ebuf_add_tail(nv->nv_ebuf, align, vsize) == -1) { PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c index 4dbfc06..ca1ab53 100644 --- a/sbin/hastd/primary.c +++ b/sbin/hastd/primary.c @@ -254,7 +254,7 @@ cleanup(struct hast_resource *res) ggiod.gctl_version = G_GATE_VERSION; ggiod.gctl_unit = res->hr_ggateunit; ggiod.gctl_force = 1; - if (ioctl(res->hr_ggatefd, G_GATE_CMD_DESTROY, &ggiod) < 0) { + if (ioctl(res->hr_ggatefd, G_GATE_CMD_DESTROY, &ggiod) == -1) { pjdlog_errno(LOG_WARNING, "Unable to destroy hast/%s device", res->hr_provname); @@ -451,7 +451,7 @@ init_resuid(struct hast_resource *res) /* Initialize unique resource identifier. */ arc4random_buf(&res->hr_resuid, sizeof(res->hr_resuid)); mtx_unlock(&metadata_lock); - if (metadata_write(res) < 0) + if (metadata_write(res) == -1) exit(EX_NOINPUT); return (true); } @@ -463,19 +463,19 @@ init_local(struct hast_resource *res) unsigned char *buf; size_t mapsize; - if (metadata_read(res, true) < 0) + if (metadata_read(res, true) == -1) exit(EX_NOINPUT); mtx_init(&res->hr_amp_lock); if (activemap_init(&res->hr_amp, res->hr_datasize, res->hr_extentsize, - res->hr_local_sectorsize, res->hr_keepdirty) < 0) { + res->hr_local_sectorsize, res->hr_keepdirty) == -1) { primary_exit(EX_TEMPFAIL, "Unable to create activemap"); } mtx_init(&range_lock); cv_init(&range_regular_cond); - if (rangelock_init(&range_regular) < 0) + if (rangelock_init(&range_regular) == -1) primary_exit(EX_TEMPFAIL, "Unable to create regular range lock"); cv_init(&range_sync_cond); - if (rangelock_init(&range_sync) < 0) + if (rangelock_init(&range_sync) == -1) primary_exit(EX_TEMPFAIL, "Unable to create sync range lock"); mapsize = activemap_ondisk_size(res->hr_amp); buf = calloc(1, mapsize); @@ -500,7 +500,7 @@ init_local(struct hast_resource *res) */ res->hr_primary_localcnt = 0; res->hr_primary_remotecnt = 0; - if (metadata_write(res) < 0) + if (metadata_write(res) == -1) exit(EX_NOINPUT); } @@ -511,11 +511,11 @@ primary_connect(struct hast_resource *res, struct proto_conn **connp) int16_t val; val = 1; - if (proto_send(res->hr_conn, &val, sizeof(val)) < 0) { + if (proto_send(res->hr_conn, &val, sizeof(val)) == -1) { primary_exit(EX_TEMPFAIL, "Unable to send connection request to parent"); } - if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) { + if (proto_recv(res->hr_conn, &val, sizeof(val)) == -1) { primary_exit(EX_TEMPFAIL, "Unable to receive reply to connection request from parent"); } @@ -525,18 +525,18 @@ primary_connect(struct hast_resource *res, struct proto_conn **connp) res->hr_remoteaddr); return (-1); } - if (proto_connection_recv(res->hr_conn, true, &conn) < 0) { + if (proto_connection_recv(res->hr_conn, true, &conn) == -1) { primary_exit(EX_TEMPFAIL, "Unable to receive connection from parent"); } - if (proto_connect_wait(conn, res->hr_timeout) < 0) { + if (proto_connect_wait(conn, res->hr_timeout) == -1) { pjdlog_errno(LOG_WARNING, "Unable to connect to %s", res->hr_remoteaddr); proto_close(conn); return (-1); } /* Error in setting timeout is not critical, but why should it fail? */ - if (proto_timeout(conn, res->hr_timeout) < 0) + if (proto_timeout(conn, res->hr_timeout) == -1) pjdlog_errno(LOG_WARNING, "Unable to set connection timeout"); *connp = conn; @@ -583,7 +583,7 @@ init_remote(struct hast_resource *res, struct proto_conn **inp, nv_free(nvout); goto close; } - if (hast_proto_send(res, out, nvout, NULL, 0) < 0) { + if (hast_proto_send(res, out, nvout, NULL, 0) == -1) { pjdlog_errno(LOG_WARNING, "Unable to send handshake header to %s", res->hr_remoteaddr); @@ -591,7 +591,7 @@ init_remote(struct hast_resource *res, struct proto_conn **inp, goto close; } nv_free(nvout); - if (hast_proto_recv_hdr(out, &nvin) < 0) { + if (hast_proto_recv_hdr(out, &nvin) == -1) { pjdlog_errno(LOG_WARNING, "Unable to receive handshake header from %s", res->hr_remoteaddr); @@ -655,7 +655,7 @@ init_remote(struct hast_resource *res, struct proto_conn **inp, nv_free(nvout); goto close; } - if (hast_proto_send(res, in, nvout, NULL, 0) < 0) { + if (hast_proto_send(res, in, nvout, NULL, 0) == -1) { pjdlog_errno(LOG_WARNING, "Unable to send handshake header to %s", res->hr_remoteaddr); @@ -663,7 +663,7 @@ init_remote(struct hast_resource *res, struct proto_conn **inp, goto close; } nv_free(nvout); - if (hast_proto_recv_hdr(out, &nvin) < 0) { + if (hast_proto_recv_hdr(out, &nvin) == -1) { pjdlog_errno(LOG_WARNING, "Unable to receive handshake header from %s", res->hr_remoteaddr); @@ -726,7 +726,7 @@ init_remote(struct hast_resource *res, struct proto_conn **inp, * download its activemap. */ if (hast_proto_recv_data(res, out, nvin, map, - mapsize) < 0) { + mapsize) == -1) { pjdlog_errno(LOG_ERR, "Unable to receive remote activemap"); nv_free(nvin); @@ -801,7 +801,7 @@ init_ggate(struct hast_resource *res) * We communicate with ggate via /dev/ggctl. Open it. */ res->hr_ggatefd = open("/dev/" G_GATE_CTL_NAME, O_RDWR); - if (res->hr_ggatefd < 0) + if (res->hr_ggatefd == -1) primary_exit(EX_OSFILE, "Unable to open /dev/" G_GATE_CTL_NAME); /* * Create provider before trying to connect, as connection failure @@ -859,7 +859,7 @@ hastd_primary(struct hast_resource *res) * Create communication channel for sending control commands from * parent to child. */ - if (proto_client(NULL, "socketpair://", &res->hr_ctrl) < 0) { + if (proto_client(NULL, "socketpair://", &res->hr_ctrl) == -1) { /* TODO: There's no need for this to be fatal error. */ KEEP_ERRNO((void)pidfile_remove(pfh)); pjdlog_exit(EX_OSERR, @@ -868,7 +868,7 @@ hastd_primary(struct hast_resource *res) /* * Create communication channel for sending events from child to parent. */ - if (proto_client(NULL, "socketpair://", &res->hr_event) < 0) { + if (proto_client(NULL, "socketpair://", &res->hr_event) == -1) { /* TODO: There's no need for this to be fatal error. */ KEEP_ERRNO((void)pidfile_remove(pfh)); pjdlog_exit(EX_OSERR, @@ -878,7 +878,7 @@ hastd_primary(struct hast_resource *res) * Create communication channel for sending connection requests from * child to parent. */ - if (proto_client(NULL, "socketpair://", &res->hr_conn) < 0) { + if (proto_client(NULL, "socketpair://", &res->hr_conn) == -1) { /* TODO: There's no need for this to be fatal error. */ KEEP_ERRNO((void)pidfile_remove(pfh)); pjdlog_exit(EX_OSERR, @@ -1095,7 +1095,7 @@ write_complete(struct hast_resource *res, struct hio *hio) mtx_unlock(&metadata_lock); } rw_unlock(&hio_remote_lock[ncomp]); - if (ioctl(res->hr_ggatefd, G_GATE_CMD_DONE, ggio) < 0) + if (ioctl(res->hr_ggatefd, G_GATE_CMD_DONE, ggio) == -1) primary_exit(EX_OSERR, "G_GATE_CMD_DONE failed"); hio->hio_done = true; } @@ -1133,7 +1133,7 @@ ggate_recv_thread(void *arg) pjdlog_debug(2, "ggate_recv: (%p) Waiting for request from the kernel.", hio); - if (ioctl(res->hr_ggatefd, G_GATE_CMD_START, ggio) < 0) { + if (ioctl(res->hr_ggatefd, G_GATE_CMD_START, ggio) == -1) { if (sigexit_received) pthread_exit(NULL); primary_exit(EX_OSERR, "G_GATE_CMD_START failed"); @@ -1225,7 +1225,7 @@ ggate_recv_thread(void *arg) continue; } if (rangelock_add(range_regular, - ggio->gctl_offset, ggio->gctl_length) < 0) { + ggio->gctl_offset, ggio->gctl_length) == -1) { mtx_unlock(&range_lock); pjdlog_debug(2, "regular: Range offset=%jd length=%zu is already locked, waiting.", @@ -1296,7 +1296,7 @@ local_send_thread(void *arg) /* * If READ failed, try to read from remote node. */ - if (ret < 0) { + if (ret == -1) { reqlog(LOG_WARNING, 0, ggio, "Local request failed (%s), trying remote node. ", strerror(errno)); @@ -1313,7 +1313,7 @@ local_send_thread(void *arg) ret = pwrite(res->hr_localfd, ggio->gctl_data, ggio->gctl_length, ggio->gctl_offset + res->hr_localoff); - if (ret < 0) { + if (ret == -1) { hio->hio_errors[ncomp] = errno; reqlog(LOG_WARNING, 0, ggio, "Local request failed (%s): ", @@ -1336,7 +1336,7 @@ local_send_thread(void *arg) ret = g_delete(res->hr_localfd, ggio->gctl_offset + res->hr_localoff, ggio->gctl_length); - if (ret < 0) { + if (ret == -1) { hio->hio_errors[ncomp] = errno; reqlog(LOG_WARNING, 0, ggio, "Local request failed (%s): ", @@ -1352,7 +1352,7 @@ local_send_thread(void *arg) break; } ret = g_flush(res->hr_localfd); - if (ret < 0) { + if (ret == -1) { if (errno == EOPNOTSUPP) res->hr_localflush = false; hio->hio_errors[ncomp] = errno; @@ -1406,7 +1406,7 @@ keepalive_send(struct hast_resource *res, unsigned int ncomp) "keepalive_send: Unable to prepare header to send."); return; } - if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) < 0) { + if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) == -1) { rw_unlock(&hio_remote_lock[ncomp]); pjdlog_common(LOG_DEBUG, 1, errno, "keepalive_send: Unable to send request"); @@ -1520,7 +1520,7 @@ remote_send_thread(void *arg) TAILQ_INSERT_TAIL(&hio_recv_list[ncomp], hio, hio_next[ncomp]); mtx_unlock(&hio_recv_list_lock[ncomp]); if (hast_proto_send(res, res->hr_remoteout, nv, data, - data != NULL ? length : 0) < 0) { + data != NULL ? length : 0) == -1) { hio->hio_errors[ncomp] = errno; rw_unlock(&hio_remote_lock[ncomp]); pjdlog_debug(2, @@ -1617,7 +1617,7 @@ remote_recv_thread(void *arg) mtx_unlock(&hio_recv_list_lock[ncomp]); goto done_queue; } - if (hast_proto_recv_hdr(res->hr_remotein, &nv) < 0) { + if (hast_proto_recv_hdr(res->hr_remotein, &nv) == -1) { pjdlog_errno(LOG_ERR, "Unable to receive reply header"); rw_unlock(&hio_remote_lock[ncomp]); @@ -1665,7 +1665,7 @@ remote_recv_thread(void *arg) goto done_queue; } if (hast_proto_recv_data(res, res->hr_remotein, nv, - ggio->gctl_data, ggio->gctl_length) < 0) { + ggio->gctl_data, ggio->gctl_length) == -1) { hio->hio_errors[ncomp] = errno; pjdlog_errno(LOG_ERR, "Unable to receive reply data"); @@ -1766,7 +1766,7 @@ ggate_send_thread(void *arg) if (!hio->hio_done) write_complete(res, hio); } else { - if (ioctl(res->hr_ggatefd, G_GATE_CMD_DONE, ggio) < 0) { + if (ioctl(res->hr_ggatefd, G_GATE_CMD_DONE, ggio) == -1) { primary_exit(EX_OSERR, "G_GATE_CMD_DONE failed"); } @@ -1834,7 +1834,7 @@ sync_thread(void *arg __unused) mtx_unlock(&res->hr_amp_lock); if (dorewind) { dorewind = false; - if (offset < 0) + if (offset == -1) pjdlog_info("Nodes are in sync."); else { pjdlog_info("Synchronization started. %NB to go.", @@ -1844,7 +1844,7 @@ sync_thread(void *arg __unused) gettimeofday(&tstart, NULL); } } - if (offset < 0) { + if (offset == -1) { sync_stop(); pjdlog_debug(1, "Nothing to synchronize."); /* @@ -1903,7 +1903,7 @@ sync_thread(void *arg __unused) mtx_unlock(&range_lock); continue; } - if (rangelock_add(range_sync, offset, length) < 0) { + if (rangelock_add(range_sync, offset, length) == -1) { mtx_unlock(&range_lock); pjdlog_debug(2, "sync: Range offset=%jd length=%jd is already locked, waiting.", @@ -2124,12 +2124,12 @@ primary_config_reload(struct hast_resource *res, struct nv *nv) } rw_unlock(&hio_remote_lock[ii]); if (proto_timeout(gres->hr_remotein, - gres->hr_timeout) < 0) { + gres->hr_timeout) == -1) { pjdlog_errno(LOG_WARNING, "Unable to set connection timeout"); } if (proto_timeout(gres->hr_remoteout, - gres->hr_timeout) < 0) { + gres->hr_timeout) == -1) { pjdlog_errno(LOG_WARNING, "Unable to set connection timeout"); } diff --git a/sbin/hastd/proto.c b/sbin/hastd/proto.c index 452f82f..73487c0 100644 --- a/sbin/hastd/proto.c +++ b/sbin/hastd/proto.c @@ -419,14 +419,14 @@ proto_timeout(const struct proto_conn *conn, int timeout) PJDLOG_ASSERT(conn->pc_proto != NULL); fd = proto_descriptor(conn); - if (fd < 0) + if (fd == -1) return (-1); tv.tv_sec = timeout; tv.tv_usec = 0; - if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0) + if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) return (-1); - if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) + if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) return (-1); return (0); diff --git a/sbin/hastd/proto_common.c b/sbin/hastd/proto_common.c index 183b4e4..59b1e39 100644 --- a/sbin/hastd/proto_common.c +++ b/sbin/hastd/proto_common.c @@ -116,7 +116,7 @@ proto_common_send(int sock, const unsigned char *data, size_t size, int fd) done = send(sock, data, sendsize, MSG_NOSIGNAL); if (done == 0) { return (ENOTCONN); - } else if (done < 0) { + } else if (done == -1) { if (errno == EINTR) continue; if (errno == ENOBUFS) { @@ -215,7 +215,7 @@ proto_common_recv(int sock, unsigned char *data, size_t size, int *fdp) } while (done == -1 && errno == EINTR); if (done == 0) { return (ENOTCONN); - } else if (done < 0) { + } else if (done == -1) { /* * If this is blocking socket and we got EAGAIN, this * means the request timed out. Translate errno to diff --git a/sbin/hastd/proto_socketpair.c b/sbin/hastd/proto_socketpair.c index 913d59c..d13caa9 100644 --- a/sbin/hastd/proto_socketpair.c +++ b/sbin/hastd/proto_socketpair.c @@ -70,7 +70,7 @@ sp_client(const char *srcaddr, const char *dstaddr, void **ctxp) if (spctx == NULL) return (errno); - if (socketpair(PF_UNIX, SOCK_STREAM, 0, spctx->sp_fd) < 0) { + if (socketpair(PF_UNIX, SOCK_STREAM, 0, spctx->sp_fd) == -1) { ret = errno; free(spctx); return (ret); diff --git a/sbin/hastd/proto_tcp.c b/sbin/hastd/proto_tcp.c index 44eb13b..6dc0661 100644 --- a/sbin/hastd/proto_tcp.c +++ b/sbin/hastd/proto_tcp.c @@ -151,7 +151,7 @@ tcp_addr(const char *addr, int defport, struct sockaddr_storage *sap) /* Port not given, use the default. */ port = defport; } else { - if (numfromstr(pp + 1, 1, 65535, &port) < 0) + if (numfromstr(pp + 1, 1, 65535, &port) == -1) return (errno); } (void)snprintf(portstr, sizeof(portstr), "%jd", (intmax_t)port); @@ -275,7 +275,7 @@ tcp_client(const char *srcaddr, const char *dstaddr, void **ctxp) tcp_close(tctx); return (ret); } - if (bind(tctx->tc_fd, (struct sockaddr *)&sa, sa.ss_len) < 0) { + if (bind(tctx->tc_fd, (struct sockaddr *)&sa, sa.ss_len) == -1) { ret = errno; tcp_close(tctx); return (ret); @@ -423,12 +423,12 @@ tcp_server(const char *addr, void **ctxp) PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); if (bind(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sa, - tctx->tc_sa.ss_len) < 0) { + tctx->tc_sa.ss_len) == -1) { ret = errno; tcp_close(tctx); return (ret); } - if (listen(tctx->tc_fd, 8) < 0) { + if (listen(tctx->tc_fd, 8) == -1) { ret = errno; tcp_close(tctx); return (ret); @@ -458,7 +458,7 @@ tcp_accept(void *ctx, void **newctxp) fromlen = tctx->tc_sa.ss_len; newtctx->tc_fd = accept(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sa, &fromlen); - if (newtctx->tc_fd < 0) { + if (newtctx->tc_fd == -1) { ret = errno; free(newtctx); return (ret); @@ -530,7 +530,7 @@ tcp_address_match(const void *ctx, const char *addr) return (false); salen = sizeof(sa2); - if (getpeername(tctx->tc_fd, (struct sockaddr *)&sa2, &salen) < 0) + if (getpeername(tctx->tc_fd, (struct sockaddr *)&sa2, &salen) == -1) return (false); if (sa1.ss_family != sa2.ss_family || sa1.ss_len != sa2.ss_len) @@ -573,7 +573,7 @@ tcp_local_address(const void *ctx, char *addr, size_t size) PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); salen = sizeof(sa); - if (getsockname(tctx->tc_fd, (struct sockaddr *)&sa, &salen) < 0) { + if (getsockname(tctx->tc_fd, (struct sockaddr *)&sa, &salen) == -1) { PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } @@ -591,7 +591,7 @@ tcp_remote_address(const void *ctx, char *addr, size_t size) PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); salen = sizeof(sa); - if (getpeername(tctx->tc_fd, (struct sockaddr *)&sa, &salen) < 0) { + if (getpeername(tctx->tc_fd, (struct sockaddr *)&sa, &salen) == -1) { PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } diff --git a/sbin/hastd/proto_uds.c b/sbin/hastd/proto_uds.c index 9dd5303..087b788 100644 --- a/sbin/hastd/proto_uds.c +++ b/sbin/hastd/proto_uds.c @@ -144,7 +144,7 @@ uds_connect(void *ctx, int timeout) PJDLOG_ASSERT(timeout >= -1); if (connect(uctx->uc_fd, (struct sockaddr *)&uctx->uc_sun, - sizeof(uctx->uc_sun)) < 0) { + sizeof(uctx->uc_sun)) == -1) { return (errno); } @@ -179,13 +179,13 @@ uds_server(const char *addr, void **ctxp) (void)unlink(uctx->uc_sun.sun_path); if (bind(uctx->uc_fd, (struct sockaddr *)&uctx->uc_sun, - sizeof(uctx->uc_sun)) < 0) { + sizeof(uctx->uc_sun)) == -1) { ret = errno; uds_close(uctx); return (ret); } uctx->uc_owner = getpid(); - if (listen(uctx->uc_fd, 8) < 0) { + if (listen(uctx->uc_fd, 8) == -1) { ret = errno; uds_close(uctx); return (ret); @@ -214,7 +214,7 @@ uds_accept(void *ctx, void **newctxp) fromlen = sizeof(newuctx->uc_sun); newuctx->uc_fd = accept(uctx->uc_fd, (struct sockaddr *)&newuctx->uc_sun, &fromlen); - if (newuctx->uc_fd < 0) { + if (newuctx->uc_fd == -1) { ret = errno; free(newuctx); return (ret); @@ -274,7 +274,7 @@ uds_local_address(const void *ctx, char *addr, size_t size) PJDLOG_ASSERT(addr != NULL); sunlen = sizeof(sun); - if (getsockname(uctx->uc_fd, (struct sockaddr *)&sun, &sunlen) < 0) { + if (getsockname(uctx->uc_fd, (struct sockaddr *)&sun, &sunlen) == -1) { PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } @@ -298,7 +298,7 @@ uds_remote_address(const void *ctx, char *addr, size_t size) PJDLOG_ASSERT(addr != NULL); sunlen = sizeof(sun); - if (getpeername(uctx->uc_fd, (struct sockaddr *)&sun, &sunlen) < 0) { + if (getpeername(uctx->uc_fd, (struct sockaddr *)&sun, &sunlen) == -1) { PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c index 16f92b1..c7e2ab8 100644 --- a/sbin/hastd/secondary.c +++ b/sbin/hastd/secondary.c @@ -181,7 +181,7 @@ static void init_local(struct hast_resource *res) { - if (metadata_read(res, true) < 0) + if (metadata_read(res, true) == -1) exit(EX_NOINPUT); } @@ -262,7 +262,7 @@ init_remote(struct hast_resource *res, struct nv *nvin) */ PJDLOG_ASSERT(res->hr_secondary_localcnt == 0); res->hr_resuid = resuid; - if (metadata_write(res) < 0) + if (metadata_write(res) == -1) exit(EX_NOINPUT); if (nv_exists(nvin, "virgin")) { free(map); @@ -282,7 +282,7 @@ init_remote(struct hast_resource *res, struct nv *nvin) (uintmax_t)resuid, (uintmax_t)res->hr_resuid); pjdlog_error("%s", errmsg); nv_add_string(nvout, errmsg, "errmsg"); - if (hast_proto_send(res, res->hr_remotein, nvout, NULL, 0) < 0) { + if (hast_proto_send(res, res->hr_remotein, nvout, NULL, 0) == -1) { pjdlog_exit(EX_TEMPFAIL, "Unable to send response to %s", res->hr_remoteaddr); } @@ -327,7 +327,7 @@ init_remote(struct hast_resource *res, struct nv *nvin) free(map); pjdlog_error("Split-brain detected, exiting."); nv_add_string(nvout, "Split-brain condition!", "errmsg"); - if (hast_proto_send(res, res->hr_remotein, nvout, NULL, 0) < 0) { + if (hast_proto_send(res, res->hr_remotein, nvout, NULL, 0) == -1) { pjdlog_exit(EX_TEMPFAIL, "Unable to send response to %s", res->hr_remoteaddr); } @@ -361,7 +361,7 @@ init_remote(struct hast_resource *res, struct nv *nvin) (uintmax_t)res->hr_secondary_remotecnt); } nv_add_uint32(nvout, (uint32_t)mapsize, "mapsize"); - if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) < 0) { + if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) == -1) { pjdlog_exit(EX_TEMPFAIL, "Unable to send activemap to %s", res->hr_remoteaddr); } @@ -386,7 +386,7 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin) /* * Create communication channel between parent and child. */ - if (proto_client(NULL, "socketpair://", &res->hr_ctrl) < 0) { + if (proto_client(NULL, "socketpair://", &res->hr_ctrl) == -1) { KEEP_ERRNO((void)pidfile_remove(pfh)); pjdlog_exit(EX_OSERR, "Unable to create control sockets between parent and child"); @@ -394,7 +394,7 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin) /* * Create communication channel between child and parent. */ - if (proto_client(NULL, "socketpair://", &res->hr_event) < 0) { + if (proto_client(NULL, "socketpair://", &res->hr_event) == -1) { KEEP_ERRNO((void)pidfile_remove(pfh)); pjdlog_exit(EX_OSERR, "Unable to create event sockets between child and parent"); @@ -441,9 +441,9 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin) PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); /* Error in setting timeout is not critical, but why should it fail? */ - if (proto_timeout(res->hr_remotein, 2 * HAST_KEEPALIVE) < 0) + if (proto_timeout(res->hr_remotein, 2 * HAST_KEEPALIVE) == -1) pjdlog_errno(LOG_WARNING, "Unable to set connection timeout"); - if (proto_timeout(res->hr_remoteout, res->hr_timeout) < 0) + if (proto_timeout(res->hr_remoteout, res->hr_timeout) == -1) pjdlog_errno(LOG_WARNING, "Unable to set connection timeout"); init_local(res); @@ -623,7 +623,7 @@ recv_thread(void *arg) pjdlog_debug(2, "recv: Taking free request."); QUEUE_TAKE(free, hio); pjdlog_debug(2, "recv: (%p) Got request.", hio); - if (hast_proto_recv_hdr(res->hr_remotein, &nv) < 0) { + if (hast_proto_recv_hdr(res->hr_remotein, &nv) == -1) { secondary_exit(EX_TEMPFAIL, "Unable to receive request header"); } @@ -666,7 +666,7 @@ recv_thread(void *arg) continue; } else if (hio->hio_cmd == HIO_WRITE) { if (hast_proto_recv_data(res, res->hr_remotein, nv, - hio->hio_data, MAXPHYS) < 0) { + hio->hio_data, MAXPHYS) == -1) { secondary_exit(EX_TEMPFAIL, "Unable to receive request data"); } @@ -735,7 +735,7 @@ disk_thread(void *arg) ret = pread(res->hr_localfd, hio->hio_data, hio->hio_length, hio->hio_offset + res->hr_localoff); - if (ret < 0) + if (ret == -1) hio->hio_error = errno; else if (ret != (int64_t)hio->hio_length) hio->hio_error = EIO; @@ -746,7 +746,7 @@ disk_thread(void *arg) ret = pwrite(res->hr_localfd, hio->hio_data, hio->hio_length, hio->hio_offset + res->hr_localoff); - if (ret < 0) + if (ret == -1) hio->hio_error = errno; else if (ret != (int64_t)hio->hio_length) hio->hio_error = EIO; @@ -757,7 +757,7 @@ disk_thread(void *arg) ret = g_delete(res->hr_localfd, hio->hio_offset + res->hr_localoff, hio->hio_length); - if (ret < 0) + if (ret == -1) hio->hio_error = errno; else hio->hio_error = 0; @@ -770,7 +770,7 @@ disk_thread(void *arg) break; } ret = g_flush(res->hr_localfd); - if (ret < 0) { + if (ret == -1) { if (errno == EOPNOTSUPP) res->hr_localflush = false; hio->hio_error = errno; @@ -837,7 +837,7 @@ send_thread(void *arg) if (hio->hio_error != 0) nv_add_int16(nvout, hio->hio_error, "error"); if (hast_proto_send(res, res->hr_remoteout, nvout, data, - length) < 0) { + length) == -1) { secondary_exit(EX_TEMPFAIL, "Unable to send reply."); } nv_free(nvout); diff --git a/sbin/hastd/subr.c b/sbin/hastd/subr.c index b8ee389..ae6f984 100644 --- a/sbin/hastd/subr.c +++ b/sbin/hastd/subr.c @@ -86,13 +86,13 @@ provinfo(struct hast_resource *res, bool dowrite) if (res->hr_localfd == -1) { res->hr_localfd = open(res->hr_localpath, dowrite ? O_RDWR : O_RDONLY); - if (res->hr_localfd < 0) { + if (res->hr_localfd == -1) { pjdlog_errno(LOG_ERR, "Unable to open %s", res->hr_localpath); return (-1); } } - if (fstat(res->hr_localfd, &sb) < 0) { + if (fstat(res->hr_localfd, &sb) == -1) { pjdlog_errno(LOG_ERR, "Unable to stat %s", res->hr_localpath); return (-1); } @@ -101,14 +101,14 @@ provinfo(struct hast_resource *res, bool dowrite) * If this is character device, it is most likely GEOM provider. */ if (ioctl(res->hr_localfd, DIOCGMEDIASIZE, - &res->hr_local_mediasize) < 0) { + &res->hr_local_mediasize) == -1) { pjdlog_errno(LOG_ERR, "Unable obtain provider %s mediasize", res->hr_localpath); return (-1); } if (ioctl(res->hr_localfd, DIOCGSECTORSIZE, - &res->hr_local_sectorsize) < 0) { + &res->hr_local_sectorsize) == -1) { pjdlog_errno(LOG_ERR, "Unable obtain provider %s sectorsize", res->hr_localpath); |