obmc-console: Add clang-format configuration
And apply the formatting.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I75251051affa5129c8698185baf8d151302b19d6
diff --git a/test/ringbuffer-test-utils.c b/test/ringbuffer-test-utils.c
index bbe688a..9172648 100644
--- a/test/ringbuffer-test-utils.c
+++ b/test/ringbuffer-test-utils.c
@@ -1,11 +1,11 @@
struct rb_test_ctx {
- struct ringbuffer_consumer *rbc;
- bool ignore_poll;
- bool force_only;
- int count;
- uint8_t *data;
- int len;
+ struct ringbuffer_consumer *rbc;
+ bool ignore_poll;
+ bool force_only;
+ int count;
+ uint8_t *data;
+ int len;
};
void ringbuffer_test_context_init(struct rb_test_ctx *ctx)
@@ -22,15 +22,15 @@
free(ctx->data);
}
-enum ringbuffer_poll_ret ringbuffer_poll_nop(
- void *data __attribute__((unused)),
- size_t force_len __attribute__((unused)))
+enum ringbuffer_poll_ret ringbuffer_poll_nop(void *data __attribute__((unused)),
+ size_t force_len
+ __attribute__((unused)))
{
return RINGBUFFER_POLL_OK;
}
enum ringbuffer_poll_ret ringbuffer_poll_append_all(void *data,
- size_t force_len)
+ size_t force_len)
{
struct rb_test_ctx *ctx = data;
size_t len, total_len;
@@ -73,7 +73,7 @@
int j;
printf("---- ringbuffer (%d consumer%s)\n", rb->n_consumers,
- rb->n_consumers == 1 ? "" : "s");
+ rb->n_consumers == 1 ? "" : "s");
for (i = 0; i < rb->size; i++) {
bool has_consumer = false;
@@ -95,4 +95,3 @@
printf("\n");
}
}
-
diff --git a/test/test-client-escape.c b/test/test-client-escape.c
index 6567024..43998fc 100644
--- a/test/test-client-escape.c
+++ b/test/test-client-escape.c
@@ -27,127 +27,126 @@
#undef main
struct test {
- enum esc_type esc_type;
+ enum esc_type esc_type;
union {
struct ssh_esc_state ssh;
struct str_esc_state str;
} esc_state;
- const char *in[4];
- size_t n_in;
- const char *exp_out;
- int exp_rc;
+ const char *in[4];
+ size_t n_in;
+ const char *exp_out;
+ int exp_rc;
};
struct test_ctx {
- struct console_client client;
- struct test *test;
- uint8_t out[4096];
- size_t cur_in;
- size_t cur_out;
+ struct console_client client;
+ struct test *test;
+ uint8_t out[4096];
+ size_t cur_in;
+ size_t cur_out;
};
-
struct test tests[] = {
{
/* no escape code */
- .esc_type = ESC_TYPE_SSH,
- .in = {"a"},
- .n_in = 1,
- .exp_out = "a",
- .exp_rc = PROCESS_EXIT,
+ .esc_type = ESC_TYPE_SSH,
+ .in = { "a" },
+ .n_in = 1,
+ .exp_out = "a",
+ .exp_rc = PROCESS_EXIT,
},
{
/* no escape code, multiple reads */
- .esc_type = ESC_TYPE_SSH,
- .in = {"a", "b"},
- .n_in = 2,
- .exp_out = "ab",
- .exp_rc = PROCESS_EXIT,
+ .esc_type = ESC_TYPE_SSH,
+ .in = { "a", "b" },
+ .n_in = 2,
+ .exp_out = "ab",
+ .exp_rc = PROCESS_EXIT,
},
{
/* ssh escape in one read */
- .esc_type = ESC_TYPE_SSH,
- .in = {"a\r~."},
- .n_in = 1,
- .exp_out = "a\r",
- .exp_rc = PROCESS_ESC,
+ .esc_type = ESC_TYPE_SSH,
+ .in = { "a\r~." },
+ .n_in = 1,
+ .exp_out = "a\r",
+ .exp_rc = PROCESS_ESC,
},
{
/* ssh escape, partial ~ is not output. */
- .esc_type = ESC_TYPE_SSH,
- .in = {"a\r~"},
- .n_in = 1,
- .exp_out = "a\r",
- .exp_rc = PROCESS_EXIT,
+ .esc_type = ESC_TYPE_SSH,
+ .in = { "a\r~" },
+ .n_in = 1,
+ .exp_out = "a\r",
+ .exp_rc = PROCESS_EXIT,
},
{
/* ssh escape split into individual reads */
- .esc_type = ESC_TYPE_SSH,
- .in = {"a", "\r", "~", "."},
- .n_in = 4,
- .exp_out = "a\r",
- .exp_rc = PROCESS_ESC,
+ .esc_type = ESC_TYPE_SSH,
+ .in = { "a", "\r", "~", "." },
+ .n_in = 4,
+ .exp_out = "a\r",
+ .exp_rc = PROCESS_ESC,
},
{
/* ssh escape, escaped. */
- .esc_type = ESC_TYPE_SSH,
- .in = {"a\r~~."},
- .n_in = 1,
- .exp_out = "a\r~.",
- .exp_rc = PROCESS_EXIT,
+ .esc_type = ESC_TYPE_SSH,
+ .in = { "a\r~~." },
+ .n_in = 1,
+ .exp_out = "a\r~.",
+ .exp_rc = PROCESS_EXIT,
},
{
/* ssh escape, escaped ~, and not completed. */
- .esc_type = ESC_TYPE_SSH,
- .in = {"a\r~~"},
- .n_in = 1,
- .exp_out = "a\r~",
- .exp_rc = PROCESS_EXIT,
+ .esc_type = ESC_TYPE_SSH,
+ .in = { "a\r~~" },
+ .n_in = 1,
+ .exp_out = "a\r~",
+ .exp_rc = PROCESS_EXIT,
},
{
/* str escape, no match */
- .esc_type = ESC_TYPE_STR,
- .esc_state = { .str = { .str = (const uint8_t *)"c" } },
- .in = {"ab"},
- .n_in = 1,
- .exp_out = "ab",
- .exp_rc = PROCESS_EXIT,
+ .esc_type = ESC_TYPE_STR,
+ .esc_state = { .str = { .str = (const uint8_t *)"c" } },
+ .in = { "ab" },
+ .n_in = 1,
+ .exp_out = "ab",
+ .exp_rc = PROCESS_EXIT,
},
{
/* str escape, one byte, as one read */
- .esc_type = ESC_TYPE_STR,
- .esc_state = { .str = { .str = (const uint8_t *)"b" } },
- .in = {"abc"},
- .n_in = 1,
- .exp_out = "ab",
- .exp_rc = PROCESS_ESC,
+ .esc_type = ESC_TYPE_STR,
+ .esc_state = { .str = { .str = (const uint8_t *)"b" } },
+ .in = { "abc" },
+ .n_in = 1,
+ .exp_out = "ab",
+ .exp_rc = PROCESS_ESC,
},
{
/* str escape, multiple bytes, as one read */
- .esc_type = ESC_TYPE_STR,
- .esc_state = { .str = { .str = (const uint8_t *)"bc" } },
- .in = {"abcd"},
- .n_in = 1,
- .exp_out = "abc",
- .exp_rc = PROCESS_ESC,
+ .esc_type = ESC_TYPE_STR,
+ .esc_state = { .str = { .str = (const uint8_t *)"bc" } },
+ .in = { "abcd" },
+ .n_in = 1,
+ .exp_out = "abc",
+ .exp_rc = PROCESS_ESC,
},
{
/* str escape, multiple bytes, split over reads */
- .esc_type = ESC_TYPE_STR,
- .esc_state = { .str = { .str = (const uint8_t *)"bc" } },
- .in = {"ab", "cd"},
- .n_in = 2,
- .exp_out = "abc",
- .exp_rc = PROCESS_ESC,
+ .esc_type = ESC_TYPE_STR,
+ .esc_state = { .str = { .str = (const uint8_t *)"bc" } },
+ .in = { "ab", "cd" },
+ .n_in = 2,
+ .exp_out = "abc",
+ .exp_rc = PROCESS_ESC,
},
{
/* str escape, not matched due to intermediate data */
- .esc_type = ESC_TYPE_STR,
- .esc_state = { .str = { .str = (const uint8_t *)"ab" } },
- .in = {"acb"},
- .n_in = 1,
- .exp_out = "acb",
- .exp_rc = PROCESS_EXIT,
+ .esc_type = ESC_TYPE_STR,
+ .esc_state = { .str = { .str = (const uint8_t *)"ab" } },
+ .in = { "acb" },
+ .n_in = 1,
+ .exp_out = "acb",
+ .exp_rc = PROCESS_EXIT,
},
};
@@ -195,7 +194,7 @@
ctx->client.fd_in = idx;
ctx->client.esc_type = test->esc_type;
memcpy(&ctx->client.esc_state, &test->esc_state,
- sizeof(test->esc_state));
+ sizeof(test->esc_state));
ctx->test = test;
for (;;) {
@@ -207,9 +206,8 @@
exp_out_len = strlen(test->exp_out);
#ifdef DEBUG
- printf("got: rc %d %s(%d), exp: rc %d %s(%ld)\n",
- rc, ctx->out, ctx->cur_out,
- test->exp_rc, test->exp_out, exp_out_len);
+ printf("got: rc %d %s(%d), exp: rc %d %s(%ld)\n", rc, ctx->out,
+ ctx->cur_out, test->exp_rc, test->exp_out, exp_out_len);
fflush(stdout);
#endif
assert(rc == test->exp_rc);
diff --git a/test/test-config-parse-logsize.c b/test/test-config-parse-logsize.c
index d6b4873..482932e 100644
--- a/test/test-config-parse-logsize.c
+++ b/test/test-config-parse-logsize.c
@@ -11,36 +11,36 @@
#include "config.c"
struct test_parse_size_unit {
- const char *test_str;
- size_t expected_size;
- int expected_rc;
+ const char *test_str;
+ size_t expected_size;
+ int expected_rc;
};
void test_config_parse_logsize(void)
{
const struct test_parse_size_unit test_data[] = {
- {"0", 0, -1},
- {"1", 1, 0},
- {"4k", 4*1024, 0},
- {"6M", (6ul << 20), 0},
- {"4095M", (4095ul << 20), 0},
- {"2G", (2ul << 30), 0},
- {"8M\n", (8ul << 20), 0}, /* Suffix ignored */
- {" 10k", 10*1024, 0}, /* Leading spaces trimmed */
- {"10k ", 10*1024, 0}, /* Trailing spaces trimmed */
- {"\r\t10k \r\t",10*1024, 0}, /* Spaces trimmed */
- {" 10 kB ", 10*1024, 0}, /* Spaces trimmed */
- {"11G", 0, -1}, /* Overflow */
- {"4294967296", 0, -1}, /* Overflow */
- {"4096M", 0, -1}, /* Overflow */
- {"65535G", 0, -1}, /* Overflow */
- {"xyz", 0, -1}, /* Invalid */
- {"000", 0, -1}, /* Invalid */
- {"0.1", 0, -1}, /* Invalid */
- {"9T", 0, -1}, /* Invalid suffix */
+ { "0", 0, -1 },
+ { "1", 1, 0 },
+ { "4k", 4 * 1024, 0 },
+ { "6M", (6ul << 20), 0 },
+ { "4095M", (4095ul << 20), 0 },
+ { "2G", (2ul << 30), 0 },
+ { "8M\n", (8ul << 20), 0 }, /* Suffix ignored */
+ { " 10k", 10 * 1024, 0 }, /* Leading spaces trimmed */
+ { "10k ", 10 * 1024, 0 }, /* Trailing spaces trimmed */
+ { "\r\t10k \r\t", 10 * 1024, 0 }, /* Spaces trimmed */
+ { " 10 kB ", 10 * 1024, 0 }, /* Spaces trimmed */
+ { "11G", 0, -1 }, /* Overflow */
+ { "4294967296", 0, -1 }, /* Overflow */
+ { "4096M", 0, -1 }, /* Overflow */
+ { "65535G", 0, -1 }, /* Overflow */
+ { "xyz", 0, -1 }, /* Invalid */
+ { "000", 0, -1 }, /* Invalid */
+ { "0.1", 0, -1 }, /* Invalid */
+ { "9T", 0, -1 }, /* Invalid suffix */
};
- const size_t num_tests = sizeof(test_data) /
- sizeof(struct test_parse_size_unit);
+ const size_t num_tests =
+ sizeof(test_data) / sizeof(struct test_parse_size_unit);
size_t size;
size_t i;
int rc;
@@ -49,17 +49,13 @@
rc = config_parse_logsize(test_data[i].test_str, &size);
if (rc == -1 && rc != test_data[i].expected_rc) {
- warn("[%zu] Str %s expected rc %d, got rc %d\n",
- i,
- test_data[i].test_str,
- test_data[i].expected_rc,
+ warn("[%zu] Str %s expected rc %d, got rc %d\n", i,
+ test_data[i].test_str, test_data[i].expected_rc,
rc);
} else if (rc == 0 && test_data[i].expected_size != size) {
warn("[%zu] Str %s expected size %lu, got size %lu\n",
- i,
- test_data[i].test_str,
- test_data[i].expected_size,
- size);
+ i, test_data[i].test_str,
+ test_data[i].expected_size, size);
}
assert(rc == test_data[i].expected_rc);
if (rc == 0)
diff --git a/test/test-config-parse.c b/test/test-config-parse.c
index 6392bd9..7d2d687 100644
--- a/test/test-config-parse.c
+++ b/test/test-config-parse.c
@@ -11,7 +11,8 @@
#include "config.c"
-static void execute_test(const char *input, const char *key, const char *expected)
+static void execute_test(const char *input, const char *key,
+ const char *expected)
{
struct config *ctx;
const char *found;
diff --git a/test/test-ringbuffer-boundary-poll.c b/test/test-ringbuffer-boundary-poll.c
index 6f6ddc7..aa8a350 100644
--- a/test/test-ringbuffer-boundary-poll.c
+++ b/test/test-ringbuffer-boundary-poll.c
@@ -17,8 +17,8 @@
rb = ringbuffer_init(10);
- ctx->rbc = ringbuffer_consumer_register(rb,
- ringbuffer_poll_append_all, ctx);
+ ctx->rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_append_all,
+ ctx);
/* don't consume initial data in the poll callback */
ctx->ignore_poll = true;
diff --git a/test/test-ringbuffer-boundary-read.c b/test/test-ringbuffer-boundary-read.c
index 2b982e1..5a8fb8f 100644
--- a/test/test-ringbuffer-boundary-read.c
+++ b/test/test-ringbuffer-boundary-read.c
@@ -36,7 +36,7 @@
len = ringbuffer_dequeue_peek(rbc, pos, &out_buf);
if (len == 0)
break;
- assert(!memcmp(in_buf+pos, out_buf, len));
+ assert(!memcmp(in_buf + pos, out_buf, len));
pos += len;
}
assert(pos == sizeof(in_buf));
diff --git a/test/test-ringbuffer-poll-force.c b/test/test-ringbuffer-poll-force.c
index 0993de5..e1e4245 100644
--- a/test/test-ringbuffer-poll-force.c
+++ b/test/test-ringbuffer-poll-force.c
@@ -8,7 +8,9 @@
void test_poll_force(void)
{
- uint8_t in_buf[] = { 'a', 'b', 'c', 'd', 'e', 'f', };
+ uint8_t in_buf[] = {
+ 'a', 'b', 'c', 'd', 'e', 'f',
+ };
struct rb_test_ctx _ctx, *ctx = &_ctx;
struct ringbuffer *rb;
int rc;
@@ -17,8 +19,8 @@
rb = ringbuffer_init(5);
- ctx->rbc = ringbuffer_consumer_register(rb,
- ringbuffer_poll_append_all, ctx);
+ ctx->rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_append_all,
+ ctx);
ctx->force_only = true;
diff --git a/test/test-ringbuffer-read-commit.c b/test/test-ringbuffer-read-commit.c
index a4be624..0dba0d7 100644
--- a/test/test-ringbuffer-read-commit.c
+++ b/test/test-ringbuffer-read-commit.c
@@ -8,7 +8,11 @@
void test_read_commit(void)
{
- uint8_t *out_buf, in_buf[] = { 'a', 'b', 'c', };
+ uint8_t *out_buf, in_buf[] = {
+ 'a',
+ 'b',
+ 'c',
+ };
struct ringbuffer_consumer *rbc;
struct ringbuffer *rb;
size_t len;
diff --git a/test/test-ringbuffer-simple-poll.c b/test/test-ringbuffer-simple-poll.c
index 116fe8c..89a9477 100644
--- a/test/test-ringbuffer-simple-poll.c
+++ b/test/test-ringbuffer-simple-poll.c
@@ -17,8 +17,8 @@
ringbuffer_test_context_init(ctx);
rb = ringbuffer_init(10);
- ctx->rbc = ringbuffer_consumer_register(rb,
- ringbuffer_poll_append_all, ctx);
+ ctx->rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_append_all,
+ ctx);
rc = ringbuffer_queue(rb, in_buf, sizeof(in_buf));
assert(!rc);