clang-format

This commit is contained in:
2024-09-10 13:03:02 -04:00
parent 53c617d779
commit d66450e427
381 changed files with 28864 additions and 34170 deletions

View File

@@ -58,63 +58,50 @@ static size_t outbufpos;
/*
* Print things.
*/
static
void
vsay(const char *fmt, va_list ap)
{
size_t begin, i;
static void vsay(const char *fmt, va_list ap) {
size_t begin, i;
assert(outbufpos < sizeof(outbuf));
assert(outbufpos < sizeof(outbuf));
begin = outbufpos;
vsnprintf(outbuf + outbufpos, sizeof(outbuf) - outbufpos, fmt, ap);
outbufpos = strlen(outbuf);
begin = outbufpos;
vsnprintf(outbuf + outbufpos, sizeof(outbuf) - outbufpos, fmt, ap);
outbufpos = strlen(outbuf);
for (i=begin; i<outbufpos; i++) {
if (outbuf[i] == '\n') {
horizpos = 0;
}
else {
horizpos++;
}
}
for (i = begin; i < outbufpos; i++) {
if (outbuf[i] == '\n') {
horizpos = 0;
} else {
horizpos++;
}
}
}
static
void
say(const char *fmt, ...)
{
va_list ap;
static void say(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vsay(fmt, ap);
va_end(ap);
va_start(ap, fmt);
vsay(fmt, ap);
va_end(ap);
}
/*
* Indent to a given horizontal position.
*/
static
void
indent_to(size_t pos)
{
while (horizpos < pos) {
assert(outbufpos < sizeof(outbuf) - 1);
outbuf[outbufpos++] = ' ';
outbuf[outbufpos] = 0;
horizpos++;
}
static void indent_to(size_t pos) {
while (horizpos < pos) {
assert(outbufpos < sizeof(outbuf) - 1);
outbuf[outbufpos++] = ' ';
outbuf[outbufpos] = 0;
horizpos++;
}
}
/*
* Flush the output.
*/
static
void
flush(void)
{
write(STDOUT_FILENO, outbuf, outbufpos);
outbufpos = 0;
static void flush(void) {
write(STDOUT_FILENO, outbuf, outbufpos);
outbufpos = 0;
}
////////////////////////////////////////////////////////////
@@ -123,28 +110,24 @@ flush(void)
* Begin a test. This flushes the description so it can be seen before
* the test happens, in case the test explodes or deadlocks the system.
*/
void
report_begin(const char *descfmt, ...)
{
va_list ap;
void report_begin(const char *descfmt, ...) {
va_list ap;
say("badcall: ");
va_start(ap, descfmt);
vsay(descfmt, ap);
va_end(ap);
say("... ");
flush();
say("badcall: ");
va_start(ap, descfmt);
vsay(descfmt, ap);
va_end(ap);
say("... ");
flush();
}
/*
* Prepare to be able to print subreports.
*/
void
report_hassubs(void)
{
subpos = horizpos;
say("\n");
flush();
void report_hassubs(void) {
subpos = horizpos;
say("\n");
flush();
}
/*
@@ -152,17 +135,15 @@ report_hassubs(void)
* subreports are in subprocesses and we want each one to print a
* whole line at once to avoid output interleaving.
*/
void
report_beginsub(const char *descfmt, ...)
{
va_list ap;
void report_beginsub(const char *descfmt, ...) {
va_list ap;
assert(horizpos == 0);
say(" ");
va_start(ap, descfmt);
vsay(descfmt, ap);
va_end(ap);
indent_to(subpos);
assert(horizpos == 0);
say(" ");
va_start(ap, descfmt);
vsay(descfmt, ap);
va_end(ap);
indent_to(subpos);
}
/*
@@ -170,52 +151,45 @@ report_beginsub(const char *descfmt, ...)
* extra line for the warning. The warnx form is the same but doesn't
* add errno.
*/
void
report_warn(const char *fmt, ...)
{
size_t pos;
const char *errmsg;
va_list ap;
void report_warn(const char *fmt, ...) {
size_t pos;
const char *errmsg;
va_list ap;
pos = horizpos;
errmsg = strerror(errno);
say("\n OOPS: ");
va_start(ap, fmt);
vsay(fmt, ap);
va_end(ap);
say(": %s\n", errmsg);
indent_to(pos);
flush();
pos = horizpos;
errmsg = strerror(errno);
say("\n OOPS: ");
va_start(ap, fmt);
vsay(fmt, ap);
va_end(ap);
say(": %s\n", errmsg);
indent_to(pos);
flush();
}
void
report_warnx(const char *fmt, ...)
{
size_t pos;
va_list ap;
void report_warnx(const char *fmt, ...) {
size_t pos;
va_list ap;
pos = horizpos;
say("\n oops: ");
va_start(ap, fmt);
vsay(fmt, ap);
va_end(ap);
say("\n");
indent_to(pos);
flush();
pos = horizpos;
say("\n oops: ");
va_start(ap, fmt);
vsay(fmt, ap);
va_end(ap);
say("\n");
indent_to(pos);
flush();
}
/*
* Report a system call result.
*/
void
report_result(int rv, int error)
{
if (rv == -1) {
say("%s ", strerror(error));
}
else {
say("Success ");
}
void report_result(int rv, int error) {
if (rv == -1) {
say("%s ", strerror(error));
} else {
say("Success ");
}
}
/*
@@ -227,13 +201,11 @@ report_result(int rv, int error)
*
* XXX this is pretty gross.
*/
void
report_saw_enosys(void)
{
size_t pos = horizpos;
void report_saw_enosys(void) {
size_t pos = horizpos;
horizpos = 0;
indent_to(pos);
horizpos = 0;
indent_to(pos);
}
/*
@@ -241,38 +213,19 @@ report_saw_enosys(void)
* in the result column, and add the final newline.
*/
static
void
report_end(const char *msg)
{
indent_to(RESULT_COLUMN);
say("%s\n", msg);
flush();
static void report_end(const char *msg) {
indent_to(RESULT_COLUMN);
say("%s\n", msg);
flush();
}
void
report_passed(void)
{
report_end("passed");
}
void report_passed(void) { report_end("passed"); }
void
report_failure(void)
{
report_end("FAILURE");
}
void report_failure(void) { report_end("FAILURE"); }
void
report_skipped(void)
{
report_end("------");
}
void report_skipped(void) { report_end("------"); }
void
report_aborted(void)
{
report_end("ABORTED");
}
void report_aborted(void) { report_end("ABORTED"); }
////////////////////////////////////////////////////////////
@@ -282,69 +235,56 @@ report_aborted(void)
* matches one or more expected results.
*/
void
report_survival(int rv, int error)
{
/* allow any error as long as we survive */
report_result(rv, error);
report_passed();
void report_survival(int rv, int error) {
/* allow any error as long as we survive */
report_result(rv, error);
report_passed();
}
static
void
report_checkN(int rv, int error, int *right_errors, int right_num)
{
int i, goterror;
static void report_checkN(int rv, int error, int *right_errors, int right_num) {
int i, goterror;
if (rv==-1) {
goterror = error;
}
else {
goterror = 0;
}
if (rv == -1) {
goterror = error;
} else {
goterror = 0;
}
for (i=0; i<right_num; i++) {
if (goterror == right_errors[i]) {
report_result(rv, error);
report_passed();
return;
}
}
for (i = 0; i < right_num; i++) {
if (goterror == right_errors[i]) {
report_result(rv, error);
report_passed();
return;
}
}
if (goterror == ENOSYS) {
report_saw_enosys();
say("(unimplemented) ");
report_skipped();
}
else {
report_result(rv, error);
report_failure();
}
if (goterror == ENOSYS) {
report_saw_enosys();
say("(unimplemented) ");
report_skipped();
} else {
report_result(rv, error);
report_failure();
}
}
void
report_check(int rv, int error, int right_error)
{
report_checkN(rv, error, &right_error, 1);
void report_check(int rv, int error, int right_error) {
report_checkN(rv, error, &right_error, 1);
}
void
report_check2(int rv, int error, int okerr1, int okerr2)
{
int ok[2];
void report_check2(int rv, int error, int okerr1, int okerr2) {
int ok[2];
ok[0] = okerr1;
ok[1] = okerr2;
report_checkN(rv, error, ok, 2);
ok[0] = okerr1;
ok[1] = okerr2;
report_checkN(rv, error, ok, 2);
}
void
report_check3(int rv, int error, int okerr1, int okerr2, int okerr3)
{
int ok[3];
void report_check3(int rv, int error, int okerr1, int okerr2, int okerr3) {
int ok[3];
ok[0] = okerr1;
ok[1] = okerr2;
ok[2] = okerr3;
report_checkN(rv, error, ok, 3);
ok[0] = okerr1;
ok[1] = okerr2;
ok[2] = okerr3;
report_checkN(rv, error, ok, 3);
}