Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Feb 2012 15:51:19 +0000 (UTC)
From:      Mikolaj Golub <trociny@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r231017 - in stable/9/sbin: hastctl hastd
Message-ID:  <201202051551.q15FpJJ7089415@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trociny
Date: Sun Feb  5 15:51:19 2012
New Revision: 231017
URL: http://svn.freebsd.org/changeset/base/231017

Log:
  MFC r229699, r229744, r229778, r229944, r229945, r229946, r230092, r230395,
    r230396, r230436, r230457, r230515, r230976:
  
  r229744 (pjd):
  
  fork(2) returns -1 on failure, not some random negative number.
  
  r229699 (pjd):
  
  Constify argument.
  
  r229778 (uqs):
  
  Spelling fixes for sbin/
  
  r229944 (pjd):
  
  Don't touch pidfiles when running in foreground. Before that change we
  would create an empty pidfile on start and check if it changed on SIGHUP.
  
  r229945 (pjd):
  
  For functions that return -1 on failure check exactly for -1 and not for
  any negative number.
  
  r229946 (pjd):
  
  - Fix a bug where pidfile was removed in SIGHUP when it hasn't changed in
    configuration file.
  - Log the fact that pidfile has changed.
  
  r230092 (pjd):
  
  Style cleanups.
  
  r230395 (pjd):
  
  Remove unused token 'port'.
  
  r230396 (pjd):
  
  Remove another unused token.
  
  r230436 (pjd):
  
  Fix minor memory leak.
  
  r230457 (pjd):
  
  Free memory that won't be used in child.
  
  r230515 (pjd):
  
  - Fix documentation to note that /etc/hast.conf is the default configuration
    file for hastd(8) and hastctl(8) and not hast.conf.
  - In copyright statement correct that this file is documentation, not software.
  - Bump date.
  
  r230976 (pjd):
  
  Fix typo in comment.

Modified:
  stable/9/sbin/hastctl/hastctl.8
  stable/9/sbin/hastctl/hastctl.c
  stable/9/sbin/hastd/activemap.c
  stable/9/sbin/hastd/control.c
  stable/9/sbin/hastd/ebuf.c
  stable/9/sbin/hastd/event.c
  stable/9/sbin/hastd/hast.conf.5
  stable/9/sbin/hastd/hast_compression.c
  stable/9/sbin/hastd/hast_proto.c
  stable/9/sbin/hastd/hastd.c
  stable/9/sbin/hastd/hooks.c
  stable/9/sbin/hastd/lzf.h
  stable/9/sbin/hastd/metadata.c
  stable/9/sbin/hastd/nv.c
  stable/9/sbin/hastd/parse.y
  stable/9/sbin/hastd/primary.c
  stable/9/sbin/hastd/proto.c
  stable/9/sbin/hastd/proto_common.c
  stable/9/sbin/hastd/proto_socketpair.c
  stable/9/sbin/hastd/proto_tcp.c
  stable/9/sbin/hastd/proto_uds.c
  stable/9/sbin/hastd/secondary.c
  stable/9/sbin/hastd/subr.c
  stable/9/sbin/hastd/subr.h
  stable/9/sbin/hastd/token.l
Directory Properties:
  stable/9/sbin/hastctl/   (props changed)
  stable/9/sbin/hastd/   (props changed)

Modified: stable/9/sbin/hastctl/hastctl.8
==============================================================================
--- stable/9/sbin/hastctl/hastctl.8	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastctl/hastctl.8	Sun Feb  5 15:51:19 2012	(r231017)
@@ -97,7 +97,7 @@ If extent size is too small, there will 
 related to dirty map updates, which will degrade performance of the
 given resource.
 If extent size is too large, synchronization, even in case of short
-outage, can take a long time increasing the risk of loosing up-to-date
+outage, can take a long time increasing the risk of losing up-to-date
 node before synchronization process is completed.
 The default extent size is
 .Va 2MB .

