Apply clang-format update to repo (#1154)

Commit bc6c183 introduced a bunch of discrepancies between what files
look like in the repo and what clang-format says they should look like.
However, there were already a few discrepancies prior to that. Most of
these discrepancies seemed to be unintentional, but a few of them were
load-bearing (e.g., a #include that violated header ordering needing
something to have been #defined by a 'later' #include.)

I opted to take what I hope is a relatively smooth-brained approach: I
reverted the .clang-format change, ran clang-format on the whole repo,
reapplied the .clang-format change, reran clang-format again, and then
reverted the commit that contained the first run. Thus the full effect
of this PR should only be to apply the changed formatting rules to the
repo, and from skimming the results, this seems to be the case.

My work can be checked by applying the short, manual commits, and then
rerunning the command listed in the autogenerated commits (those whose
messages I have prefixed auto:) and seeing if your results agree.

It might be that the other diffs should be fixed at some point but I'm
leaving that aside for now.

fd '\.c(c|pp)?$' --print0| xargs -0 clang-format -i
This commit is contained in:
Jōshin 2024-04-25 10:38:00 -07:00 committed by GitHub
parent 342d0c81e5
commit 6e6fc38935
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
863 changed files with 9201 additions and 4627 deletions

View file

@ -65,8 +65,10 @@ static ssize_t EzWritevAll(int fd, struct iovec *iov, int iovlen) {
total = 0;
do {
if (i) {
while (i < iovlen && !iov[i].iov_len) ++i;
if (i == iovlen) break;
while (i < iovlen && !iov[i].iov_len)
++i;
if (i == iovlen)
break;
}
if ((rc = writev(fd, iov + i, iovlen - i)) != -1) {
wrote = rc;
@ -99,7 +101,8 @@ int EzTlsFlush(struct EzTlsBio *bio, const unsigned char *buf, size_t len) {
v[1].iov_base = (void *)buf;
v[1].iov_len = len;
if (EzWritevAll(bio->fd, v, 2) != -1) {
if (bio->c > 0) bio->c = 0;
if (bio->c > 0)
bio->c = 0;
} else if (errno == EAGAIN) {
return MBEDTLS_ERR_SSL_TIMEOUT;
} else if (errno == EPIPE || errno == ECONNRESET || errno == ENETRESET) {
@ -121,7 +124,8 @@ static int EzTlsSend(void *ctx, const unsigned char *buf, size_t len) {
bio->c += len;
return len;
}
if ((rc = EzTlsFlush(bio, buf, len)) < 0) return rc;
if ((rc = EzTlsFlush(bio, buf, len)) < 0)
return rc;
return len;
}
@ -130,11 +134,13 @@ static int EzTlsRecvImpl(void *ctx, unsigned char *p, size_t n, uint32_t o) {
int r;
struct iovec v[2];
struct EzTlsBio *bio = ctx;
if ((r = EzTlsFlush(bio, 0, 0)) < 0) return r;
if ((r = EzTlsFlush(bio, 0, 0)) < 0)
return r;
if (bio->a < bio->b) {
r = MIN(n, bio->b - bio->a);
memcpy(p, bio->t + bio->a, r);
if ((bio->a += r) == bio->b) bio->a = bio->b = 0;
if ((bio->a += r) == bio->b)
bio->a = bio->b = 0;
return r;
}
v[0].iov_base = p;
@ -153,7 +159,8 @@ static int EzTlsRecvImpl(void *ctx, unsigned char *p, size_t n, uint32_t o) {
return MBEDTLS_ERR_NET_RECV_FAILED;
}
}
if (r > n) bio->b = r - n;
if (r > n)
bio->b = r - n;
return MIN(n, r);
}
@ -237,7 +244,8 @@ void EzSetup(char psk[32]) {
}
void EzDestroy(void) {
if (!mytid) return;
if (!mytid)
return;
EzSanity();
mbedtls_ssl_free(&ezssl);
mbedtls_ctr_drbg_free(&ezrng);