summaryrefslogtreecommitdiff
path: root/usr.sbin/acme-client/revokeproc.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2017-01-24 12:05:15 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2017-01-24 12:05:15 +0000
commitd77840a5e95c604ceb14fb96d9723a1e36b46f96 (patch)
treecd4e42e6b0b8418c24a53f3137d1eca04cbfe337 /usr.sbin/acme-client/revokeproc.c
parent04a1ee6a83461a987d3ca563473f4d0302a71f66 (diff)
Replace comparisons between a constant or enum and an expression, with
a comparison between the expression and the constant or enum. This significantly improves readability. Transformed with coccinelle. Requested by deraadt@
Diffstat (limited to 'usr.sbin/acme-client/revokeproc.c')
-rw-r--r--usr.sbin/acme-client/revokeproc.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/usr.sbin/acme-client/revokeproc.c b/usr.sbin/acme-client/revokeproc.c
index e0d0a0c7d28..ae5d89a61ce 100644
--- a/usr.sbin/acme-client/revokeproc.c
+++ b/usr.sbin/acme-client/revokeproc.c
@@ -1,4 +1,4 @@
-/* $Id: revokeproc.c,v 1.9 2017/01/21 08:54:26 florian Exp $ */
+/* $Id: revokeproc.c,v 1.10 2017/01/24 12:05:14 jsing Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -114,10 +114,10 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
* We allow "f" to be NULL IFF the cert doesn't exist yet.
*/
- if (-1 == asprintf(&path, "%s/%s", certdir, certfile)) {
+ if (asprintf(&path, "%s/%s", certdir, certfile) == -1) {
warn("asprintf");
goto out;
- } else if (NULL == (f = fopen(path, "r")) && ENOENT != errno) {
+ } else if ((f = fopen(path, "r")) == NULL && errno != ENOENT) {
warn("%s", path);
goto out;
}
@@ -139,24 +139,24 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
* Ignore if the reader isn't reading in either case.
*/
- if (NULL == f && revocate) {
+ if (f == NULL && revocate) {
warnx("%s/%s: no certificate found", certdir, certfile);
(void)writeop(fd, COMM_REVOKE_RESP, REVOKE_OK);
goto out;
- } else if (NULL == f && ! revocate) {
+ } else if (f == NULL && ! revocate) {
if (writeop(fd, COMM_REVOKE_RESP, REVOKE_EXP) >= 0)
rc = 1;
goto out;
}
- if (NULL == (x = PEM_read_X509(f, NULL, NULL, NULL))) {
+ if ((x = PEM_read_X509(f, NULL, NULL, NULL)) == NULL) {
warnx("PEM_read_X509");
goto out;
}
/* Read out the expiration date. */
- if ((time_t)-1 == (t = X509expires(x))) {
+ if ((t = X509expires(x)) == (time_t)-1) {
warnx("X509expires");
goto out;
}
@@ -167,32 +167,32 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
* comamnd line.
*/
- extsz = NULL != x->cert_info->extensions ?
+ extsz = x->cert_info->extensions != NULL ?
sk_X509_EXTENSION_num(x->cert_info->extensions) : 0;
/* Scan til we find the SAN NID. */
for (i = 0; i < extsz; i++) {
ex = sk_X509_EXTENSION_value(x->cert_info->extensions, i);
- assert(NULL != ex);
+ assert(ex != NULL);
obj = X509_EXTENSION_get_object(ex);
- assert(NULL != obj);
+ assert(obj != NULL);
if (NID_subject_alt_name != OBJ_obj2nid(obj))
continue;
- if (NULL != san) {
+ if (san != NULL) {
warnx("%s/%s: two SAN entries", certdir, certfile);
goto out;
}
bio = BIO_new(BIO_s_mem());
- if (NULL == bio) {
+ if (bio == NULL) {
warnx("BIO_new");
goto out;
} else if (!X509V3_EXT_print(bio, ex, 0, 0)) {
warnx("X509V3_EXT_print");
goto out;
- } else if (NULL == (san = calloc(1, bio->num_write + 1))) {
+ } else if ((san = calloc(1, bio->num_write + 1)) == NULL) {
warn("calloc");
goto out;
}
@@ -203,14 +203,14 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
}
}
- if (NULL == san) {
+ if (san == NULL) {
warnx("%s/%s: does not have a SAN entry", certdir, certfile);
goto out;
}
/* An array of buckets: the number of entries found. */
- if (NULL == (found = calloc(altsz, sizeof(size_t)))) {
+ if ((found = calloc(altsz, sizeof(size_t))) == NULL) {
warn("calloc");
goto out;
}
@@ -221,8 +221,8 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
*/
str = san;
- while (NULL != (tok = strsep(&str, ","))) {
- if ('\0' == *tok)
+ while ((tok = strsep(&str, ",")) != NULL) {
+ if (*tok == '\0')
continue;
while (isspace((int)*tok))
tok++;
@@ -230,7 +230,7 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
continue;
tok += 4;
for (j = 0; j < altsz; j++)
- if (0 == strcmp(tok, alts[j]))
+ if (strcmp(tok, alts[j]) == 0)
break;
if (j == altsz) {
warnx("%s/%s: unknown SAN entry: %s",
@@ -267,7 +267,7 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
*/
cc = writeop(fd, COMM_REVOKE_RESP, REVOKE_EXP);
- if (0 == cc)
+ if (cc == 0)
rc = 1;
if (cc <= 0)
goto out;
@@ -275,13 +275,13 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
if ((len = i2d_X509(x, NULL)) < 0) {
warnx("i2d_X509");
goto out;
- } else if (NULL == (der = dercp = malloc(len))) {
+ } else if ((der = dercp = malloc(len)) == NULL) {
warn("malloc");
goto out;
} else if (len != i2d_X509(x, (u_char **)&dercp)) {
warnx("i2d_X509");
goto out;
- } else if (NULL == (der64 = base64buf_url(der, len))) {
+ } else if ((der64 = base64buf_url(der, len)) == NULL) {
warnx("base64buf_url");
goto out;
} else if (writestr(fd, COMM_CSR, der64) >= 0)
@@ -311,15 +311,15 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
* If netproc is down, just exit.
*/
- if (0 == (cc = writeop(fd, COMM_REVOKE_RESP, rop)))
+ if ((cc = writeop(fd, COMM_REVOKE_RESP, rop)) == 0)
rc = 1;
if (cc <= 0)
goto out;
op = REVOKE__MAX;
- if (0 == (lval = readop(fd, COMM_REVOKE_OP)))
+ if ((lval = readop(fd, COMM_REVOKE_OP)) == 0)
op = REVOKE_STOP;
- else if (REVOKE_CHECK == lval)
+ else if (lval == REVOKE_CHECK)
op = lval;
if (REVOKE__MAX == op) {
@@ -333,11 +333,11 @@ revokeproc(int fd, const char *certdir, const char *certfile, int force,
rc = 1;
out:
close(fd);
- if (NULL != f)
+ if (f != NULL)
fclose(f);
- if (NULL != x)
+ if (x != NULL)
X509_free(x);
- if (NULL != bio)
+ if (bio != NULL)
BIO_free(bio);
free(san);
free(path);