From e89c20d83fc19d5ee9fd7ca8dc4f713832ef113f Mon Sep 17 00:00:00 2001 From: tb Date: Sun, 15 May 2022 16:43:34 +0000 Subject: [PATCH] More KNF and whitespace fixes. --- usr.sbin/rpki-client/as.c | 8 ++++---- usr.sbin/rpki-client/cms.c | 6 +++--- usr.sbin/rpki-client/http.c | 12 ++++++------ usr.sbin/rpki-client/io.c | 3 +-- usr.sbin/rpki-client/ip.c | 4 ++-- usr.sbin/rpki-client/main.c | 4 ++-- usr.sbin/rpki-client/output-bird.c | 4 ++-- usr.sbin/rpki-client/output-json.c | 8 ++++---- usr.sbin/rpki-client/print.c | 11 ++++------- usr.sbin/rpki-client/repo.c | 11 ++++------- usr.sbin/rpki-client/roa.c | 3 +-- usr.sbin/rpki-client/rrdp.c | 4 ++-- usr.sbin/rpki-client/rrdp_delta.c | 3 +-- usr.sbin/rpki-client/rsc.c | 9 +++++---- usr.sbin/rpki-client/tal.c | 4 ++-- usr.sbin/rpki-client/validate.c | 10 +++++----- usr.sbin/rpki-client/x509.c | 4 +--- 17 files changed, 49 insertions(+), 59 deletions(-) diff --git a/usr.sbin/rpki-client/as.c b/usr.sbin/rpki-client/as.c index 88598a6a5de..5178218a0f1 100644 --- a/usr.sbin/rpki-client/as.c +++ b/usr.sbin/rpki-client/as.c @@ -1,4 +1,4 @@ -/* $OpenBSD: as.c,v 1.7 2021/12/26 12:32:28 tb Exp $ */ +/* $OpenBSD: as.c,v 1.8 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -152,9 +152,9 @@ as_check_covered(uint32_t min, uint32_t max, if (as[i].type == CERT_AS_INHERIT) return 0; amin = as[i].type == CERT_AS_RANGE ? - as[i].range.min : as[i].id; - amax = as[i].type == CERT_AS_RANGE? - as[i].range.max : as[i].id; + as[i].range.min : as[i].id; + amax = as[i].type == CERT_AS_RANGE ? + as[i].range.max : as[i].id; if (min >= amin && max <= amax) return 1; } diff --git a/usr.sbin/rpki-client/cms.c b/usr.sbin/rpki-client/cms.c index 52ace284aa8..109f9e5f8e2 100644 --- a/usr.sbin/rpki-client/cms.c +++ b/usr.sbin/rpki-client/cms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms.c,v 1.18 2022/05/15 15:00:53 deraadt Exp $ */ +/* $OpenBSD: cms.c,v 1.19 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -280,7 +280,7 @@ out: */ int ASN1_frame(const char *fn, size_t sz, - const unsigned char **cnt, long *cntsz, int *tag) + const unsigned char **cnt, long *cntsz, int *tag) { int ret, pcls; @@ -298,7 +298,7 @@ ASN1_frame(const char *fn, size_t sz, */ int cms_econtent_version(const char *fn, const unsigned char **d, size_t dsz, - long *version) + long *version) { ASN1_INTEGER *aint = NULL; long plen; diff --git a/usr.sbin/rpki-client/http.c b/usr.sbin/rpki-client/http.c index ffdf5d53bc1..fa8d1be6672 100644 --- a/usr.sbin/rpki-client/http.c +++ b/usr.sbin/rpki-client/http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http.c,v 1.59 2022/05/15 15:00:53 deraadt Exp $ */ +/* $OpenBSD: http.c,v 1.60 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2020 Nils Fisher * Copyright (c) 2020 Claudio Jeker @@ -150,7 +150,7 @@ TAILQ_HEAD(http_req_queue, http_request); static struct http_conn_list active = LIST_HEAD_INITIALIZER(active); static struct http_conn_list idle = LIST_HEAD_INITIALIZER(idle); static struct http_req_queue queue = TAILQ_HEAD_INITIALIZER(queue); -static unsigned int http_conn_count; +static unsigned int http_conn_count; static struct msgbuf msgq; static struct sockaddr_storage http_bindaddr; @@ -180,7 +180,7 @@ static void http_do(struct http_connection *, static enum res http_connect(struct http_connection *); static enum res http_request(struct http_connection *); static enum res http_close(struct http_connection *); -static enum res http_handle(struct http_connection *); +static enum res http_handle(struct http_connection *); /* Internal state functions used by the above functions */ static enum res http_finish_connect(struct http_connection *); @@ -1167,7 +1167,7 @@ http_parse_header(struct http_connection *conn, char *buf) size_t s; cp += sizeof(CONTENTLEN) - 1; if ((s = strcspn(cp, " \t")) != 0) - *(cp+s) = 0; + *(cp + s) = 0; conn->iosz = strtonum(cp, 0, MAX_CONTENTLEN, &errstr); if (errstr != NULL) { warnx("Content-Length of %s is %s", @@ -1590,7 +1590,7 @@ proxy_write(struct http_connection *conn) assert(conn->state == STATE_PROXY_REQUEST); s = write(conn->fd, conn->buf + conn->bufpos, - conn->bufsz - conn->bufpos); + conn->bufsz - conn->bufpos); if (s == -1) { warn("%s: write", http_info(conn->host)); return http_failed(conn); @@ -1695,7 +1695,7 @@ data_write(struct http_connection *conn) static enum res http_handle(struct http_connection *conn) { - assert (conn->pfd != NULL && conn->pfd->revents != 0); + assert(conn->pfd != NULL && conn->pfd->revents != 0); conn->io_time = 0; diff --git a/usr.sbin/rpki-client/io.c b/usr.sbin/rpki-client/io.c index f9541c57e34..f056ff18ac1 100644 --- a/usr.sbin/rpki-client/io.c +++ b/usr.sbin/rpki-client/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.19 2022/04/20 15:31:48 tb Exp $ */ +/* $OpenBSD: io.c,v 1.20 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -222,7 +222,6 @@ io_buf_read(int fd, struct ibuf **ib) return NULL; } - /* * Read data from socket but receive a file descriptor at the same time. */ diff --git a/usr.sbin/rpki-client/ip.c b/usr.sbin/rpki-client/ip.c index b4a813b73da..67f1564d923 100644 --- a/usr.sbin/rpki-client/ip.c +++ b/usr.sbin/rpki-client/ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip.c,v 1.24 2022/05/15 15:00:53 deraadt Exp $ */ +/* $OpenBSD: ip.c,v 1.25 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -154,7 +154,7 @@ ip_addr_check_overlap(const struct cert_ip *ip, const char *fn, memcmp(ips[i].min, ip->max, sz) >= 0) continue; socktype = (ips[i].afi == AFI_IPV4) ? AF_INET : AF_INET6, - warnx("%s: RFC 3779 section 2.2.3.5: " + warnx("%s: RFC 3779 section 2.2.3.5: " "cannot have overlapping IP addresses", fn); ip_addr_print(&ip->ip, ip->afi, buf, sizeof(buf)); warnx("%s: certificate IP: %s", fn, buf); diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c index 4b6f2ebde71..283d0e55afa 100644 --- a/usr.sbin/rpki-client/main.c +++ b/usr.sbin/rpki-client/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.203 2022/05/10 07:28:43 job Exp $ */ +/* $OpenBSD: main.c,v 1.204 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -727,7 +727,7 @@ main(int argc, char *argv[]) const char *cachedir = NULL, *outputdir = NULL; const char *errs, *name; struct vrp_tree vrps = RB_INITIALIZER(&vrps); - struct brk_tree brks = RB_INITIALIZER(&brks); + struct brk_tree brks = RB_INITIALIZER(&brks); struct rusage ru; struct timeval start_time, now_time; diff --git a/usr.sbin/rpki-client/output-bird.c b/usr.sbin/rpki-client/output-bird.c index eb0c98aa405..fa4211c9870 100644 --- a/usr.sbin/rpki-client/output-bird.c +++ b/usr.sbin/rpki-client/output-bird.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output-bird.c,v 1.13 2022/04/20 15:31:48 tb Exp $ */ +/* $OpenBSD: output-bird.c,v 1.14 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2019 Claudio Jeker * Copyright (c) 2020 Robert Scheck @@ -92,7 +92,7 @@ output_bird2(FILE *out, struct vrp_tree *vrps, struct brk_tree *brks, if (fprintf(out, "\ndefine force_roa_table_update = %lld;\n\n" "roa4 table %s4;\nroa6 table %s6;\n\n" "protocol static {\n\troa4 { table %s4; };\n\n", - (long long) now, bird_tablename, bird_tablename, + (long long)now, bird_tablename, bird_tablename, bird_tablename) < 0) return -1; diff --git a/usr.sbin/rpki-client/output-json.c b/usr.sbin/rpki-client/output-json.c index 781dc567442..bb404eff613 100644 --- a/usr.sbin/rpki-client/output-json.c +++ b/usr.sbin/rpki-client/output-json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output-json.c,v 1.25 2022/04/20 15:29:24 tb Exp $ */ +/* $OpenBSD: output-json.c,v 1.26 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2019 Claudio Jeker * @@ -25,10 +25,10 @@ static int outputheader_json(FILE *out, struct stats *st) { - char hn[NI_MAXHOST], tbuf[26]; + char hn[NI_MAXHOST], tbuf[26]; struct tm *tp; - time_t t; - int i; + time_t t; + int i; time(&t); tp = gmtime(&t); diff --git a/usr.sbin/rpki-client/print.c b/usr.sbin/rpki-client/print.c index ca0ce5d7c01..a625f2f151e 100644 --- a/usr.sbin/rpki-client/print.c +++ b/usr.sbin/rpki-client/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.12 2022/05/15 15:00:53 deraadt Exp $ */ +/* $OpenBSD: print.c,v 1.13 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -73,7 +73,6 @@ tal_print(const struct tal *p) int rder_len; size_t i; - der = p->pkey; pk = d2i_PUBKEY(NULL, &der, p->pkeysz); if (pk == NULL) @@ -242,7 +241,7 @@ cert_print(const struct cert *p) break; case CERT_IP_RANGE: sockt = (p->ips[j].afi == AFI_IPV4) ? - AF_INET : AF_INET6; + AF_INET : AF_INET6; inet_ntop(sockt, p->ips[j].min, buf1, sizeof(buf1)); inet_ntop(sockt, p->ips[j].max, buf2, sizeof(buf2)); if (outformats & FORMAT_JSON) @@ -375,8 +374,6 @@ mft_print(const X509 *x, const struct mft *p) if (outformats & FORMAT_JSON) printf("\t],\n"); - - } void @@ -406,7 +403,7 @@ roa_print(const X509 *x, const struct roa *p) printf("\t\"vrps\": [\n"); ip_addr_print(&p->ips[i].addr, - p->ips[i].afi, buf, sizeof(buf)); + p->ips[i].afi, buf, sizeof(buf)); if (outformats & FORMAT_JSON) { printf("\t\t{ \"prefix\": \"%s\",", buf); @@ -521,7 +518,7 @@ rsc_print(const X509 *x, const struct rsc *p) break; case CERT_IP_RANGE: sockt = (p->ips[j].afi == AFI_IPV4) ? - AF_INET : AF_INET6; + AF_INET : AF_INET6; inet_ntop(sockt, p->ips[j].min, buf1, sizeof(buf1)); inet_ntop(sockt, p->ips[j].max, buf2, sizeof(buf2)); if (outformats & FORMAT_JSON) diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c index ded44d53c82..89e1fab87c8 100644 --- a/usr.sbin/rpki-client/repo.c +++ b/usr.sbin/rpki-client/repo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repo.c,v 1.33 2022/04/20 15:31:48 tb Exp $ */ +/* $OpenBSD: repo.c,v 1.34 2022/05/15 16:43:34 tb Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -317,7 +317,7 @@ ta_filename(const struct tarepo *tr, int temp) assert(file); if (asprintf(&nfile, "%s%s%s", tr->basedir, file, - temp ? ".XXXXXXXX": "") == -1) + temp ? ".XXXXXXXX" : "") == -1) err(1, NULL); return nfile; @@ -513,7 +513,7 @@ rrdp_state_filename(const struct rrdprepo *rr, int temp) char *nfile; if (asprintf(&nfile, "%s/.state%s", rr->basedir, - temp ? ".XXXXXXXX": "") == -1) + temp ? ".XXXXXXXX" : "") == -1) err(1, NULL); return nfile; @@ -688,7 +688,7 @@ rrdp_save_state(unsigned int id, struct rrdp_session *state) warn("mkostemp %s", temp); goto fail; } - (void) fchmod(fd, 0644); + (void)fchmod(fd, 0644); f = fdopen(fd, "w"); if (f == NULL) err(1, "fdopen"); @@ -747,7 +747,6 @@ rrdp_get(const char *uri) RB_INIT(&rr->deleted); - /* create base directory */ if (mkpath(rr->basedir) == -1) { warn("mkpath %s", rr->basedir); @@ -995,8 +994,6 @@ http_finish(unsigned int id, enum http_result res, const char *last_mod) } } - - /* * Look up a trust anchor, queueing it for download if not found. */ diff --git a/usr.sbin/rpki-client/roa.c b/usr.sbin/rpki-client/roa.c index 144335b5f0a..a03efc6086f 100644 --- a/usr.sbin/rpki-client/roa.c +++ b/usr.sbin/rpki-client/roa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roa.c,v 1.41 2022/05/10 07:28:43 job Exp $ */ +/* $OpenBSD: roa.c,v 1.42 2022/05/15 16:43:35 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -390,7 +390,6 @@ out: } free(cms); return p.res; - } /* diff --git a/usr.sbin/rpki-client/rrdp.c b/usr.sbin/rpki-client/rrdp.c index 90de0677fa7..3114de481a9 100644 --- a/usr.sbin/rpki-client/rrdp.c +++ b/usr.sbin/rpki-client/rrdp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rrdp.c,v 1.23 2022/04/04 13:45:02 claudio Exp $ */ +/* $OpenBSD: rrdp.c,v 1.24 2022/05/15 16:43:35 tb Exp $ */ /* * Copyright (c) 2020 Nils Fisher * Copyright (c) 2021 Claudio Jeker @@ -73,7 +73,7 @@ struct rrdp { struct delta_xml *dxml; }; -TAILQ_HEAD(,rrdp) states = TAILQ_HEAD_INITIALIZER(states); +TAILQ_HEAD(, rrdp) states = TAILQ_HEAD_INITIALIZER(states); char * xstrdup(const char *s) diff --git a/usr.sbin/rpki-client/rrdp_delta.c b/usr.sbin/rpki-client/rrdp_delta.c index 3a8629ad98f..97b563daa9b 100644 --- a/usr.sbin/rpki-client/rrdp_delta.c +++ b/usr.sbin/rpki-client/rrdp_delta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rrdp_delta.c,v 1.7 2022/02/03 18:19:32 claudio Exp $ */ +/* $OpenBSD: rrdp_delta.c,v 1.8 2022/05/15 16:43:35 tb Exp $ */ /* * Copyright (c) 2020 Nils Fisher * Copyright (c) 2021 Claudio Jeker @@ -109,7 +109,6 @@ end_delta_elem(struct delta_xml *dxml) PARSE_FAIL(p, "parse failed - exited delta " "elem unexpectedely"); dxml->scope = DELTA_SCOPE_END; - } static void diff --git a/usr.sbin/rpki-client/rsc.c b/usr.sbin/rpki-client/rsc.c index 9561547d238..7e7177a6df9 100644 --- a/usr.sbin/rpki-client/rsc.c +++ b/usr.sbin/rpki-client/rsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsc.c,v 1.3 2022/05/15 15:00:53 deraadt Exp $ */ +/* $OpenBSD: rsc.c,v 1.4 2022/05/15 16:43:35 tb Exp $ */ /* * Copyright (c) 2022 Job Snijders * Copyright (c) 2019 Kristaps Dzonsons @@ -192,7 +192,8 @@ rsc_parse_filenamehash(struct parse *p, const ASN1_OCTET_STRING *os) rent = &p->res->files[p->res->filesz++]; rent->filename = fn; fn = NULL; - memcpy(rent->hash, hash->value.octet_string->data, SHA256_DIGEST_LENGTH); + memcpy(rent->hash, hash->value.octet_string->data, + SHA256_DIGEST_LENGTH); rc = 1; out: @@ -545,7 +546,7 @@ rsc_parse_resourceblock(const ASN1_OCTET_STRING *os, struct parse *p) default: warnx("%s: want ASN.1 context specific id, have %s" " (NID %d)", p->fn, ASN1_tag2str(ptag), ptag); - goto out; + goto out; } } @@ -574,7 +575,7 @@ rsc_parse_econtent(const unsigned char *d, size_t dsz, struct parse *p) if ((seq = d2i_ASN1_SEQUENCE_ANY(NULL, &d, dsz)) == NULL) { cryptowarnx("%s: RSC: RpkiSignedChecklist: failed ASN.1 " - "sequence parse", p->fn); + "sequence parse", p->fn); goto out; } diff --git a/usr.sbin/rpki-client/tal.c b/usr.sbin/rpki-client/tal.c index 1eb5067c122..aad992c91ab 100644 --- a/usr.sbin/rpki-client/tal.c +++ b/usr.sbin/rpki-client/tal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tal.c,v 1.34 2021/11/04 11:32:55 claudio Exp $ */ +/* $OpenBSD: tal.c,v 1.35 2022/05/15 16:43:35 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -98,7 +98,7 @@ tal_parse_buffer(const char *fn, char *buf, size_t len) /* Append to list of URIs. */ tal->uri = reallocarray(tal->uri, - tal->urisz + 1, sizeof(char *)); + tal->urisz + 1, sizeof(char *)); if (tal->uri == NULL) err(1, NULL); diff --git a/usr.sbin/rpki-client/validate.c b/usr.sbin/rpki-client/validate.c index b06eae21175..8d01041c991 100644 --- a/usr.sbin/rpki-client/validate.c +++ b/usr.sbin/rpki-client/validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: validate.c,v 1.37 2022/05/15 16:40:43 tb Exp $ */ +/* $OpenBSD: validate.c,v 1.38 2022/05/15 16:43:35 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -230,10 +230,10 @@ valid_roa(const char *fn, struct auth *a, struct roa *roa) int valid_filehash(int fd, const char *hash, size_t hlen) { - SHA256_CTX ctx; - char filehash[SHA256_DIGEST_LENGTH]; - char buffer[8192]; - ssize_t nr; + SHA256_CTX ctx; + char filehash[SHA256_DIGEST_LENGTH]; + char buffer[8192]; + ssize_t nr; if (hlen != sizeof(filehash)) errx(1, "bad hash size"); diff --git a/usr.sbin/rpki-client/x509.c b/usr.sbin/rpki-client/x509.c index 0751b8e88e5..9f226bc7f5e 100644 --- a/usr.sbin/rpki-client/x509.c +++ b/usr.sbin/rpki-client/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.44 2022/05/11 21:19:06 job Exp $ */ +/* $OpenBSD: x509.c,v 1.45 2022/05/15 16:43:35 tb Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -80,7 +80,6 @@ x509_init_oid(void) if ((rsc_oid = OBJ_txt2obj("1.2.840.113549.1.9.16.1.48", 1)) == NULL) errx(1, "OBJ_txt2obj for %s failed", "1.2.840.113549.1.9.16.1.48"); - } /* @@ -345,7 +344,6 @@ x509_get_expire(X509 *x, const char *fn, time_t *tt) return 0; } return 1; - } /* -- 2.20.1