Modified: stable/9/sbin/hastctl/hastctl.c
==============================================================================
--- stable/9/sbin/hastctl/hastctl.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastctl/hastctl.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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: stable/9/sbin/hastd/activemap.c
==============================================================================
--- stable/9/sbin/hastd/activemap.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/activemap.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -219,7 +219,7 @@ keepdirty_add(struct activemap *amp, int
 	kd = keepdirty_find(amp, extent);
 	if (kd != NULL) {
 		/*
-		 * Only move element at the begining.
+		 * Only move element at the beginning.
 		 */
 		TAILQ_REMOVE(&amp->am_keepdirty, kd, kd_next);
 		TAILQ_INSERT_HEAD(&amp->am_keepdirty, kd, kd_next);
@@ -573,7 +573,7 @@ activemap_sync_rewind(struct activemap *
 		return;
 	}
 	/*
-	 * Mark that we want to start synchronization from the begining.
+	 * Mark that we want to start synchronization from the beginning.
 	 */
 	amp->am_syncoff = -1;
 }

Modified: stable/9/sbin/hastd/control.c
==============================================================================
--- stable/9/sbin/hastd/control.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/control.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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: stable/9/sbin/hastd/ebuf.c
==============================================================================
--- stable/9/sbin/hastd/ebuf.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/ebuf.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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: stable/9/sbin/hastd/event.c
==============================================================================
--- stable/9/sbin/hastd/event.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/event.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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: stable/9/sbin/hastd/hast.conf.5
==============================================================================
--- stable/9/sbin/hastd/hast.conf.5	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/hast.conf.5	Sun Feb  5 15:51:19 2012	(r231017)
@@ -1,8 +1,8 @@
 .\" Copyright (c) 2010 The FreeBSD Foundation
-.\" Copyright (c) 2010-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
+.\" Copyright (c) 2010-2012 Pawel Jakub Dawidek <pawel@dawidek.net>
 .\" All rights reserved.
 .\"
-.\" This software was developed by Pawel Jakub Dawidek under sponsorship from
+.\" This documentation was written by Pawel Jakub Dawidek under sponsorship from
 .\" the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 27, 2011
+.Dd January 25, 2012
 .Dt HAST.CONF 5
 .Os
 .Sh NAME
@@ -389,7 +389,9 @@ statement.
 .Bl -tag -width ".Pa /var/run/hastctl" -compact
 .It Pa /etc/hast.conf
 The default
-.Nm
+.Xr hastctl 8
+and
+.Xr hastd 8
 configuration file.
 .It Pa /var/run/hastctl
 Control socket used by the

Modified: stable/9/sbin/hastd/hast_compression.c
==============================================================================
--- stable/9/sbin/hastd/hast_compression.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/hast_compression.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -55,7 +55,7 @@ allzeros(const void *data, size_t size)
 	 * Because inside the loop we don't check at every step, we would
 	 * get an answer only after walking through entire buffer.
 	 * To return early if the buffer doesn't contain all zeros, we probe
-	 * 8 bytes at the begining, in the middle and at the end of the buffer
+	 * 8 bytes at the beginning, in the middle and at the end of the buffer
 	 * first.
 	 */
 

Modified: stable/9/sbin/hastd/hast_proto.c
==============================================================================
--- stable/9/sbin/hastd/hast_proto.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/hast_proto.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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: stable/9/sbin/hastd/hastd.c
==============================================================================
--- stable/9/sbin/hastd/hastd.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/hastd.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -68,6 +68,8 @@ static struct hastd_config *cfg;
 bool sigexit_received = false;
 /* PID file handle. */
 struct pidfh *pfh;
+/* Do we run in foreground? */
+static bool foreground;
 
 /* How often check for hooks running for too long. */
 #define	REPORT_INTERVAL	5
@@ -97,10 +99,10 @@ g_gate_load(void)
 void
 descriptors_cleanup(struct hast_resource *res)
 {
-	struct hast_resource *tres;
+	struct hast_resource *tres, *tmres;
 	struct hastd_listen *lst;
 
-	TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) {
+	TAILQ_FOREACH_SAFE(tres, &cfg->hc_resources, hr_next, tmres) {
 		if (tres == res) {
 			PJDLOG_VERIFY(res->hr_role == HAST_ROLE_SECONDARY ||
 			    (res->hr_remotein == NULL &&
@@ -117,13 +119,17 @@ descriptors_cleanup(struct hast_resource
 			proto_close(tres->hr_event);
 		if (tres->hr_conn != NULL)
 			proto_close(tres->hr_conn);
+		TAILQ_REMOVE(&cfg->hc_resources, tres, hr_next);
+		free(tres);
 	}
 	if (cfg->hc_controlin != NULL)
 		proto_close(cfg->hc_controlin);
 	proto_close(cfg->hc_controlconn);
-	TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) {
+	while ((lst = TAILQ_FIRST(&cfg->hc_listen)) != NULL) {
+		TAILQ_REMOVE(&cfg->hc_listen, lst, hl_next);
 		if (lst->hl_conn != NULL)
 			proto_close(lst->hl_conn);
+		free(lst);
 	}
 	(void)pidfile_close(pfh);
 	hook_fini();
@@ -172,7 +178,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));
@@ -450,7 +456,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;
@@ -458,7 +464,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;
 	}
@@ -494,7 +500,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);
@@ -531,7 +537,7 @@ hastd_reload(void)
 	/*
 	 * Check if pidfile's path has changed.
 	 */
-	if (strcmp(cfg->hc_pidfile, newcfg->hc_pidfile) != 0) {
+	if (!foreground && strcmp(cfg->hc_pidfile, newcfg->hc_pidfile) != 0) {
 		newpfh = pidfile_open(newcfg->hc_pidfile, 0600, &otherpid);
 		if (newpfh == NULL) {
 			if (errno == EEXIST) {
@@ -543,7 +549,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",
@@ -571,10 +577,14 @@ hastd_reload(void)
 	/*
 	 * Switch to new pidfile.
 	 */
-	(void)pidfile_remove(pfh);
-	pfh = newpfh;
-	(void)strlcpy(cfg->hc_pidfile, newcfg->hc_pidfile,
-	    sizeof(cfg->hc_pidfile));
+	if (newpfh != NULL) {
+		pjdlog_info("Pidfile changed from %s to %s.", cfg->hc_pidfile,
+		    newcfg->hc_pidfile);
+		(void)pidfile_remove(pfh);
+		pfh = newpfh;
+		(void)strlcpy(cfg->hc_pidfile, newcfg->hc_pidfile,
+		    sizeof(cfg->hc_pidfile));
+	}
 	/*
 	 * Switch to new listen addresses. Close all that were removed.
 	 */
@@ -742,7 +752,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;
 	}
@@ -752,7 +762,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;
@@ -771,7 +781,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;
@@ -786,7 +796,7 @@ listen_accept(struct hastd_listen *lst)
 	pjdlog_debug(2, "%s: resource=%s", raddr, resname);
 	token = nv_get_uint8_array(nvin, &size, "token");
 	/*
-	 * NULL token means that this is first conection.
+	 * NULL token means that this is first connection.
 	 */
 	if (token != NULL && size != sizeof(res->hr_token)) {
 		pjdlog_error("Received token of invalid size from %s (expected %zu, got %zu).",
@@ -859,7 +869,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);
@@ -909,7 +919,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",
@@ -938,7 +948,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;
 	}
@@ -963,20 +973,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);
@@ -985,11 +995,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", "");
@@ -1155,7 +1165,6 @@ main(int argc, char *argv[])
 	struct hastd_listen *lst;
 	const char *pidfile;
 	pid_t otherpid;
-	bool foreground;
 	int debuglevel;
 	sigset_t mask;
 
@@ -1220,16 +1229,23 @@ main(int argc, char *argv[])
 			pjdlog_exitx(EX_CONFIG, "Pidfile path is too long.");
 		}
 	}
-	pfh = pidfile_open(cfg->hc_pidfile, 0600, &otherpid);
-	if (pfh == NULL) {
-		if (errno == EEXIST) {
-			pjdlog_exitx(EX_TEMPFAIL,
-			    "Another hastd is already running, pidfile: %s, pid: %jd.",
-			    cfg->hc_pidfile, (intmax_t)otherpid);
-		}
-		/* If we cannot create pidfile for other reasons, only warn. */
-		pjdlog_errno(LOG_WARNING, "Unable to open or create pidfile %s",
-		    cfg->hc_pidfile);
+
+	if (!foreground) {
+		pfh = pidfile_open(cfg->hc_pidfile, 0600, &otherpid);
+		if (pfh == NULL) {
+			if (errno == EEXIST) {
+				pjdlog_exitx(EX_TEMPFAIL,
+				    "Another hastd is already running, pidfile: %s, pid: %jd.",
+				    cfg->hc_pidfile, (intmax_t)otherpid);
+			}
+			/*
+			 * If we cannot create pidfile for other reasons,
+			 * only warn.
+			 */
+			pjdlog_errno(LOG_WARNING,
+			    "Unable to open or create pidfile %s",
+			    cfg->hc_pidfile);
+		}
 	}
 
 	/*
@@ -1253,14 +1269,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);
@@ -1268,7 +1284,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");
 		}
@@ -1277,7 +1293,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: stable/9/sbin/hastd/hooks.c
==============================================================================
--- stable/9/sbin/hastd/hooks.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/hooks.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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: stable/9/sbin/hastd/lzf.h
==============================================================================
--- stable/9/sbin/hastd/lzf.h	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/lzf.h	Sun Feb  5 15:51:19 2012	(r231017)
@@ -146,7 +146,7 @@ lzf_decompress (const void *const in_dat
 
 /*
  * Avoid assigning values to errno variable? for some embedding purposes
- * (linux kernel for example), this is neccessary. NOTE: this breaks
+ * (linux kernel for example), this is necessary. NOTE: this breaks
  * the documentation in lzf.h.
  */
 #ifndef AVOID_ERRNO
@@ -167,7 +167,7 @@ lzf_decompress (const void *const in_dat
  * and return EINVAL if the input stream has been corrupted. This
  * only shields against overflowing the input buffer and will not
  * detect most corrupted streams.
- * This check is not normally noticable on modern hardware
+ * This check is not normally noticeable on modern hardware
  * (<1% slowdown), but might slow down older cpus considerably.
  */
 #ifndef CHECK_INPUT

Modified: stable/9/sbin/hastd/metadata.c
==============================================================================
--- stable/9/sbin/hastd/metadata.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/metadata.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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: stable/9/sbin/hastd/nv.c
==============================================================================
--- stable/9/sbin/hastd/nv.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/nv.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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: stable/9/sbin/hastd/parse.y
==============================================================================
--- stable/9/sbin/hastd/parse.y	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/parse.y	Sun Feb  5 15:51:19 2012	(r231017)
@@ -85,7 +85,7 @@ isitme(const char *name)
 	size_t bufsize;
 
 	/*
-	 * First check if the give name matches our full hostname.
+	 * First check if the given name matches our full hostname.
 	 */
 	if (gethostname(buf, sizeof(buf)) < 0) {
 		pjdlog_errno(LOG_ERR, "gethostname() failed");
@@ -369,8 +369,8 @@ yy_config_free(struct hastd_config *conf
 }
 %}
 
-%token CONTROL PIDFILE LISTEN PORT REPLICATION CHECKSUM COMPRESSION METAFLUSH
-%token TIMEOUT EXEC EXTENTSIZE RESOURCE NAME LOCAL REMOTE SOURCE ON OFF
+%token CONTROL PIDFILE LISTEN REPLICATION CHECKSUM COMPRESSION METAFLUSH
+%token TIMEOUT EXEC RESOURCE NAME LOCAL REMOTE SOURCE ON OFF
 %token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256 HOLE LZF
 %token NUM STR OB CB
 
@@ -812,6 +812,7 @@ resource_start:	STR
 		    sizeof(curres->hr_name)) >=
 		    sizeof(curres->hr_name)) {
 			pjdlog_error("Resource name is too long.");
+			free(curres);
 			free($1);
 			return (1);
 		}

Modified: stable/9/sbin/hastd/primary.c
==============================================================================
--- stable/9/sbin/hastd/primary.c	Sun Feb  5 15:23:32 2012	(r231016)
+++ stable/9/sbin/hastd/primary.c	Sun Feb  5 15:51:19 2012	(r231017)
@@ -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,
@@ -886,7 +886,7 @@ hastd_primary(struct hast_resource *res)
 	}
 
 	pid = fork();
-	if (pid < 0) {
+	if (pid == -1) {
 		/* TODO: There's no need for this to be fatal error. */
 		KEEP_ERRNO((void)pidfile_remove(pfh));
 		pjdlog_exit(EX_TEMPFAIL, "Unable to fork");
@@ -933,7 +933,7 @@ hastd_primary(struct hast_resource *res)
 
 	/*
 	 * Create the guard thread first, so we can handle signals from the
-	 * very begining.
+	 * very beginning.
 	 */
 	error = pthread_create(&td, NULL, guard_thread, res);
 	PJDLOG_ASSERT(error == 0);
@@ -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)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202051551.q15FpJJ7089415>