summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2017-01-24 13:32:56 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2017-01-24 13:32:56 +0000
commitee0dd96b08cc94c96c0bec1fea7eed6c2761b2ab (patch)
tree3fc04a2cc2d885b4765a9d49a9d096088d5279e4 /usr.sbin
parent4934783550c08961517a3d181769a975b338ee9d (diff)
Make returns consistent and remove parentheses per style(9).
Transformed with coccinelle. Requested by and ok tb@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/acme-client/acctproc.c20
-rw-r--r--usr.sbin/acme-client/base64.c4
-rw-r--r--usr.sbin/acme-client/certproc.c14
-rw-r--r--usr.sbin/acme-client/chngproc.c4
-rw-r--r--usr.sbin/acme-client/dnsproc.c10
-rw-r--r--usr.sbin/acme-client/fileproc.c16
-rw-r--r--usr.sbin/acme-client/http.c106
-rw-r--r--usr.sbin/acme-client/json.c82
-rw-r--r--usr.sbin/acme-client/main.c7
-rw-r--r--usr.sbin/acme-client/netproc.c86
-rw-r--r--usr.sbin/acme-client/revokeproc.c12
-rw-r--r--usr.sbin/acme-client/rsa.c10
-rw-r--r--usr.sbin/acme-client/util.c56
13 files changed, 213 insertions, 214 deletions
diff --git a/usr.sbin/acme-client/acctproc.c b/usr.sbin/acme-client/acctproc.c
index 3f80bd2da28..c127ef82f81 100644
--- a/usr.sbin/acme-client/acctproc.c
+++ b/usr.sbin/acme-client/acctproc.c
@@ -1,4 +1,4 @@
-/* $Id: acctproc.c,v 1.10 2017/01/24 12:05:14 jsing Exp $ */
+/* $Id: acctproc.c,v 1.11 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -47,11 +47,11 @@ bn2string(const BIGNUM *bn)
len = BN_num_bytes(bn);
if ((buf = malloc(len)) == NULL) {
warn("malloc");
- return (NULL);
+ return NULL;
} else if (len != BN_bn2bin(bn, (unsigned char *)buf)) {
warnx("BN_bn2bin");
free(buf);
- return (NULL);
+ return NULL;
}
/* Convert to base64url. */
@@ -59,11 +59,11 @@ bn2string(const BIGNUM *bn)
if ((bbuf = base64buf_url(buf, len)) == NULL) {
warnx("base64buf_url");
free(buf);
- return (NULL);
+ return NULL;
}
free(buf);
- return (bbuf);
+ return bbuf;
}
/*
@@ -87,7 +87,7 @@ op_thumb_rsa(EVP_PKEY *pkey)
free(exp);
free(mod);
- return (json);
+ return json;
}
/*
@@ -150,7 +150,7 @@ out:
free(thumb);
free(dig);
free(dig64);
- return (rc);
+ return rc;
}
static int
@@ -184,7 +184,7 @@ op_sign_rsa(char **head, char **prot, EVP_PKEY *pkey, const char *nonce)
free(exp);
free(mod);
- return (rc);
+ return rc;
}
/*
@@ -296,7 +296,7 @@ out:
free(dig);
free(dig64);
free(fin);
- return (rc);
+ return rc;
}
int
@@ -397,5 +397,5 @@ out:
EVP_PKEY_free(pkey);
ERR_print_errors_fp(stderr);
ERR_free_strings();
- return (rc);
+ return rc;
}
diff --git a/usr.sbin/acme-client/base64.c b/usr.sbin/acme-client/base64.c
index cfcf85adc46..2b6377f0d81 100644
--- a/usr.sbin/acme-client/base64.c
+++ b/usr.sbin/acme-client/base64.c
@@ -1,4 +1,4 @@
-/* $Id: base64.c,v 1.8 2017/01/24 13:13:41 tb Exp $ */
+/* $Id: base64.c,v 1.9 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -46,7 +46,7 @@ base64buf_url(const char *data, size_t len)
sz = base64len(len);
if ((buf = malloc(sz)) == NULL)
- return (NULL);
+ return NULL;
b64_ntop(data, len, buf, sz);
diff --git a/usr.sbin/acme-client/certproc.c b/usr.sbin/acme-client/certproc.c
index 4b4ae0049ce..1ceff194975 100644
--- a/usr.sbin/acme-client/certproc.c
+++ b/usr.sbin/acme-client/certproc.c
@@ -1,4 +1,4 @@
-/* $Id: certproc.c,v 1.9 2017/01/24 12:05:14 jsing Exp $ */
+/* $Id: certproc.c,v 1.10 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -46,11 +46,11 @@ x509buf(X509 *x, size_t *sz)
if ((bio = BIO_new(BIO_s_mem())) == NULL) {
warnx("BIO_new");
- return (NULL);
+ return NULL;
} else if (!PEM_write_bio_X509(bio, x)) {
warnx("PEM_write_bio_X509");
BIO_free(bio);
- return (NULL);
+ return NULL;
}
/*
@@ -61,19 +61,19 @@ x509buf(X509 *x, size_t *sz)
if ((p = calloc(1, bio->num_write + 1)) == NULL) {
warn("calloc");
BIO_free(bio);
- return (NULL);
+ return NULL;
}
ssz = BIO_read(bio, p, bio->num_write);
if (ssz < 0 || (unsigned)ssz != bio->num_write) {
warnx("BIO_read");
BIO_free(bio);
- return (NULL);
+ return NULL;
}
*sz = ssz;
BIO_free(bio);
- return (p);
+ return p;
}
int
@@ -240,5 +240,5 @@ out:
free(chain);
ERR_print_errors_fp(stderr);
ERR_free_strings();
- return (rc);
+ return rc;
}
diff --git a/usr.sbin/acme-client/chngproc.c b/usr.sbin/acme-client/chngproc.c
index 4af466b6ae8..6e4089c8590 100644
--- a/usr.sbin/acme-client/chngproc.c
+++ b/usr.sbin/acme-client/chngproc.c
@@ -1,4 +1,4 @@
-/* $Id: chngproc.c,v 1.11 2017/01/24 12:53:52 deraadt Exp $ */
+/* $Id: chngproc.c,v 1.12 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -147,5 +147,5 @@ out:
free(fmt);
free(th);
free(tok);
- return(rc);
+ return rc;
}
diff --git a/usr.sbin/acme-client/dnsproc.c b/usr.sbin/acme-client/dnsproc.c
index cdfe32f6c4d..9593828a121 100644
--- a/usr.sbin/acme-client/dnsproc.c
+++ b/usr.sbin/acme-client/dnsproc.c
@@ -1,4 +1,4 @@
-/* $Id: dnsproc.c,v 1.8 2017/01/24 12:53:52 deraadt Exp $ */
+/* $Id: dnsproc.c,v 1.9 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -71,12 +71,12 @@ host_dns(const char *s, struct addr *vec)
error == EAI_NODATA ||
#endif
error == EAI_NONAME)
- return(0);
+ return 0;
if (error) {
warnx("%s: parse error: %s",
s, gai_strerror(error));
- return(-1);
+ return -1;
}
for (vecsz = 0, res = res0;
@@ -106,7 +106,7 @@ host_dns(const char *s, struct addr *vec)
}
freeaddrinfo(res0);
- return(vecsz);
+ return vecsz;
}
int
@@ -182,5 +182,5 @@ out:
close(nfd);
free(look);
free(last);
- return(rc);
+ return rc;
}
diff --git a/usr.sbin/acme-client/fileproc.c b/usr.sbin/acme-client/fileproc.c
index d19c26de1f7..cd4298e62a4 100644
--- a/usr.sbin/acme-client/fileproc.c
+++ b/usr.sbin/acme-client/fileproc.c
@@ -1,4 +1,4 @@
-/* $Id: fileproc.c,v 1.13 2017/01/24 12:53:52 deraadt Exp $ */
+/* $Id: fileproc.c,v 1.14 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -40,24 +40,24 @@ serialise(const char *tmp, const char *real,
fd = open(tmp, O_WRONLY|O_CREAT|O_TRUNC, 0444);
if (fd == -1) {
warn("%s", tmp);
- return (0);
+ return 0;
} else if ((ssize_t)vsz != write(fd, v, vsz)) {
warnx("%s", tmp);
close(fd);
- return (0);
+ return 0;
} else if (v2 != NULL && write(fd, v2, v2sz) != (ssize_t)v2sz) {
warnx("%s", tmp);
close(fd);
- return (0);
+ return 0;
} else if (close(fd) == -1) {
warn("%s", tmp);
- return (0);
+ return 0;
} else if (rename(tmp, real) == -1) {
warn("%s", real);
- return (0);
+ return 0;
}
- return (1);
+ return 1;
}
int
@@ -218,5 +218,5 @@ out:
free(certfile_bak);
free(chainfile_bak);
free(fullchainfile_bak);
- return (rc);
+ return rc;
}
diff --git a/usr.sbin/acme-client/http.c b/usr.sbin/acme-client/http.c
index 09ceb95b7cc..15a09b03a40 100644
--- a/usr.sbin/acme-client/http.c
+++ b/usr.sbin/acme-client/http.c
@@ -1,4 +1,4 @@
-/* $Id: http.c,v 1.17 2017/01/24 12:53:52 deraadt Exp $ */
+/* $Id: http.c,v 1.18 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -74,7 +74,7 @@ dosysread(char *buf, size_t sz, const struct http *http)
rc = read(http->fd, buf, sz);
if (rc < 0)
warn("%s: read", http->src.ip);
- return (rc);
+ return rc;
}
static ssize_t
@@ -85,7 +85,7 @@ dosyswrite(const void *buf, size_t sz, const struct http *http)
rc = write(http->fd, buf, sz);
if (rc < 0)
warn("%s: write", http->src.ip);
- return (rc);
+ return rc;
}
static ssize_t
@@ -100,7 +100,7 @@ dotlsread(char *buf, size_t sz, const struct http *http)
if (rc < 0)
warnx("%s: tls_read: %s", http->src.ip,
tls_error(http->ctx));
- return (rc);
+ return rc;
}
static ssize_t
@@ -115,14 +115,14 @@ dotlswrite(const void *buf, size_t sz, const struct http *http)
if (rc < 0)
warnx("%s: tls_write: %s", http->src.ip,
tls_error(http->ctx));
- return (rc);
+ return rc;
}
int
http_init()
{
if (tlscfg != NULL)
- return (0);
+ return 0;
if (tls_init() == -1) {
warn("tls_init");
@@ -140,13 +140,13 @@ http_init()
goto err;
}
- return (0);
+ return 0;
err:
tls_config_free(tlscfg);
tlscfg = NULL;
- return (-1);
+ return -1;
}
static ssize_t
@@ -157,7 +157,7 @@ http_read(char *buf, size_t sz, const struct http *http)
xfer = 0;
do {
if ((ssz = http->reader(buf, sz, http)) < 0)
- return (-1);
+ return -1;
if (ssz == 0)
break;
xfer += ssz;
@@ -165,7 +165,7 @@ http_read(char *buf, size_t sz, const struct http *http)
buf += ssz;
} while (ssz > 0 && sz > 0);
- return (xfer);
+ return xfer;
}
static int
@@ -176,11 +176,11 @@ http_write(const char *buf, size_t sz, const struct http *http)
xfer = sz;
while (sz > 0) {
if ((ssz = http->writer(buf, sz, http)) < 0)
- return (-1);
+ return -1;
sz -= ssz;
buf += (size_t)ssz;
}
- return (xfer);
+ return xfer;
}
void
@@ -235,7 +235,7 @@ http_alloc(const struct source *addrs, size_t addrsz,
/* Do this while we still have addresses to connect. */
again:
if (i == addrsz)
- return (NULL);
+ return NULL;
cur = i++;
/* Convert to PF_INET or PF_INET6 address from string. */
@@ -287,7 +287,7 @@ again:
if (http == NULL) {
warn("calloc");
close(fd);
- return (NULL);
+ return NULL;
}
http->fd = fd;
http->port = port;
@@ -305,7 +305,7 @@ again:
if (port != 443) {
http->writer = dosyswrite;
http->reader = dosysread;
- return (http);
+ return http;
}
http->writer = dotlswrite;
@@ -326,10 +326,10 @@ again:
goto err;
}
- return (http);
+ return http;
err:
http_free(http);
- return (NULL);
+ return NULL;
}
struct httpxfer *
@@ -355,13 +355,13 @@ http_open(const struct http *http, const void *p, size_t psz)
}
if (c == -1) {
warn("asprintf");
- return (NULL);
+ return NULL;
} else if (!http_write(req, c, http)) {
free(req);
- return (NULL);
+ return NULL;
} else if (p != NULL && !http_write(p, psz, http)) {
free(req);
- return (NULL);
+ return NULL;
}
free(req);
@@ -369,7 +369,7 @@ http_open(const struct http *http, const void *p, size_t psz)
trans = calloc(1, sizeof(struct httpxfer));
if (trans == NULL)
warn("calloc");
- return (trans);
+ return trans;
}
void
@@ -407,9 +407,9 @@ http_body_read(const struct http *http, struct httpxfer *trans, size_t *sz)
if (trans->bodyok > 0) {
*sz = trans->bbufsz;
- return (trans->bbuf);
+ return trans->bbuf;
} else if (trans->bodyok < 0)
- return (NULL);
+ return NULL;
*sz = 0;
trans->bodyok = -1;
@@ -417,13 +417,13 @@ http_body_read(const struct http *http, struct httpxfer *trans, size_t *sz)
do {
/* If less than sizeof(buf), at EOF. */
if ((ssz = http_read(buf, sizeof(buf), http)) < 0)
- return (NULL);
+ return NULL;
else if (ssz == 0)
break;
pp = realloc(trans->bbuf, trans->bbufsz + ssz);
if (pp == NULL) {
warn("realloc");
- return (NULL);
+ return NULL;
}
trans->bbuf = pp;
memcpy(trans->bbuf + trans->bbufsz, buf, ssz);
@@ -432,7 +432,7 @@ http_body_read(const struct http *http, struct httpxfer *trans, size_t *sz)
trans->bodyok = 1;
*sz = trans->bbufsz;
- return (trans->bbuf);
+ return trans->bbuf;
}
struct httphead *
@@ -443,9 +443,9 @@ http_head_get(const char *v, struct httphead *h, size_t hsz)
for (i = 0; i < hsz; i++) {
if (strcmp(h[i].key, v))
continue;
- return (&h[i]);
+ return &h[i];
}
- return (NULL);
+ return NULL;
}
/*
@@ -461,18 +461,18 @@ http_head_status(const struct http *http, struct httphead *h, size_t sz)
if ((st = http_head_get("Status", h, sz)) == NULL) {
warnx("%s: no status header", http->src.ip);
- return (-1);
+ return -1;
}
rc = sscanf(st->val, "%*s %u %*s", &code);
if (rc < 0) {
warn("sscanf");
- return (-1);
+ return -1;
} else if (rc != 1) {
warnx("%s: cannot convert status header", http->src.ip);
- return (-1);
+ return -1;
}
- return (code);
+ return code;
}
/*
@@ -505,13 +505,13 @@ http_head_parse(const struct http *http, struct httpxfer *trans, size_t *sz)
if (trans->head != NULL) {
*sz = trans->headsz;
- return (trans->head);
+ return trans->head;
} else if (trans->headok <= 0)
- return (NULL);
+ return NULL;
if ((buf = strdup(trans->hbuf)) == NULL) {
warn("strdup");
- return (NULL);
+ return NULL;
}
hsz = 0;
cp = buf;
@@ -533,7 +533,7 @@ http_head_parse(const struct http *http, struct httpxfer *trans, size_t *sz)
if (h == NULL) {
warn("calloc");
free(buf);
- return (NULL);
+ return NULL;
}
*sz = hsz;
@@ -567,7 +567,7 @@ http_head_parse(const struct http *http, struct httpxfer *trans, size_t *sz)
trans->headbuf = buf;
trans->head = h;
trans->headsz = hsz;
- return (h);
+ return h;
}
/*
@@ -593,9 +593,9 @@ http_head_read(const struct http *http, struct httpxfer *trans, size_t *sz)
if (trans->headok > 0) {
*sz = trans->hbufsz;
- return (trans->hbuf);
+ return trans->hbuf;
} else if (trans->headok < 0)
- return (NULL);
+ return NULL;
*sz = 0;
ep = NULL;
@@ -611,13 +611,13 @@ http_head_read(const struct http *http, struct httpxfer *trans, size_t *sz)
do {
/* If less than sizeof(buf), at EOF. */
if ((ssz = http_read(buf, sizeof(buf), http)) < 0)
- return (NULL);
+ return NULL;
else if (ssz == 0)
break;
pp = realloc(trans->hbuf, trans->hbufsz + ssz);
if (pp == NULL) {
warn("realloc");
- return (NULL);
+ return NULL;
}
trans->hbuf = pp;
memcpy(trans->hbuf + trans->hbufsz, buf, ssz);
@@ -628,7 +628,7 @@ http_head_read(const struct http *http, struct httpxfer *trans, size_t *sz)
if (ep == NULL) {
warnx("%s: partial transfer", http->src.ip);
- return (NULL);
+ return NULL;
}
*ep = '\0';
@@ -641,7 +641,7 @@ http_head_read(const struct http *http, struct httpxfer *trans, size_t *sz)
if (strlen(trans->hbuf) != (uintptr_t)(ep - trans->hbuf)) {
warnx("%s: binary data in header", http->src.ip);
- return (NULL);
+ return NULL;
}
/*
@@ -653,13 +653,13 @@ http_head_read(const struct http *http, struct httpxfer *trans, size_t *sz)
trans->bbuf = malloc(trans->bbufsz);
if (trans->bbuf == NULL) {
warn("malloc");
- return (NULL);
+ return NULL;
}
memcpy(trans->bbuf, ep, trans->bbufsz);
trans->headok = 1;
*sz = trans->hbufsz;
- return (trans->hbuf);
+ return trans->hbuf;
}
void
@@ -687,19 +687,19 @@ http_get(const struct source *addrs, size_t addrsz, const char *domain,
h = http_alloc(addrs, addrsz, domain, port, path);
if (h == NULL)
- return (NULL);
+ return NULL;
if ((x = http_open(h, post, postsz)) == NULL) {
http_free(h);
- return (NULL);
+ return NULL;
} else if ((headr = http_head_read(h, x, &headrsz)) == NULL) {
http_close(x);
http_free(h);
- return (NULL);
+ return NULL;
} else if ((bod = http_body_read(h, x, &bodsz)) == NULL) {
http_close(x);
http_free(h);
- return (NULL);
+ return NULL;
}
http_disconnect(h);
@@ -707,18 +707,18 @@ http_get(const struct source *addrs, size_t addrsz, const char *domain,
if ((head = http_head_parse(h, x, &headsz)) == NULL) {
http_close(x);
http_free(h);
- return (NULL);
+ return NULL;
} else if ((code = http_head_status(h, head, headsz)) < 0) {
http_close(x);
http_free(h);
- return (NULL);
+ return NULL;
}
if ((g = calloc(1, sizeof(struct httpget))) == NULL) {
warn("calloc");
http_close(x);
http_free(h);
- return (NULL);
+ return NULL;
}
g->headpart = headr;
@@ -730,7 +730,7 @@ http_get(const struct source *addrs, size_t addrsz, const char *domain,
g->code = code;
g->xfer = x;
g->http = h;
- return (g);
+ return g;
}
#if 0
diff --git a/usr.sbin/acme-client/json.c b/usr.sbin/acme-client/json.c
index f30797fdcb1..e800799fbde 100644
--- a/usr.sbin/acme-client/json.c
+++ b/usr.sbin/acme-client/json.c
@@ -1,4 +1,4 @@
-/* $Id: json.c,v 1.8 2017/01/24 12:53:52 deraadt Exp $ */
+/* $Id: json.c,v 1.9 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -76,7 +76,7 @@ build(struct parse *parse, struct jsmnn **np,
ssize_t tmp;
if (sz == 0)
- return (0);
+ return 0;
assert(parse->cur < parse->max);
n = *np = &parse->nodes[parse->cur++];
@@ -93,7 +93,7 @@ build(struct parse *parse, struct jsmnn **np,
t->end - t->start);
if (n->d.str == NULL)
break;
- return (1);
+ return 1;
case JSMN_OBJECT:
n->fields = t->size;
n->d.obj = calloc(n->fields,
@@ -116,7 +116,7 @@ build(struct parse *parse, struct jsmnn **np,
}
if (i < (size_t)t->size)
break;
- return (j + 1);
+ return j + 1;
case JSMN_ARRAY:
n->fields = t->size;
n->d.array = calloc(n->fields,
@@ -133,12 +133,12 @@ build(struct parse *parse, struct jsmnn **np,
}
if (i < (size_t)t->size)
break;
- return (j + 1);
+ return j + 1;
default:
break;
}
- return (-1);
+ return -1;
}
/*
@@ -187,17 +187,17 @@ jsmntree_alloc(jsmntok_t *t, const char *js, size_t sz)
struct parse *p;
if (sz == 0)
- return (NULL);
+ return NULL;
p = calloc(1, sizeof(struct parse));
if (p == NULL)
- return (NULL);
+ return NULL;
p->max = sz;
p->nodes = calloc(p->max, sizeof(struct jsmnn));
if (p->nodes == NULL) {
free(p);
- return (NULL);
+ return NULL;
}
if (build(p, &first, t, js, sz) < 0) {
@@ -205,7 +205,7 @@ jsmntree_alloc(jsmntok_t *t, const char *js, size_t sz)
first = NULL;
}
- return (first);
+ return first;
}
/*
@@ -226,7 +226,7 @@ static struct jsmnn *
json_getarrayobj(struct jsmnn *n)
{
- return (n->type != JSMN_OBJECT ? NULL : n);
+ return n->type != JSMN_OBJECT ? NULL : n;
}
/*
@@ -240,7 +240,7 @@ json_getarray(struct jsmnn *n, const char *name)
size_t i;
if (n->type != JSMN_OBJECT)
- return (NULL);
+ return NULL;
for (i = 0; i < n->fields; i++) {
if (n->d.obj[i].lhs->type != JSMN_STRING &&
n->d.obj[i].lhs->type != JSMN_PRIMITIVE)
@@ -250,10 +250,10 @@ json_getarray(struct jsmnn *n, const char *name)
break;
}
if (i == n->fields)
- return (NULL);
+ return NULL;
if (n->d.obj[i].rhs->type != JSMN_ARRAY)
- return (NULL);
- return (n->d.obj[i].rhs);
+ return NULL;
+ return n->d.obj[i].rhs;
}
/*
@@ -268,7 +268,7 @@ json_getstr(struct jsmnn *n, const char *name)
char *cp;
if (n->type != JSMN_OBJECT)
- return (NULL);
+ return NULL;
for (i = 0; i < n->fields; i++) {
if (n->d.obj[i].lhs->type != JSMN_STRING &&
n->d.obj[i].lhs->type != JSMN_PRIMITIVE)
@@ -278,15 +278,15 @@ json_getstr(struct jsmnn *n, const char *name)
break;
}
if (i == n->fields)
- return (NULL);
+ return NULL;
if (n->d.obj[i].rhs->type != JSMN_STRING &&
n->d.obj[i].rhs->type != JSMN_PRIMITIVE)
- return (NULL);
+ return NULL;
cp = strdup(n->d.obj[i].rhs->d.str);
if (cp == NULL)
warn("strdup");
- return (cp);
+ return cp;
}
/*
@@ -312,9 +312,9 @@ json_parse_response(struct jsmnn *n)
int rc;
if (n == NULL)
- return (-1);
+ return -1;
if ((resp = json_getstr(n, "status")) == NULL)
- return (-1);
+ return -1;
if (strcmp(resp, "valid") == 0)
rc = 1;
@@ -324,7 +324,7 @@ json_parse_response(struct jsmnn *n)
rc = -1;
free(resp);
- return (rc);
+ return rc;
}
/*
@@ -341,11 +341,11 @@ json_parse_challenge(struct jsmnn *n, struct chng *p)
char *type;
if (n == NULL)
- return (0);
+ return 0;
array = json_getarray(n, "challenges");
if (array == NULL)
- return (0);
+ return 0;
for (i = 0; i < array->fields; i++) {
obj = json_getarrayobj(array->d.array[i]);
@@ -360,10 +360,10 @@ json_parse_challenge(struct jsmnn *n, struct chng *p)
continue;
p->uri = json_getstr(obj, "uri");
p->token = json_getstr(obj, "token");
- return (p->uri != NULL && p->token != NULL);
+ return p->uri != NULL && p->token != NULL;
}
- return (0);
+ return 0;
}
/*
@@ -375,15 +375,15 @@ json_parse_capaths(struct jsmnn *n, struct capaths *p)
{
if (n == NULL)
- return (0);
+ return 0;
p->newauthz = json_getstr(n, "new-authz");
p->newcert = json_getstr(n, "new-cert");
p->newreg = json_getstr(n, "new-reg");
p->revokecert = json_getstr(n, "revoke-cert");
- return (p->newauthz != NULL && p->newcert != NULL &&
- p->newreg != NULL && p->revokecert != NULL);
+ return p->newauthz != NULL && p->newcert != NULL &&
+ p->newreg != NULL && p->revokecert != NULL;
}
/*
@@ -421,7 +421,7 @@ again:
tok = calloc(tokcount, sizeof(jsmntok_t));
if (tok == NULL) {
warn("calloc");
- return (NULL);
+ return NULL;
}
/* Actually try to parse the JSON into the tokens. */
@@ -434,14 +434,14 @@ again:
} else if (r < 0) {
warnx("jsmn_parse: %d", r);
free(tok);
- return (NULL);
+ return NULL;
}
/* Now parse the tokens into a tree. */
n = jsmntree_alloc(tok, buf, r);
free(tok);
- return (n);
+ return n;
}
/*
@@ -462,7 +462,7 @@ json_fmt_newreg(const char *license)
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
/*
@@ -484,7 +484,7 @@ json_fmt_newauthz(const char *domain)
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
/*
@@ -505,7 +505,7 @@ json_fmt_challenge(const char *token, const char *thumb)
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
/*
@@ -526,7 +526,7 @@ json_fmt_revokecert(const char *cert)
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
/*
@@ -547,7 +547,7 @@ json_fmt_newcert(const char *cert)
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
/*
@@ -569,7 +569,7 @@ json_fmt_header_rsa(const char *exp, const char *mod)
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
/*
@@ -592,7 +592,7 @@ json_fmt_protected_rsa(const char *exp, const char *mod, const char *nce)
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
/*
@@ -616,7 +616,7 @@ json_fmt_signed(const char *header, const char *protected,
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
/*
@@ -639,5 +639,5 @@ json_fmt_thumb_rsa(const char *exp, const char *mod)
warn("asprintf");
p = NULL;
}
- return (p);
+ return p;
}
diff --git a/usr.sbin/acme-client/main.c b/usr.sbin/acme-client/main.c
index ad887256028..dde8e8b638e 100644
--- a/usr.sbin/acme-client/main.c
+++ b/usr.sbin/acme-client/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.32 2017/01/24 12:53:52 deraadt Exp $ */
+/* $Id: main.c,v 1.33 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -430,10 +430,9 @@ main(int argc, char *argv[])
checkexit(pids[COMP_REVOKE], COMP_REVOKE);
free(alts);
- return (rc != COMP__MAX ? EXIT_FAILURE :
- (c == 2 ? EXIT_SUCCESS : 2));
+ return rc != COMP__MAX ? EXIT_FAILURE : (c == 2 ? EXIT_SUCCESS : 2);
usage:
fprintf(stderr,
"usage: acme-client [-ADFnrv] [-f configfile] domain\n");
- return (EXIT_FAILURE);
+ return EXIT_FAILURE;
}
diff --git a/usr.sbin/acme-client/netproc.c b/usr.sbin/acme-client/netproc.c
index 35d1635a24e..a4bcc542dbe 100644
--- a/usr.sbin/acme-client/netproc.c
+++ b/usr.sbin/acme-client/netproc.c
@@ -1,4 +1,4 @@
-/* $Id: netproc.c,v 1.12 2017/01/24 12:05:14 jsing Exp $ */
+/* $Id: netproc.c,v 1.13 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -98,17 +98,17 @@ url2host(const char *host, short *port, char **path)
*port = 443;
if ((url = strdup(host + 8)) == NULL) {
warn("strdup");
- return (NULL);
+ return NULL;
}
} else if (strncmp(host, "http://", 7) == 0) {
*port = 80;
if ((url = strdup(host + 7)) == NULL) {
warn("strdup");
- return (NULL);
+ return NULL;
}
} else {
warnx("%s: unknown schema", host);
- return (NULL);
+ return NULL;
}
/* Terminate path part. */
@@ -122,10 +122,10 @@ url2host(const char *host, short *port, char **path)
if (*path == NULL) {
warn("strdup");
free(url);
- return (NULL);
+ return NULL;
}
- return (url);
+ return url;
}
/*
@@ -142,11 +142,11 @@ urlresolve(int fd, const char *host, struct source *v)
long lval;
if (writeop(fd, COMM_DNS, DNS_LOOKUP) <= 0)
- return (-1);
+ return -1;
else if (writestr(fd, COMM_DNSQ, host) <= 0)
- return (-1);
+ return -1;
else if ((lval = readop(fd, COMM_DNSLEN)) < 0)
- return (-1);
+ return -1;
sz = lval;
assert(sz <= MAX_SERVERS_DNS);
@@ -163,11 +163,11 @@ urlresolve(int fd, const char *host, struct source *v)
v[i].ip = addr;
}
- return (sz);
+ return sz;
err:
for (i = 0; i < sz; i++)
free(v[i].ip);
- return (-1);
+ return -1;
}
/*
@@ -187,12 +187,12 @@ nreq(struct conn *c, const char *addr)
long code;
if ((host = url2host(addr, &port, &path)) == NULL)
- return (-1);
+ return -1;
if ((ssz = urlresolve(c->dfd, host, src)) < 0) {
free(host);
free(path);
- return (-1);
+ return -1;
}
srcsz = ssz;
@@ -200,7 +200,7 @@ nreq(struct conn *c, const char *addr)
free(host);
free(path);
if (g == NULL)
- return (-1);
+ return -1;
code = g->code;
@@ -213,9 +213,9 @@ nreq(struct conn *c, const char *addr)
http_get_free(g);
if (c->buf.buf == NULL) {
warn("malloc");
- return (-1);
+ return -1;
}
- return (code);
+ return code;
}
/*
@@ -235,29 +235,29 @@ sreq(struct conn *c, const char *addr, const char *req)
long code;
if ((host = url2host(c->na, &port, &path)) == NULL)
- return (-1);
+ return -1;
if ((ssz = urlresolve(c->dfd, host, src)) < 0) {
free(host);
free(path);
- return (-1);
+ return -1;
}
g = http_get(src, (size_t)ssz, host, port, path, NULL, 0);
free(host);
free(path);
if (g == NULL)
- return (-1);
+ return -1;
h = http_head_get("Replay-Nonce", g->head, g->headsz);
if (h == NULL) {
warnx("%s: no replay nonce", c->na);
http_get_free(g);
- return (-1);
+ return -1;
} else if ((nonce = strdup(h->val)) == NULL) {
warn("strdup");
http_get_free(g);
- return (-1);
+ return -1;
}
http_get_free(g);
@@ -268,31 +268,31 @@ sreq(struct conn *c, const char *addr, const char *req)
if (writeop(c->fd, COMM_ACCT, ACCT_SIGN) <= 0) {
free(nonce);
- return (-1);
+ return -1;
} else if (writestr(c->fd, COMM_PAY, req) <= 0) {
free(nonce);
- return (-1);
+ return -1;
} else if (writestr(c->fd, COMM_NONCE, nonce) <= 0) {
free(nonce);
- return (-1);
+ return -1;
}
free(nonce);
/* Now read back the signed payload. */
if ((reqsn = readstr(c->fd, COMM_REQ)) == NULL)
- return (-1);
+ return -1;
/* Now send the signed payload to the CA. */
if ((host = url2host(addr, &port, &path)) == NULL) {
free(reqsn);
- return (-1);
+ return -1;
} else if ((ssz = urlresolve(c->dfd, host, src)) < 0) {
free(host);
free(path);
free(reqsn);
- return (-1);
+ return -1;
}
g = http_get(src, (size_t)ssz, host, port, path, reqsn, strlen(reqsn));
@@ -301,7 +301,7 @@ sreq(struct conn *c, const char *addr, const char *req)
free(path);
free(reqsn);
if (g == NULL)
- return (-1);
+ return -1;
/* Stuff response into parse buffer. */
@@ -314,9 +314,9 @@ sreq(struct conn *c, const char *addr, const char *req)
http_get_free(g);
if (c->buf.buf == NULL) {
warn("malloc");
- return (-1);
+ return -1;
}
- return (code);
+ return code;
}
/*
@@ -347,7 +347,7 @@ donewreg(struct conn *c, const char *agreement, const struct capaths *p)
if (rc == 0 || verbose > 1)
buf_dump(&c->buf);
free(req);
- return (rc);
+ return rc;
}
/*
@@ -383,7 +383,7 @@ dochngreq(struct conn *c, const char *alt, struct chng *chng,
buf_dump(&c->buf);
json_free(j);
free(req);
- return (rc);
+ return rc;
}
/*
@@ -410,7 +410,7 @@ dochngresp(struct conn *c, const struct chng *chng, const char *th)
if (rc == 0 || verbose > 1)
buf_dump(&c->buf);
free(req);
- return (rc);
+ return rc;
}
/*
@@ -429,25 +429,25 @@ dochngcheck(struct conn *c, struct chng *chng)
if ((lc = nreq(c, chng->uri)) < 0) {
warnx("%s: bad comm", chng->uri);
- return (0);
+ return 0;
} else if (lc != 200 && lc != 201 && lc != 202) {
warnx("%s: bad HTTP: %ld", chng->uri, lc);
buf_dump(&c->buf);
- return (0);
+ return 0;
} else if ((j = json_parse(c->buf.buf, c->buf.sz)) == NULL) {
warnx("%s: bad JSON object", chng->uri);
buf_dump(&c->buf);
- return (0);
+ return 0;
} else if ((cc = json_parse_response(j)) == -1) {
warnx("%s: bad response", chng->uri);
buf_dump(&c->buf);
json_free(j);
- return (0);
+ return 0;
} else if (cc > 0)
chng->status = 1;
json_free(j);
- return (1);
+ return 1;
}
static int
@@ -474,7 +474,7 @@ dorevoke(struct conn *c, const char *addr, const char *cert)
if (rc == 0 || verbose > 1)
buf_dump(&c->buf);
free(req);
- return (rc);
+ return rc;
}
/*
@@ -504,7 +504,7 @@ docert(struct conn *c, const char *addr, const char *cert)
if (rc == 0 || verbose > 1)
buf_dump(&c->buf);
free(req);
- return (rc);
+ return rc;
}
/*
@@ -533,7 +533,7 @@ dodirs(struct conn *c, const char *addr, struct capaths *paths)
if (rc == 0 || verbose > 1)
buf_dump(&c->buf);
json_free(j);
- return (rc);
+ return rc;
}
/*
@@ -556,7 +556,7 @@ dofullchain(struct conn *c, const char *addr)
if (rc == 0 || verbose > 1)
buf_dump(&c->buf);
- return (rc);
+ return rc;
}
/*
@@ -791,5 +791,5 @@ out:
json_free_challenge(&chngs[i]);
free(chngs);
json_free_capaths(&paths);
- return (rc);
+ return rc;
}
diff --git a/usr.sbin/acme-client/revokeproc.c b/usr.sbin/acme-client/revokeproc.c
index 101e321843c..66ccfa315a2 100644
--- a/usr.sbin/acme-client/revokeproc.c
+++ b/usr.sbin/acme-client/revokeproc.c
@@ -1,4 +1,4 @@
-/* $Id: revokeproc.c,v 1.11 2017/01/24 12:53:52 deraadt Exp $ */
+/* $Id: revokeproc.c,v 1.12 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -57,7 +57,7 @@ X509expires(X509 *x)
if (atim->type == V_ASN1_UTCTIME) {
if (atim->length <= 2) {
warnx("invalid ASN1_TIME");
- return ((time_t)-1);
+ return (time_t)-1;
}
t.tm_year = (str[0] - '0') * 10 + (str[1] - '0');
if (t.tm_year < 70)
@@ -66,7 +66,7 @@ X509expires(X509 *x)
} else if (atim->type == V_ASN1_GENERALIZEDTIME) {
if (atim->length <= 4) {
warnx("invalid ASN1_TIME");
- return ((time_t)-1);
+ return (time_t)-1;
}
t.tm_year = (str[0] - '0') * 1000 + (str[1] - '0') * 100 +
(str[2] - '0') * 10 + (str[3] - '0');
@@ -78,7 +78,7 @@ X509expires(X509 *x)
if (atim->length <= (int)i + 10) {
warnx("invalid ASN1_TIME");
- return ((time_t)-1);
+ return (time_t)-1;
}
t.tm_mon = ((str[i + 0] - '0') * 10 + (str[i + 1] - '0')) - 1;
@@ -87,7 +87,7 @@ X509expires(X509 *x)
t.tm_min = (str[i + 6] - '0') * 10 + (str[i + 7] - '0');
t.tm_sec = (str[i + 8] - '0') * 10 + (str[i + 9] - '0');
- return (mktime(&t));
+ return mktime(&t);
}
int
@@ -346,5 +346,5 @@ out:
free(der64);
ERR_print_errors_fp(stderr);
ERR_free_strings();
- return (rc);
+ return rc;
}
diff --git a/usr.sbin/acme-client/rsa.c b/usr.sbin/acme-client/rsa.c
index 74bc72a3e19..35ca61c40cd 100644
--- a/usr.sbin/acme-client/rsa.c
+++ b/usr.sbin/acme-client/rsa.c
@@ -1,4 +1,4 @@
-/* $Id: rsa.c,v 1.5 2017/01/24 12:05:14 jsing Exp $ */
+/* $Id: rsa.c,v 1.6 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -68,7 +68,7 @@ err:
out:
if (ctx != NULL)
EVP_PKEY_CTX_free(ctx);
- return (pkey);
+ return pkey;
}
@@ -80,11 +80,11 @@ rsa_key_load(FILE *f, const char *fname)
pkey = PEM_read_PrivateKey(f, NULL, NULL, NULL);
if (pkey == NULL) {
warnx("%s: PEM_read_PrivateKey", fname);
- return (NULL);
+ return NULL;
} else if (EVP_PKEY_type(pkey->type) == EVP_PKEY_RSA)
- return (pkey);
+ return pkey;
warnx("%s: unsupported key type", fname);
EVP_PKEY_free(pkey);
- return (NULL);
+ return NULL;
}
diff --git a/usr.sbin/acme-client/util.c b/usr.sbin/acme-client/util.c
index 6e7653ce83d..d5f6f5ddbff 100644
--- a/usr.sbin/acme-client/util.c
+++ b/usr.sbin/acme-client/util.c
@@ -1,4 +1,4 @@
-/* $Id: util.c,v 1.8 2017/01/24 12:53:52 deraadt Exp $ */
+/* $Id: util.c,v 1.9 2017/01/24 13:32:55 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -93,14 +93,14 @@ readop(int fd, enum comm comm)
ssz = read(fd, &op, sizeof(long));
if (ssz < 0) {
warn("read: %s", comms[comm]);
- return (LONG_MAX);
+ return LONG_MAX;
} else if (ssz && ssz != sizeof(long)) {
warnx("short read: %s", comms[comm]);
- return (LONG_MAX);
+ return LONG_MAX;
} else if (ssz == 0)
- return (0);
+ return 0;
- return (op);
+ return op;
}
char *
@@ -108,7 +108,7 @@ readstr(int fd, enum comm comm)
{
size_t sz;
- return (readbuf(fd, comm, &sz));
+ return readbuf(fd, comm, &sz);
}
/*
@@ -126,16 +126,16 @@ readbuf(int fd, enum comm comm, size_t *sz)
if ((ssz = read(fd, sz, sizeof(size_t))) < 0) {
warn("read: %s length", comms[comm]);
- return (NULL);
+ return NULL;
} else if ((size_t)ssz != sizeof(size_t)) {
warnx("short read: %s length", comms[comm]);
- return (NULL);
+ return NULL;
} else if (*sz > SIZE_MAX - 1) {
warnx("integer overflow");
- return (NULL);
+ return NULL;
} else if ((p = calloc(1, *sz + 1)) == NULL) {
warn("malloc");
- return (NULL);
+ return NULL;
}
/* Catch this over several reads. */
@@ -156,10 +156,10 @@ readbuf(int fd, enum comm comm, size_t *sz)
if (lsz) {
warnx("couldn't read buffer: %s", comms[comm]);
free(p);
- return (NULL);
+ return NULL;
}
- return (p);
+ return p;
}
/*
@@ -179,17 +179,17 @@ writeop(int fd, enum comm comm, long op)
if ((er = errno) != EPIPE)
warn("write: %s", comms[comm]);
signal(SIGPIPE, sigfp);
- return (er == EPIPE ? 0 : -1);
+ return er == EPIPE ? 0 : -1;
}
signal(SIGPIPE, sigfp);
if ((size_t)ssz != sizeof(long)) {
warnx("short write: %s", comms[comm]);
- return (-1);
+ return -1;
}
- return (1);
+ return 1;
}
/*
@@ -216,7 +216,7 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz)
if ((er = errno) != EPIPE)
warn("write: %s length", comms[comm]);
signal(SIGPIPE, sigfp);
- return (er == EPIPE ? 0 : -1);
+ return er == EPIPE ? 0 : -1;
}
/* Now write errors cause us to bail. */
@@ -231,14 +231,14 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz)
rc = 1;
signal(SIGPIPE, sigfp);
- return (rc);
+ return rc;
}
int
writestr(int fd, enum comm comm, const char *v)
{
- return (writebuf(fd, comm, v, strlen(v)));
+ return writebuf(fd, comm, v, strlen(v));
}
/*
@@ -254,21 +254,21 @@ checkexit(pid_t pid, enum comp comp)
if (waitpid(pid, &c, 0) == -1) {
warn("waitpid");
- return (0);
+ return 0;
} else if (!WIFEXITED(c) && WIFSIGNALED(c)) {
cp = strsignal(WTERMSIG(c));
warnx("signal: %s(%u): %s", comps[comp], pid, cp);
- return (0);
+ return 0;
} else if (!WIFEXITED(c)) {
warnx("did not exit: %s(%u)", comps[comp], pid);
- return (0);
+ return 0;
} else if (WEXITSTATUS(c) != EXIT_SUCCESS) {
cc = WEXITSTATUS(c);
dodbg("bad exit: %s(%u): %d", comps[comp], pid, cc);
- return (0);
+ return 0;
}
- return (1);
+ return 1;
}
/*
@@ -287,23 +287,23 @@ checkexit_ext(int *rc, pid_t pid, enum comp comp)
if (waitpid(pid, &c, 0) == -1) {
warn("waitpid");
- return (0);
+ return 0;
}
if (!WIFEXITED(c) && WIFSIGNALED(c)) {
cp = strsignal(WTERMSIG(c));
warnx("signal: %s(%u): %s", comps[comp], pid, cp);
- return (0);
+ return 0;
} else if (!WIFEXITED(c)) {
warnx("did not exit: %s(%u)", comps[comp], pid);
- return (0);
+ return 0;
}
/* Now check extended status. */
if ((*rc = WEXITSTATUS(c)) != EXIT_SUCCESS && *rc != 2) {
dodbg("bad exit: %s(%u): %d", comps[comp], pid, *rc);
- return (0);
+ return 0;
}
- return (1);
+ return 1;
}