From be16f395f6cd24269de8c7a3f76d7fde33b7ec7e Mon Sep 17 00:00:00 2001 From: claudio Date: Sun, 20 Apr 2014 18:17:12 +0000 Subject: [PATCH] Use only one style for "return foo;" --- usr.sbin/iscsid/connection.c | 32 ++++++++++++++++---------------- usr.sbin/iscsid/control.c | 22 +++++++++++++--------- usr.sbin/iscsid/pdu.c | 12 ++++++------ 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/usr.sbin/iscsid/connection.c b/usr.sbin/iscsid/connection.c index d9c0ad6ae1d..d01250015b5 100644 --- a/usr.sbin/iscsid/connection.c +++ b/usr.sbin/iscsid/connection.c @@ -1,4 +1,4 @@ -/* $OpenBSD: connection.c,v 1.14 2014/04/20 16:49:56 claudio Exp $ */ +/* $OpenBSD: connection.c,v 1.15 2014/04/20 18:17:12 claudio Exp $ */ /* * Copyright (c) 2009 Claudio Jeker @@ -316,11 +316,11 @@ conn_gen_kvp(struct connection *c, struct kvp *kvp, size_t *nkvp) if (kvp && i < *nkvp) { kvp[i].key = strdup("MaxConnections"); if (kvp[i].key == NULL) - return (-1); + return -1; if (asprintf(&kvp[i].value, "%hu", s->mine.MaxConnections) == -1) { kvp[i].value = NULL; - return (-1); + return -1; } } i++; @@ -330,18 +330,18 @@ conn_gen_kvp(struct connection *c, struct kvp *kvp, size_t *nkvp) if (kvp && i < *nkvp) { kvp[i].key = strdup("MaxRecvDataSegmentLength"); if (kvp[i].key == NULL) - return (-1); + return -1; if (asprintf(&kvp[i].value, "%u", c->mine.MaxRecvDataSegmentLength) == -1) { kvp[i].value = NULL; - return (-1); + return -1; } } i++; } *nkvp = i; - return (0); + return 0; } void @@ -419,23 +419,23 @@ c_do_connect(struct connection *c, enum c_event ev) log_warnx("connect(%s), lost socket", log_sockaddr(&c->config.TargetAddr)); session_fsm(c->session, SESS_EV_CONN_FAIL, c); - return (CONN_FREE); + return CONN_FREE; } if (connect(c->fd, (struct sockaddr *)&c->config.TargetAddr, c->config.TargetAddr.ss_len) == -1) { if (errno == EINPROGRESS) { event_add(&c->wev, NULL); - return (CONN_XPT_WAIT); + return CONN_XPT_WAIT; } else { log_warn("connect(%s)", log_sockaddr(&c->config.TargetAddr)); session_fsm(c->session, SESS_EV_CONN_FAIL, c); - return (CONN_FREE); + return CONN_FREE; } } /* move forward */ - return (c_do_login(c, CONN_EV_CONNECTED)); + return c_do_login(c, CONN_EV_CONNECTED); } int @@ -443,7 +443,7 @@ c_do_login(struct connection *c, enum c_event ev) { /* start a login session and hope for the best ... */ initiator_login(c); - return (CONN_IN_LOGIN); + return CONN_IN_LOGIN; } int @@ -451,14 +451,14 @@ c_do_loggedin(struct connection *c, enum c_event ev) { session_fsm(c->session, SESS_EV_CONN_LOGGED_IN, c); - return (CONN_LOGGED_IN); + return CONN_LOGGED_IN; } int c_do_logout(struct connection *c, enum c_event ev) { /* logout is in progress ... */ - return (CONN_IN_LOGOUT); + return CONN_IN_LOGOUT; } int @@ -470,7 +470,7 @@ c_do_loggedout(struct connection *c, enum c_event ev) close(c->fd); /* session is informed by the logout handler */ - return (CONN_FREE); + return CONN_FREE; } int @@ -484,8 +484,8 @@ c_do_fail(struct connection *c, enum c_event ev) session_fsm(c->session, SESS_EV_CONN_FAIL, c); if (ev == CONN_EV_FREE || c->state & CONN_NEVER_LOGGED_IN) - return (CONN_FREE); - return (CONN_CLEANUP_WAIT); + return CONN_FREE; + return CONN_CLEANUP_WAIT; } const char * diff --git a/usr.sbin/iscsid/control.c b/usr.sbin/iscsid/control.c index cd2142e8c39..c352b1261e7 100644 --- a/usr.sbin/iscsid/control.c +++ b/usr.sbin/iscsid/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.6 2014/04/19 18:31:33 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.7 2014/04/20 18:17:12 claudio Exp $ */ /* * Copyright (c) 2010 Claudio Jeker @@ -64,23 +64,27 @@ control_init(char *path) if ((control_state = calloc(1, sizeof(*control_state))) == NULL) { log_warn("control_init: calloc"); - return (-1); + return -1; } if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { log_warn("control_init: socket"); - return (-1); + return -1; } bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; - strlcpy(sun.sun_path, path, sizeof(sun.sun_path)); + if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= + sizeof(sun.sun_path)) { + log_warnx("control_init: path %s too long", path); + return -1; + } if (unlink(path) == -1) if (errno != ENOENT) { log_warn("control_init: unlink %s", path); close(fd); - return (-1); + return -1; } old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); @@ -88,7 +92,7 @@ control_init(char *path) log_warn("control_init: bind: %s", path); close(fd); umask(old_umask); - return (-1); + return -1; } umask(old_umask); @@ -96,21 +100,21 @@ control_init(char *path) log_warn("control_init: chmod"); close(fd); (void)unlink(path); - return (-1); + return -1; } if (listen(fd, CONTROL_BACKLOG) == -1) { log_warn("control_init: listen"); close(fd); (void)unlink(path); - return (-1); + return -1; } socket_setblockmode(fd, 1); control_state->fd = fd; TAILQ_INIT(&controls); - return (0); + return 0; } void diff --git a/usr.sbin/iscsid/pdu.c b/usr.sbin/iscsid/pdu.c index 26ef6f9b5b1..8167f662821 100644 --- a/usr.sbin/iscsid/pdu.c +++ b/usr.sbin/iscsid/pdu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pdu.c,v 1.7 2014/04/19 18:31:33 claudio Exp $ */ +/* $OpenBSD: pdu.c,v 1.8 2014/04/20 18:17:12 claudio Exp $ */ /* * Copyright (c) 2009 Claudio Jeker @@ -60,7 +60,7 @@ text_to_pdu(struct kvp *k, struct pdu *p) int n, nk; if (k == NULL) - return (0); + return 0; nk = 0; while(k[nk].key) { @@ -182,7 +182,7 @@ text_to_num(const char *numstr, u_int64_t minval, u_int64_t maxval, if (error) ull = 0; - return (ull); + return ull; #undef INVALID #undef TOOSMALL #undef TOOLARGE @@ -207,7 +207,7 @@ text_to_bool(const char *buf, const char **errstrp) else *errstrp = "invalid"; } - return (val); + return val; } @@ -263,7 +263,7 @@ pdu_read(struct connection *c) if (c->prbuf.wpos >= c->prbuf.size) c->prbuf.wpos -= c->prbuf.size; - return (n); + return n; } ssize_t @@ -414,7 +414,7 @@ pdu_readbuf_read(struct pdu_readbuf *rb, void *ptr, size_t len) size_t l; if (rb->rpos == rb->wpos) { - return (0); + return 0; } else if (rb->rpos < rb->wpos) { l = PDU_MIN(rb->wpos - rb->rpos, len); memcpy(ptr, rb->buf + rb->rpos, l); -- 2.20.1