From owner-svn-src-all@FreeBSD.ORG Tue Jan 10 22:39:08 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40F16106566C; Tue, 10 Jan 2012 22:39:08 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2E3108FC13; Tue, 10 Jan 2012 22:39:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0AMd8tJ030652; Tue, 10 Jan 2012 22:39:08 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0AMd8i6030635; Tue, 10 Jan 2012 22:39:08 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201201102239.q0AMd8i6030635@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 10 Jan 2012 22:39:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r229945 - in head/sbin: hastctl hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2012 22:39:08 -0000 Author: pjd Date: Tue Jan 10 22:39:07 2012 New Revision: 229945 URL: http://svn.freebsd.org/changeset/base/229945 Log: For functions that return -1 on failure check exactly for -1 and not for any negative number. MFC after: 3 days Modified: head/sbin/hastctl/hastctl.c head/sbin/hastd/control.c head/sbin/hastd/ebuf.c head/sbin/hastd/event.c head/sbin/hastd/hast_proto.c head/sbin/hastd/hastd.c head/sbin/hastd/hooks.c head/sbin/hastd/metadata.c head/sbin/hastd/nv.c head/sbin/hastd/primary.c head/sbin/hastd/proto.c head/sbin/hastd/proto_common.c head/sbin/hastd/proto_socketpair.c head/sbin/hastd/proto_tcp.c head/sbin/hastd/proto_uds.c head/sbin/hastd/secondary.c head/sbin/hastd/subr.c Modified: head/sbin/hastctl/hastctl.c ============================================================================== --- head/sbin/hastctl/hastctl.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastctl/hastctl.c Tue Jan 10 22:39:07 2012 (r229945) @@ -104,7 +104,7 @@ create_one(struct hast_resource *res, in ec = 0; pjdlog_prefix_set("[%s] ", res->hr_name); - if (provinfo(res, true) < 0) { + if (provinfo(res, true) == -1) { ec = EX_NOINPUT; goto end; } @@ -146,7 +146,7 @@ create_one(struct hast_resource *res, in res->hr_localoff = METADATA_SIZE + mapsize; - if (metadata_write(res) < 0) { + if (metadata_write(res) == -1) { ec = EX_IOERR; goto end; } @@ -401,15 +401,15 @@ main(int argc, char *argv[]) debug++; break; case 'e': - if (expand_number(optarg, &extentsize) < 0) + if (expand_number(optarg, &extentsize) == -1) errx(EX_USAGE, "Invalid extentsize"); break; case 'k': - if (expand_number(optarg, &keepdirty) < 0) + if (expand_number(optarg, &keepdirty) == -1) errx(EX_USAGE, "Invalid keepdirty"); break; case 'm': - if (expand_number(optarg, &mediasize) < 0) + if (expand_number(optarg, &mediasize) == -1) errx(EX_USAGE, "Invalid mediasize"); break; case 'h': @@ -479,13 +479,13 @@ main(int argc, char *argv[]) } /* Setup control connection... */ - if (proto_client(NULL, cfg->hc_controladdr, &controlconn) < 0) { + if (proto_client(NULL, cfg->hc_controladdr, &controlconn) == -1) { pjdlog_exit(EX_OSERR, "Unable to setup control connection to %s", cfg->hc_controladdr); } /* ...and connect to hastd. */ - if (proto_connect(controlconn, HAST_TIMEOUT) < 0) { + if (proto_connect(controlconn, HAST_TIMEOUT) == -1) { pjdlog_exit(EX_OSERR, "Unable to connect to hastd via %s", cfg->hc_controladdr); } @@ -494,14 +494,14 @@ main(int argc, char *argv[]) exit(EX_CONFIG); /* Send the command to the server... */ - if (hast_proto_send(NULL, controlconn, nv, NULL, 0) < 0) { + if (hast_proto_send(NULL, controlconn, nv, NULL, 0) == -1) { pjdlog_exit(EX_UNAVAILABLE, "Unable to send command to hastd via %s", cfg->hc_controladdr); } nv_free(nv); /* ...and receive reply. */ - if (hast_proto_recv_hdr(controlconn, &nv) < 0) { + if (hast_proto_recv_hdr(controlconn, &nv) == -1) { pjdlog_exit(EX_UNAVAILABLE, "cannot receive reply from hastd via %s", cfg->hc_controladdr); Modified: head/sbin/hastd/control.c ============================================================================== --- head/sbin/hastd/control.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/control.c Tue Jan 10 22:39:07 2012 (r229945) @@ -115,7 +115,7 @@ control_set_role_common(struct hastd_con * 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_resour "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_resour /* * 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"); } Modified: head/sbin/hastd/ebuf.c ============================================================================== --- head/sbin/hastd/ebuf.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/ebuf.c Tue Jan 10 22:39:07 2012 (r229945) @@ -116,7 +116,7 @@ ebuf_add_head(struct ebuf *eb, const voi * 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 voi * 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 <= Modified: head/sbin/hastd/event.c ============================================================================== --- head/sbin/hastd/event.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/event.c Tue Jan 10 22:39:07 2012 (r229945) @@ -61,11 +61,11 @@ event_send(const struct hast_resource *r "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 *r 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 *r "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; } Modified: head/sbin/hastd/hast_proto.c ============================================================================== --- head/sbin/hastd/hast_proto.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/hast_proto.c Tue Jan 10 22:39:07 2012 (r229945) @@ -114,13 +114,13 @@ hast_proto_send(const struct hast_resour 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_c 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_c 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_r } 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--) { Modified: head/sbin/hastd/hastd.c ============================================================================== --- head/sbin/hastd/hastd.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/hastd.c Tue Jan 10 22:39:07 2012 (r229945) @@ -174,7 +174,7 @@ descriptors_assert(const struct hast_res 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_resour 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_resour 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 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 } 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); Modified: head/sbin/hastd/hooks.c ============================================================================== --- head/sbin/hastd/hooks.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/hooks.c Tue Jan 10 22:39:07 2012 (r229945) @@ -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"); } Modified: head/sbin/hastd/metadata.c ============================================================================== --- head/sbin/hastd/metadata.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/metadata.c Tue Jan 10 22:39:07 2012 (r229945) @@ -61,14 +61,14 @@ metadata_read(struct hast_resource *res, * 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, "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, 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; } Modified: head/sbin/hastd/nv.c ============================================================================== --- head/sbin/hastd/nv.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/nv.c Tue Jan 10 22:39:07 2012 (r229945) @@ -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 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 cha 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 cha } 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 cha 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; Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/primary.c Tue Jan 10 22:39:07 2012 (r229945) @@ -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 *re 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 *re 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, s 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, s 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, s 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, s 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, s * 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 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 "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_resour } 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"); } Modified: head/sbin/hastd/proto.c ============================================================================== --- head/sbin/hastd/proto.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/proto.c Tue Jan 10 22:39:07 2012 (r229945) @@ -419,14 +419,14 @@ proto_timeout(const struct proto_conn *c 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); Modified: head/sbin/hastd/proto_common.c ============================================================================== --- head/sbin/hastd/proto_common.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/proto_common.c Tue Jan 10 22:39:07 2012 (r229945) @@ -116,7 +116,7 @@ proto_common_send(int sock, const unsign 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 cha } 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 Modified: head/sbin/hastd/proto_socketpair.c ============================================================================== --- head/sbin/hastd/proto_socketpair.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/proto_socketpair.c Tue Jan 10 22:39:07 2012 (r229945) @@ -70,7 +70,7 @@ sp_client(const char *srcaddr, const cha 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); Modified: head/sbin/hastd/proto_tcp.c ============================================================================== --- head/sbin/hastd/proto_tcp.c Tue Jan 10 22:24:57 2012 (r229944) +++ head/sbin/hastd/proto_tcp.c Tue Jan 10 22:39:07 2012 (r229945) @@ -151,7 +151,7 @@ tcp_addr(const char *addr, int defport, /* 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 ch 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 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 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 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) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***