summaryrefslogtreecommitdiffstats
path: root/sbin/ggate
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-09-08 07:57:14 +0000
committerpjd <pjd@FreeBSD.org>2004-09-08 07:57:14 +0000
commit456c69d9279b3d7be52f54e49798af226c808977 (patch)
treed26ef4e341905a0fbddc773046d8074752d69827 /sbin/ggate
parent772c5279be6bb55eca2f8e98e29a8f725c93c01d (diff)
downloadFreeBSD-src-456c69d9279b3d7be52f54e49798af226c808977.zip
FreeBSD-src-456c69d9279b3d7be52f54e49798af226c808977.tar.gz
Fix/clean up return values checking.
Diffstat (limited to 'sbin/ggate')
-rw-r--r--sbin/ggate/ggatec/ggatec.c18
-rw-r--r--sbin/ggate/ggated/ggated.c22
-rw-r--r--sbin/ggate/ggatel/ggatel.c6
-rw-r--r--sbin/ggate/shared/ggate.c16
4 files changed, 31 insertions, 31 deletions
diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c
index bb598e6..84aa60e 100644
--- a/sbin/ggate/ggatec/ggatec.c
+++ b/sbin/ggate/ggatec/ggatec.c
@@ -103,7 +103,7 @@ handshake(void)
}
serv.sin_port = htons(port);
sfd = socket(AF_INET, SOCK_STREAM, 0);
- if (sfd < 0)
+ if (sfd == -1)
g_gate_xlog("Can't open socket: %s.", strerror(errno));
/*
* Some trivial network optimalization.
@@ -113,23 +113,23 @@ handshake(void)
int on = 1;
if (setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, &on,
- sizeof(on)) < 0) {
+ sizeof(on)) == -1) {
g_gate_xlog("setsockopt() error: %s.", strerror(errno));
}
}
bsize = rcvbuf;
- if (setsockopt(sfd, SOL_SOCKET, SO_RCVBUF, &bsize, sizeof(bsize)))
+ if (setsockopt(sfd, SOL_SOCKET, SO_RCVBUF, &bsize, sizeof(bsize)) == -1)
g_gate_xlog("setsockopt() error: %s.", strerror(errno));
bsize = sndbuf;
- if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bsize, sizeof(bsize)))
+ if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bsize, sizeof(bsize)) == -1)
g_gate_xlog("setsockopt() error: %s.", strerror(errno));
tv.tv_sec = timeout;
tv.tv_usec = 0;
- if (setsockopt(sfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) ||
- setsockopt(sfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
+ if (setsockopt(sfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1 ||
+ setsockopt(sfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
g_gate_xlog("setsockopt() error: %s.", strerror(errno));
}
- if (connect(sfd, (struct sockaddr *)&serv, sizeof(serv)) < 0) {
+ if (connect(sfd, (struct sockaddr *)&serv, sizeof(serv)) == -1) {
g_gate_log(LOG_ERR, "Can't connect to server: %s.",
strerror(errno));
return (-1);
@@ -294,7 +294,7 @@ serve_loop(int sfd)
if (error != EAGAIN)
g_gate_xlog("%s.", strerror(error));
sfd = handshake();
- if (sfd < 0) {
+ if (sfd == -1) {
sleep(2);
continue;
}
@@ -332,7 +332,7 @@ g_gatec_create(void)
int sfd;
sfd = handshake();
- if (sfd < 0)
+ if (sfd == -1)
exit(EXIT_FAILURE);
ggioc.gctl_version = G_GATE_VERSION;
ggioc.gctl_mediasize = mediasize;
diff --git a/sbin/ggate/ggated/ggated.c b/sbin/ggate/ggated/ggated.c
index e602bc8..a0628ea 100644
--- a/sbin/ggate/ggated/ggated.c
+++ b/sbin/ggate/ggated/ggated.c
@@ -575,14 +575,14 @@ main(int argc, char *argv[])
if (!g_gate_verbose) {
/* Run in daemon mode. */
- if (daemon(0, 0) < 0)
+ if (daemon(0, 0) == -1)
g_gate_xlog("Can't daemonize: %s", strerror(errno));
}
signal(SIGCHLD, SIG_IGN);
sfd = socket(AF_INET, SOCK_STREAM, 0);
- if (sfd < 0)
+ if (sfd == -1)
g_gate_xlog("Can't open stream socket: %s.", strerror(errno));
bzero(&serv, sizeof(serv));
serv.sin_family = AF_INET;
@@ -591,27 +591,27 @@ main(int argc, char *argv[])
on = 1;
if (nagle) {
if (setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, &on,
- sizeof(on)) < 0) {
+ sizeof(on)) == -1) {
g_gate_xlog("setsockopt() error: %s.", strerror(errno));
}
}
- if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
+ if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1)
g_gate_xlog("setsockopt(): %s.", strerror(errno));
bsize = rcvbuf;
- if (setsockopt(sfd, SOL_SOCKET, SO_RCVBUF, &bsize, sizeof(bsize)) < 0)
+ if (setsockopt(sfd, SOL_SOCKET, SO_RCVBUF, &bsize, sizeof(bsize)) == -1)
g_gate_xlog("setsockopt(): %s.", strerror(errno));
bsize = sndbuf;
- if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bsize, sizeof(bsize)) < 0)
+ if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bsize, sizeof(bsize)) == -1)
g_gate_xlog("setsockopt(): %s.", strerror(errno));
tv.tv_sec = 10;
tv.tv_usec = 0;
- if (setsockopt(sfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) ||
- setsockopt(sfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
+ if (setsockopt(sfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1 ||
+ setsockopt(sfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
g_gate_xlog("setsockopt() error: %s.", strerror(errno));
}
- if (bind(sfd, (struct sockaddr *)&serv, sizeof(serv)) < 0)
+ if (bind(sfd, (struct sockaddr *)&serv, sizeof(serv)) == -1)
g_gate_xlog("bind(): %s.", strerror(errno));
- if (listen(sfd, 5) < 0)
+ if (listen(sfd, 5) == -1)
g_gate_xlog("listen(): %s.", strerror(errno));
g_gate_log(LOG_INFO, "Listen on port: %d.", port);
@@ -621,7 +621,7 @@ main(int argc, char *argv[])
for (;;) {
fromlen = sizeof(from);
tmpsfd = accept(sfd, &from, &fromlen);
- if (tmpsfd < 0)
+ if (tmpsfd == -1)
g_gate_xlog("accept(): %s.", strerror(errno));
if (got_sighup) {
diff --git a/sbin/ggate/ggatel/ggatel.c b/sbin/ggate/ggatel/ggatel.c
index 01be38c..4aa19ea 100644
--- a/sbin/ggate/ggatel/ggatel.c
+++ b/sbin/ggate/ggatel/ggatel.c
@@ -77,7 +77,7 @@ g_gatel_serve(int fd)
size_t bsize;
if (g_gate_verbose == 0) {
- if (daemon(0, 0) < 0) {
+ if (daemon(0, 0) == -1) {
g_gate_destroy(unit, 1);
err(EXIT_FAILURE, "Cannot daemonize");
}
@@ -161,7 +161,7 @@ g_gatel_create(void)
int fd;
fd = open(path, g_gate_openflags(flags));
- if (fd < 0)
+ if (fd == -1)
err(EXIT_FAILURE, "Cannot open %s", path);
ggioc.gctl_version = G_GATE_VERSION;
ggioc.gctl_unit = unit;
@@ -186,7 +186,7 @@ g_gatel_attach(void)
int fd;
fd = open(path, g_gate_openflags(flags));
- if (fd < 0)
+ if (fd == -1)
err(EXIT_FAILURE, "Cannot open %s", path);
g_gatel_serve(fd);
}
diff --git a/sbin/ggate/shared/ggate.c b/sbin/ggate/shared/ggate.c
index 8eeef2f..08f13d7 100644
--- a/sbin/ggate/shared/ggate.c
+++ b/sbin/ggate/shared/ggate.c
@@ -133,10 +133,10 @@ g_gate_mediasize(int fd)
off_t mediasize;
struct stat sb;
- if (fstat(fd, &sb) < 0)
+ if (fstat(fd, &sb) == -1)
g_gate_xlog("fstat(): %s.", strerror(errno));
if (S_ISCHR(sb.st_mode)) {
- if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) < 0) {
+ if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) == -1) {
g_gate_xlog("Can't get media size: %s.",
strerror(errno));
}
@@ -154,10 +154,10 @@ g_gate_sectorsize(int fd)
size_t secsize;
struct stat sb;
- if (fstat(fd, &sb) < 0)
+ if (fstat(fd, &sb) == -1)
g_gate_xlog("fstat(): %s.", strerror(errno));
if (S_ISCHR(sb.st_mode)) {
- if (ioctl(fd, DIOCGSECTORSIZE, &secsize) < 0) {
+ if (ioctl(fd, DIOCGSECTORSIZE, &secsize) == -1) {
g_gate_xlog("Can't get sector size: %s.",
strerror(errno));
}
@@ -174,7 +174,7 @@ g_gate_open_device(void)
{
g_gate_devfd = open("/dev/" G_GATE_CTL_NAME, O_RDWR, 0);
- if (g_gate_devfd < 0)
+ if (g_gate_devfd == -1)
err(EXIT_FAILURE, "open(/dev/%s)", G_GATE_CTL_NAME);
}
@@ -189,7 +189,7 @@ void
g_gate_ioctl(unsigned long req, void *data)
{
- if (ioctl(g_gate_devfd, req, data) < 0) {
+ if (ioctl(g_gate_devfd, req, data) == -1) {
g_gate_xlog("%s: ioctl(/dev/%s): %s.", getprogname(),
G_GATE_CTL_NAME, strerror(errno));
}
@@ -221,9 +221,9 @@ void
g_gate_load_module(void)
{
- if (modfind("g_gate") < 0) {
+ if (modfind("g_gate") == -1) {
/* Not present in kernel, try loading it. */
- if (kldload("geom_gate") < 0 || modfind("g_gate") < 0) {
+ if (kldload("geom_gate") == -1 || modfind("g_gate") == -1) {
if (errno != EEXIST) {
errx(EXIT_FAILURE,
"geom_gate module not available!");
OpenPOWER on IntegriCloud