Rerun clang-format on the repo

🚨 clang-format changes output per version!

This is with version 18.1.0. The modifications seem to be fixing the old
version's errors - mainly involving omitted whitespace around binary ops
and inserted whitespace between goto labels and colons (if followed by a
curly brace.)

Also fixes a few mistakes made by e.g. someone (ahem) forgetting to pass
his ctl/string.h modifications through it.

We should add this to .git-blame-ignore-revs once we have its final hash
on master.
This commit is contained in:
Jōshin 2024-06-15 13:09:27 -07:00
parent 8e37ee2598
commit ef1647ca79
No known key found for this signature in database
38 changed files with 141 additions and 129 deletions

View file

@ -84,7 +84,8 @@
/* clang-format on */
#elif defined(__LINKER__)
#define BCX_NIBBLE(X) ((((X)&0xf) > 0x9) ? ((X)&0xf) + 0x37 : ((X)&0xf) + 0x30)
#define BCX_NIBBLE(X) \
((((X) & 0xf) > 0x9) ? ((X) & 0xf) + 0x37 : ((X) & 0xf) + 0x30)
#define BCX_OCTET(X) ((BCX_NIBBLE((X) >> 4) << 8) | (BCX_NIBBLE((X) >> 0) << 0))
#define BCX_INT16(X) ((BCX_OCTET((X) >> 8) << 16) | (BCX_OCTET((X) >> 0) << 0))
#define BCXSTUB(SYM, X) \

View file

@ -23,8 +23,7 @@ struct sock_fprog {
#define BPF_TAX 0x00
#define BPF_TXA 0x80
#define BPF_STMT(code, k) \
{ (unsigned short)(code), 0, 0, k }
#define BPF_STMT(code, k) {(unsigned short)(code), 0, 0, k}
#define BPF_JUMP(code, k, jumptrue, jumpfalse) \
{(unsigned short)(code), jumptrue, jumpfalse, k}

View file

@ -50,11 +50,13 @@ struct magicu __magicu_get(uint32_t d) {
p32 = 2 * p32;
}
if (r + 1 >= d - r) {
if (q >= 0x7FFFFFFF) a = 1;
if (q >= 0x7FFFFFFF)
a = 1;
q = 2 * q + 1; // Update q.
r = 2 * r + 1 - d; // Update r.
} else {
if (q >= 0x80000000) a = 1;
if (q >= 0x80000000)
a = 1;
q = 2 * q;
r = 2 * r + 1;
}
@ -62,7 +64,8 @@ struct magicu __magicu_get(uint32_t d) {
} while (p < 64 && p32 < delta);
magu.M = q + 1; // Magic number and
magu.s = p - 32; // Shift amount to return
if (a) magu.s |= 64; // Sets "add" indicator
if (a)
magu.s |= 64; // Sets "add" indicator
npassert(magu.M || magu.s); // Never returns zero.
return magu;
}

View file

@ -24,8 +24,10 @@ forceinline uint32_t __magicu_div(uint32_t x, struct magicu d) {
* Checks if 𝑑 contains a valid initialized divisor.
*/
static inline bool32 __magicu_valid(struct magicu d) {
if (!d.M && !d.s) return false; /* uninitialized */
if (d.s & ~(64 | 63)) return false; /* corrupted */
if (!d.M && !d.s)
return false; /* uninitialized */
if (d.s & ~(64 | 63))
return false; /* corrupted */
return true;
}

View file

@ -68,6 +68,7 @@ char *GetInterpreterExecutableName(char *p, size_t n) {
p[rc] = 0;
return p;
} else if (IsFreebsd() || IsNetbsd()) {
// clang-format off
cmd[0] = 1; // CTL_KERN
cmd[1] = 14; // KERN_PROC
if (IsFreebsd()) { //
@ -76,6 +77,7 @@ char *GetInterpreterExecutableName(char *p, size_t n) {
cmd[2] = 5; // KERN_PROC_PATHNAME
} //
cmd[3] = -1; // current process
// clang-format on
if (sysctl(cmd, ARRAYLEN(cmd), p, &n, 0, 0) != -1) {
errno = e;
return p;

View file

@ -108,8 +108,7 @@ https://github.com/piscisaureus/wepoll");
(EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDNORM | \
EPOLLRDBAND | EPOLLWRNORM | EPOLLWRBAND | EPOLLMSG | EPOLLRDHUP)
#define RTL_CONSTANT_STRING(s) \
{ sizeof(s) - sizeof((s)[0]), sizeof(s), s }
#define RTL_CONSTANT_STRING(s) {sizeof(s) - sizeof((s)[0]), sizeof(s), s}
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(ObjectName, Attributes) \
{sizeof(struct NtObjectAttributes), 0, ObjectName, Attributes, NULL, NULL}

View file

@ -117,7 +117,14 @@ main()
}
{
struct A { int* p = &g; A() {++*p; } };
struct A
{
int* p = &g;
A()
{
++*p;
}
};
ctl::optional<A> x;
if (g != 0)
return 25;

View file

@ -22,7 +22,6 @@
#include "libc/runtime/runtime.h"
#include "libc/testlib/ezbench.h"
#include "libc/testlib/testlib.h"
#include "libc/intrin/magicu.h"
#define T uint32_t
#define TBIT (sizeof(T) * CHAR_BIT - 1)

View file

@ -30,8 +30,7 @@
#define OPEN_MAX 16
#define I(x, y) \
{ x, y, 0, (y - x) * FRAMESIZE + FRAMESIZE }
#define I(x, y) {x, y, 0, (y - x) * FRAMESIZE + FRAMESIZE}
void SetUpOnce(void) {
ASSERT_SYS(0, 0, pledge("stdio rpath", 0));

View file

@ -49,7 +49,8 @@ long unsharp(long cn, long yw, long xw, unsigned char img[cn][yw][xw], long yn,
}
if (y < yn) {
for (x = 0; x < xn; ++x) {
(*t)[y % 3][x] = CONVOLVE5X5(/* clang-format off */
(*t)[y % 3][x] =
CONVOLVE5X5(/* clang-format off */
7, (-1 / 256.), img[c],
1, 4, 6, 4, 1,
4, 16, 24, 16, 4,