aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-13 20:16:43 +0200
committerEgor Tensin <egor@tensin.name>2026-06-13 20:16:43 +0200
commitd64e7bf3d93649b78231912f37606153e3d30665 (patch)
tree1b583f5b3a8952794d4bd4f7a1936f7d66802551
parentupdate .git-blame-ignore-revs (diff)
downloadcimple-d64e7bf3d93649b78231912f37606153e3d30665.tar.gz
cimple-d64e7bf3d93649b78231912f37606153e3d30665.zip
finally, perfect .clang-format settings?
-rw-r--r--.clang-format3
-rw-r--r--src/client.c10
-rw-r--r--src/command.c38
-rw-r--r--src/command.h16
-rw-r--r--src/event_loop.c24
-rw-r--r--src/file.c10
-rw-r--r--src/json.c30
-rw-r--r--src/json_rpc.c94
-rw-r--r--src/json_rpc.h36
-rw-r--r--src/process.c8
-rw-r--r--src/process.h8
-rw-r--r--src/protocol.c24
-rw-r--r--src/protocol.h8
-rw-r--r--src/run_queue.c14
-rw-r--r--src/run_queue.h14
-rw-r--r--src/server.c54
-rw-r--r--src/sqlite.c10
-rw-r--r--src/storage_sqlite.c8
-rw-r--r--src/tcp_server.c35
-rw-r--r--src/tcp_server.h12
-rw-r--r--src/worker.c21
21 files changed, 291 insertions, 186 deletions
diff --git a/.clang-format b/.clang-format
index bea4b57..55e07c0 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,14 +5,17 @@ BasedOnStyle: Chromium
IndentWidth: 4
AccessModifierOffset: -4
+AlignAfterOpenBracket: BlockIndent
AlignConsecutiveMacros: AcrossComments
AllowShortFunctionsOnASingleLine: Empty
BinPackArguments: false
+BinPackParameters: OnePerLine
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: false
ColumnLimit: 100
IncludeBlocks: Regroup
+PenaltyReturnTypeOnItsOwnLine: 1000
SpacesBeforeTrailingComments: 1
WrapNamespaceBodyWithEmptyLines: Always
diff --git a/src/client.c b/src/client.c
index 493dec2..03b22bf 100644
--- a/src/client.c
+++ b/src/client.c
@@ -67,10 +67,12 @@ static int make_request(struct jsonrpc_request** request, int argc, const char**
return -1;
}
-int client_main(UNUSED const struct client* client,
- const struct settings* settings,
- int argc,
- const char** argv) {
+int client_main(
+ UNUSED const struct client* client,
+ const struct settings* settings,
+ int argc,
+ const char** argv
+) {
int ret = 0;
struct jsonrpc_request* request = NULL;
diff --git a/src/command.c b/src/command.c
index 18e15c6..0c8c5fc 100644
--- a/src/command.c
+++ b/src/command.c
@@ -60,10 +60,12 @@ static void free_cmds(struct cmd_desc* cmds, size_t numof_cmds) {
free_cmd(&cmds[i]);
}
-int cmd_dispatcher_create(struct cmd_dispatcher** _dispatcher,
- struct cmd_desc* cmds,
- size_t numof_cmds,
- void* ctx) {
+int cmd_dispatcher_create(
+ struct cmd_dispatcher** _dispatcher,
+ struct cmd_desc* cmds,
+ size_t numof_cmds,
+ void* ctx
+) {
int ret = 0;
struct cmd_dispatcher* dispatcher = malloc(sizeof(struct cmd_dispatcher));
@@ -103,10 +105,12 @@ void cmd_dispatcher_destroy(struct cmd_dispatcher* dispatcher) {
free(dispatcher);
}
-static int cmd_dispatcher_handle_internal(const struct cmd_dispatcher* dispatcher,
- const struct jsonrpc_request* request,
- struct jsonrpc_response** result,
- void* arg) {
+static int cmd_dispatcher_handle_internal(
+ const struct cmd_dispatcher* dispatcher,
+ const struct jsonrpc_request* request,
+ struct jsonrpc_response** result,
+ void* arg
+) {
const char* actual_cmd = jsonrpc_request_get_method(request);
for (size_t i = 0; i < dispatcher->numof_cmds; ++i) {
@@ -122,9 +126,11 @@ static int cmd_dispatcher_handle_internal(const struct cmd_dispatcher* dispatche
return -1;
}
-int cmd_dispatcher_handle(const struct cmd_dispatcher* dispatcher,
- const struct jsonrpc_request* command,
- struct jsonrpc_response** result) {
+int cmd_dispatcher_handle(
+ const struct cmd_dispatcher* dispatcher,
+ const struct jsonrpc_request* command,
+ struct jsonrpc_response** result
+) {
return cmd_dispatcher_handle_internal(dispatcher, command, result, dispatcher->ctx);
}
@@ -206,10 +212,12 @@ int cmd_dispatcher_handle_conn(int conn_fd, void* _dispatcher) {
return cmd_dispatcher_handle_conn_internal(conn_fd, (struct cmd_dispatcher*)_dispatcher);
}
-int cmd_dispatcher_handle_event(UNUSED struct event_loop* loop,
- int fd,
- short revents,
- void* _dispatcher) {
+int cmd_dispatcher_handle_event(
+ UNUSED struct event_loop* loop,
+ int fd,
+ short revents,
+ void* _dispatcher
+) {
if (!(revents & POLLIN)) {
log_err("Descriptor %d is not readable\n", fd);
return -1;
diff --git a/src/command.h b/src/command.h
index da7ab24..a27ee7c 100644
--- a/src/command.h
+++ b/src/command.h
@@ -13,9 +13,11 @@
#include <stddef.h>
-typedef int (*cmd_handler)(const struct jsonrpc_request* request,
- struct jsonrpc_response** response,
- void* ctx);
+typedef int (*cmd_handler)(
+ const struct jsonrpc_request* request,
+ struct jsonrpc_response** response,
+ void* ctx
+);
struct cmd_desc {
char* name;
@@ -27,9 +29,11 @@ struct cmd_dispatcher;
int cmd_dispatcher_create(struct cmd_dispatcher**, struct cmd_desc*, size_t numof_defs, void* ctx);
void cmd_dispatcher_destroy(struct cmd_dispatcher*);
-int cmd_dispatcher_handle(const struct cmd_dispatcher*,
- const struct jsonrpc_request* command,
- struct jsonrpc_response** response);
+int cmd_dispatcher_handle(
+ const struct cmd_dispatcher*,
+ const struct jsonrpc_request* command,
+ struct jsonrpc_response** response
+);
struct cmd_conn_ctx {
int fd;
diff --git a/src/event_loop.c b/src/event_loop.c
index 1f1b789..c37f101 100644
--- a/src/event_loop.c
+++ b/src/event_loop.c
@@ -94,11 +94,13 @@ static void event_loop_add_internal(struct event_loop* loop, struct event_fd* en
loop->nfds = nfds;
}
-int event_loop_add(struct event_loop* loop,
- int fd,
- short events,
- event_handler handler,
- void* arg) {
+int event_loop_add(
+ struct event_loop* loop,
+ int fd,
+ short events,
+ event_handler handler,
+ void* arg
+) {
struct event_fd* entry = event_fd_create(fd, events, handler, arg);
if (!entry)
return -1;
@@ -106,11 +108,13 @@ int event_loop_add(struct event_loop* loop,
return 0;
}
-int event_loop_add_once(struct event_loop* loop,
- int fd,
- short events,
- event_handler handler,
- void* arg) {
+int event_loop_add_once(
+ struct event_loop* loop,
+ int fd,
+ short events,
+ event_handler handler,
+ void* arg
+) {
struct event_fd* entry = event_fd_create(fd, events, handler, arg);
if (!entry)
return -1;
diff --git a/src/file.c b/src/file.c
index 229dc89..a69dba2 100644
--- a/src/file.c
+++ b/src/file.c
@@ -17,10 +17,12 @@
#include <sys/stat.h>
#include <unistd.h>
-static int unlink_cb(const char* fpath,
- UNUSED const struct stat* sb,
- UNUSED int typeflag,
- UNUSED struct FTW* ftwbuf) {
+static int unlink_cb(
+ const char* fpath,
+ UNUSED const struct stat* sb,
+ UNUSED int typeflag,
+ UNUSED struct FTW* ftwbuf
+) {
int ret = 0;
ret = remove(fpath);
diff --git a/src/json.c b/src/json.c
index 8db9d45..440fd65 100644
--- a/src/json.c
+++ b/src/json.c
@@ -184,10 +184,12 @@ int libjson_get_int(const struct json_object* obj, const char* key, int64_t* _va
return 0;
}
-static int libjson_set_internal(struct json_object* obj,
- const char* key,
- struct json_object* value,
- unsigned flags) {
+static int libjson_set_internal(
+ struct json_object* obj,
+ const char* key,
+ struct json_object* value,
+ unsigned flags
+) {
int ret = 0;
ret = json_object_object_add_ex(obj, key, value, flags);
@@ -199,10 +201,12 @@ static int libjson_set_internal(struct json_object* obj,
return 0;
}
-static int libjson_set_string_internal(struct json_object* obj,
- const char* key,
- const char* _value,
- unsigned flags) {
+static int libjson_set_string_internal(
+ struct json_object* obj,
+ const char* key,
+ const char* _value,
+ unsigned flags
+) {
struct json_object* value = json_object_new_string(_value);
if (!value) {
libjson_errno("json_object_new_string");
@@ -221,10 +225,12 @@ free_value:
return ret;
}
-static int libjson_set_int_internal(struct json_object* obj,
- const char* key,
- int64_t _value,
- unsigned flags) {
+static int libjson_set_int_internal(
+ struct json_object* obj,
+ const char* key,
+ int64_t _value,
+ unsigned flags
+) {
struct json_object* value = json_object_new_int64(_value);
if (!value) {
libjson_errno("json_object_new_int");
diff --git a/src/json_rpc.c b/src/json_rpc.c
index 6bf9fc5..c0cdf18 100644
--- a/src/json_rpc.c
+++ b/src/json_rpc.c
@@ -178,10 +178,12 @@ static int jsonrpc_check_result_or_error(struct json_object* obj) {
return jsonrpc_check_error(obj);
}
-static int jsonrpc_request_create_internal(struct jsonrpc_request** _request,
- int* id,
- const char* method,
- struct json_object* params) {
+static int jsonrpc_request_create_internal(
+ struct jsonrpc_request** _request,
+ int* id,
+ const char* method,
+ struct json_object* params
+) {
int ret = 0;
struct jsonrpc_request* request = malloc(sizeof(struct jsonrpc_request));
@@ -226,10 +228,12 @@ exit:
return ret;
}
-int jsonrpc_request_create(struct jsonrpc_request** _request,
- int id,
- const char* method,
- struct json_object* params) {
+int jsonrpc_request_create(
+ struct jsonrpc_request** _request,
+ int id,
+ const char* method,
+ struct json_object* params
+) {
return jsonrpc_request_create_internal(_request, &id, method, params);
}
@@ -238,9 +242,11 @@ void jsonrpc_request_destroy(struct jsonrpc_request* request) {
free(request);
}
-int jsonrpc_notification_create(struct jsonrpc_request** _request,
- const char* method,
- struct json_object* params) {
+int jsonrpc_notification_create(
+ struct jsonrpc_request** _request,
+ const char* method,
+ struct json_object* params
+) {
return jsonrpc_request_create_internal(_request, NULL, method, params);
}
@@ -334,9 +340,11 @@ static struct json_object* jsonrpc_request_create_params(struct jsonrpc_request*
return params;
}
-int jsonrpc_request_get_param_string(const struct jsonrpc_request* request,
- const char* name,
- const char** value) {
+int jsonrpc_request_get_param_string(
+ const struct jsonrpc_request* request,
+ const char* name,
+ const char** value
+) {
struct json_object* params = NULL;
int ret = libjson_get(request->impl, jsonrpc_key_params, &params);
if (ret < 0)
@@ -344,18 +352,22 @@ int jsonrpc_request_get_param_string(const struct jsonrpc_request* request,
return libjson_get_string(params, name, value);
}
-int jsonrpc_request_set_param_string(struct jsonrpc_request* request,
- const char* name,
- const char* value) {
+int jsonrpc_request_set_param_string(
+ struct jsonrpc_request* request,
+ const char* name,
+ const char* value
+) {
struct json_object* params = jsonrpc_request_create_params(request);
if (!params)
return -1;
return libjson_set_string(params, name, value);
}
-int jsonrpc_request_get_param_int(const struct jsonrpc_request* request,
- const char* name,
- int64_t* value) {
+int jsonrpc_request_get_param_int(
+ const struct jsonrpc_request* request,
+ const char* name,
+ int64_t* value
+) {
struct json_object* params = NULL;
int ret = libjson_get(request->impl, jsonrpc_key_params, &params);
if (ret < 0)
@@ -363,9 +375,11 @@ int jsonrpc_request_get_param_int(const struct jsonrpc_request* request,
return libjson_get_int(params, name, value);
}
-int jsonrpc_request_set_param_int(struct jsonrpc_request* request,
- const char* name,
- int64_t value) {
+int jsonrpc_request_set_param_int(
+ struct jsonrpc_request* request,
+ const char* name,
+ int64_t value
+) {
struct json_object* params = jsonrpc_request_create_params(request);
if (!params)
return -1;
@@ -376,10 +390,12 @@ const char* jsonrpc_response_to_string(const struct jsonrpc_response* response)
return libjson_to_string_pretty(response->impl);
}
-int jsonrpc_response_create_internal(struct jsonrpc_response** _response,
- const struct jsonrpc_request* request,
- struct json_object* result,
- struct json_object* error) {
+int jsonrpc_response_create_internal(
+ struct jsonrpc_response** _response,
+ const struct jsonrpc_request* request,
+ struct json_object* result,
+ struct json_object* error
+) {
int ret = 0;
struct jsonrpc_response* response = malloc(sizeof(struct jsonrpc_response));
@@ -429,9 +445,11 @@ exit:
return ret;
}
-int jsonrpc_response_create(struct jsonrpc_response** response,
- const struct jsonrpc_request* request,
- struct json_object* result) {
+int jsonrpc_response_create(
+ struct jsonrpc_response** response,
+ const struct jsonrpc_request* request,
+ struct json_object* result
+) {
return jsonrpc_response_create_internal(response, request, result, NULL);
}
@@ -440,10 +458,12 @@ void jsonrpc_response_destroy(struct jsonrpc_response* response) {
free(response);
}
-int jsonrpc_error_create(struct jsonrpc_response** response,
- struct jsonrpc_request* request,
- int code,
- const char* message) {
+int jsonrpc_error_create(
+ struct jsonrpc_response** response,
+ struct jsonrpc_request* request,
+ int code,
+ const char* message
+) {
int ret = 0;
struct json_object* error = NULL;
@@ -474,8 +494,10 @@ int jsonrpc_response_is_error(const struct jsonrpc_response* response) {
return libjson_has(response->impl, jsonrpc_key_error);
}
-static int jsonrpc_response_from_json(struct jsonrpc_response** _response,
- struct json_object* impl) {
+static int jsonrpc_response_from_json(
+ struct jsonrpc_response** _response,
+ struct json_object* impl
+) {
int ret = 0;
ret = jsonrpc_check_version(impl);
diff --git a/src/json_rpc.h b/src/json_rpc.h
index 0d6d34d..a341835 100644
--- a/src/json_rpc.h
+++ b/src/json_rpc.h
@@ -18,15 +18,19 @@ struct jsonrpc_request;
int jsonrpc_generate_request_id(void);
-int jsonrpc_request_create(struct jsonrpc_request**,
- int id,
- const char* method,
- struct json_object* params);
+int jsonrpc_request_create(
+ struct jsonrpc_request**,
+ int id,
+ const char* method,
+ struct json_object* params
+);
void jsonrpc_request_destroy(struct jsonrpc_request*);
-int jsonrpc_notification_create(struct jsonrpc_request**,
- const char* method,
- struct json_object* params);
+int jsonrpc_notification_create(
+ struct jsonrpc_request**,
+ const char* method,
+ struct json_object* params
+);
int jsonrpc_request_is_notification(const struct jsonrpc_request*);
int jsonrpc_request_send(const struct jsonrpc_request*, int fd);
@@ -43,15 +47,19 @@ struct jsonrpc_response;
const char* jsonrpc_response_to_string(const struct jsonrpc_response*);
-int jsonrpc_response_create(struct jsonrpc_response**,
- const struct jsonrpc_request*,
- struct json_object* result);
+int jsonrpc_response_create(
+ struct jsonrpc_response**,
+ const struct jsonrpc_request*,
+ struct json_object* result
+);
void jsonrpc_response_destroy(struct jsonrpc_response*);
-int jsonrpc_error_create(struct jsonrpc_response**,
- struct jsonrpc_request*,
- int code,
- const char* message);
+int jsonrpc_error_create(
+ struct jsonrpc_response**,
+ struct jsonrpc_request*,
+ int code,
+ const char* message
+);
int jsonrpc_response_is_error(const struct jsonrpc_response*);
int jsonrpc_response_send(const struct jsonrpc_response*, int fd);
diff --git a/src/process.c b/src/process.c
index ea93904..a034237 100644
--- a/src/process.c
+++ b/src/process.c
@@ -90,9 +90,11 @@ static int redirect_and_exec_child(int pipe_fds[2], const char* args[], const ch
return exec_child(args, envp);
}
-int process_execute_and_capture(const char* args[],
- const char* envp[],
- struct process_output* result) {
+int process_execute_and_capture(
+ const char* args[],
+ const char* envp[],
+ struct process_output* result
+) {
static const int flags = O_CLOEXEC;
int pipe_fds[2];
int ret = 0;
diff --git a/src/process.h b/src/process.h
index b3ee603..adbeb5c 100644
--- a/src/process.h
+++ b/src/process.h
@@ -23,9 +23,11 @@ int process_execute(const char* args[], const char* envp[], int* ec);
* non-negative number.
*
* In that case, you'll need to free the output. */
-int process_execute_and_capture(const char* args[],
- const char* envp[],
- struct process_output* result);
+int process_execute_and_capture(
+ const char* args[],
+ const char* envp[],
+ struct process_output* result
+);
int process_output_create(struct process_output**);
void process_output_destroy(struct process_output*);
diff --git a/src/protocol.c b/src/protocol.c
index dc72434..e24d09d 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -114,9 +114,11 @@ static const char* const finished_key_run_id = "run_id";
static const char* const finished_key_ec = "exit_code";
static const char* const finished_key_data = "output";
-int request_create_finished_run(struct jsonrpc_request** request,
- int run_id,
- const struct process_output* output) {
+int request_create_finished_run(
+ struct jsonrpc_request** request,
+ int run_id,
+ const struct process_output* output
+) {
int ret = 0;
ret = jsonrpc_notification_create(request, CMD_FINISHED_RUN, NULL);
@@ -147,9 +149,11 @@ free_request:
return ret;
}
-int request_parse_finished_run(const struct jsonrpc_request* request,
- int* _run_id,
- struct process_output** _output) {
+int request_parse_finished_run(
+ const struct jsonrpc_request* request,
+ int* _run_id,
+ struct process_output** _output
+) {
int ret = 0;
struct process_output* output = NULL;
@@ -195,9 +199,11 @@ int request_parse_get_runs(UNUSED const struct jsonrpc_request* request) {
return 0;
}
-int response_create_get_runs(struct jsonrpc_response** response,
- const struct jsonrpc_request* request,
- const struct run_queue* runs) {
+int response_create_get_runs(
+ struct jsonrpc_response** response,
+ const struct jsonrpc_request* request,
+ const struct run_queue* runs
+) {
struct json_object* runs_json = NULL;
int ret = 0;
diff --git a/src/protocol.h b/src/protocol.h
index 31d0091..9b4261a 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -27,8 +27,10 @@ int request_parse_finished_run(const struct jsonrpc_request*, int* run_id, struc
int request_create_get_runs(struct jsonrpc_request**);
int request_parse_get_runs(const struct jsonrpc_request*);
-int response_create_get_runs(struct jsonrpc_response**,
- const struct jsonrpc_request*,
- const struct run_queue*);
+int response_create_get_runs(
+ struct jsonrpc_response**,
+ const struct jsonrpc_request*,
+ const struct run_queue*
+);
#endif
diff --git a/src/run_queue.c b/src/run_queue.c
index b6093e4..2c316e3 100644
--- a/src/run_queue.c
+++ b/src/run_queue.c
@@ -26,12 +26,14 @@ struct run {
SIMPLEQ_ENTRY(run) entries;
};
-int run_new(struct run** _entry,
- int id,
- const char* _repo_url,
- const char* _repo_rev,
- enum run_status status,
- int exit_code) {
+int run_new(
+ struct run** _entry,
+ int id,
+ const char* _repo_url,
+ const char* _repo_rev,
+ enum run_status status,
+ int exit_code
+) {
struct run* entry = malloc(sizeof(struct run));
if (!entry) {
log_errno("malloc");
diff --git a/src/run_queue.h b/src/run_queue.h
index 92948a9..3ff89bd 100644
--- a/src/run_queue.h
+++ b/src/run_queue.h
@@ -19,12 +19,14 @@ enum run_status {
struct run;
-int run_new(struct run**,
- int id,
- const char* repo_url,
- const char* repo_rev,
- enum run_status,
- int exit_code);
+int run_new(
+ struct run**,
+ int id,
+ const char* repo_url,
+ const char* repo_rev,
+ enum run_status,
+ int exit_code
+);
void run_destroy(struct run*);
int run_queued(struct run**, const char* repo_url, const char* repo_rev);
diff --git a/src/server.c b/src/server.c
index dabc0f4..692988d 100644
--- a/src/server.c
+++ b/src/server.c
@@ -75,10 +75,12 @@ static void server_notify(struct server* server) {
pthread_errno_if(pthread_cond_signal(&server->server_cv), "pthread_cond_signal");
}
-static int server_set_stopping(UNUSED struct event_loop* loop,
- UNUSED int fd,
- UNUSED short revents,
- void* _server) {
+static int server_set_stopping(
+ UNUSED struct event_loop* loop,
+ UNUSED int fd,
+ UNUSED short revents,
+ void* _server
+) {
struct server* server = (struct server*)_server;
int ret = 0;
@@ -218,9 +220,11 @@ exit:
return NULL;
}
-static int server_handle_cmd_new_worker(UNUSED const struct jsonrpc_request* request,
- UNUSED struct jsonrpc_response** response,
- void* _ctx) {
+static int server_handle_cmd_new_worker(
+ UNUSED const struct jsonrpc_request* request,
+ UNUSED struct jsonrpc_response** response,
+ void* _ctx
+) {
struct cmd_conn_ctx* ctx = (struct cmd_conn_ctx*)_ctx;
struct server* server = (struct server*)ctx->arg;
int ret = 0;
@@ -251,9 +255,11 @@ close:
return ret;
}
-static int server_handle_cmd_queue_run(const struct jsonrpc_request* request,
- struct jsonrpc_response** response,
- void* _ctx) {
+static int server_handle_cmd_queue_run(
+ const struct jsonrpc_request* request,
+ struct jsonrpc_response** response,
+ void* _ctx
+) {
struct cmd_conn_ctx* ctx = (struct cmd_conn_ctx*)_ctx;
struct server* server = (struct server*)ctx->arg;
int ret = 0;
@@ -284,9 +290,11 @@ destroy_run:
return ret;
}
-static int server_handle_cmd_finished_run(const struct jsonrpc_request* request,
- UNUSED struct jsonrpc_response** response,
- void* _ctx) {
+static int server_handle_cmd_finished_run(
+ const struct jsonrpc_request* request,
+ UNUSED struct jsonrpc_response** response,
+ void* _ctx
+) {
struct cmd_conn_ctx* ctx = (struct cmd_conn_ctx*)_ctx;
struct server* server = (struct server*)ctx->arg;
int ret = 0;
@@ -312,9 +320,11 @@ free_output:
return ret;
}
-static int server_handle_cmd_get_runs(const struct jsonrpc_request* request,
- struct jsonrpc_response** response,
- void* _ctx) {
+static int server_handle_cmd_get_runs(
+ const struct jsonrpc_request* request,
+ struct jsonrpc_response** response,
+ void* _ctx
+) {
struct cmd_conn_ctx* ctx = (struct cmd_conn_ctx*)_ctx;
struct server* server = (struct server*)ctx->arg;
int ret = 0;
@@ -406,11 +416,13 @@ int server_create(struct server** _server, const struct settings* settings) {
if (ret < 0)
goto destroy_storage;
- ret = tcp_server_create(&server->tcp_server,
- server->event_loop,
- settings->port,
- cmd_dispatcher_handle_conn,
- server->cmd_dispatcher);
+ ret = tcp_server_create(
+ &server->tcp_server,
+ server->event_loop,
+ settings->port,
+ cmd_dispatcher_handle_conn,
+ server->cmd_dispatcher
+ );
if (ret < 0)
goto destroy_run_queue;
diff --git a/src/sqlite.c b/src/sqlite.c
index 11a9ce8..8f0db5f 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -84,10 +84,12 @@ int sqlite_exec(sqlite3* db, const char* stmt, sqlite3_callback callback, void*
return ret;
}
-int sqlite_exec_log_result(UNUSED void* arg,
- int numof_columns,
- char** values,
- char** column_names) {
+int sqlite_exec_log_result(
+ UNUSED void* arg,
+ int numof_columns,
+ char** values,
+ char** column_names
+) {
log("Row:\n");
for (int i = 0; i < numof_columns; ++i) {
log("\t%s: %s\n", column_names[i], values[i]);
diff --git a/src/storage_sqlite.c b/src/storage_sqlite.c
index e8e75b5..9a73162 100644
--- a/src/storage_sqlite.c
+++ b/src/storage_sqlite.c
@@ -392,9 +392,11 @@ int storage_sqlite_run_create(struct storage* storage, const char* repo_url, con
return ret;
}
-int storage_sqlite_run_finished(struct storage* storage,
- int run_id,
- const struct process_output* output) {
+int storage_sqlite_run_finished(
+ struct storage* storage,
+ int run_id,
+ const struct process_output* output
+) {
struct prepared_stmt* stmt = &storage->sqlite->stmt_run_finished;
int ret = 0;
diff --git a/src/tcp_server.c b/src/tcp_server.c
index cdd5db6..60d5615 100644
--- a/src/tcp_server.c
+++ b/src/tcp_server.c
@@ -94,10 +94,12 @@ static void client_destroy(struct client* client) {
free(client);
}
-static int client_destroy_handler(UNUSED struct event_loop* loop,
- UNUSED int fd,
- UNUSED short revents,
- void* _client) {
+static int client_destroy_handler(
+ UNUSED struct event_loop* loop,
+ UNUSED int fd,
+ UNUSED short revents,
+ void* _client
+) {
struct client* client = (struct client*)_client;
log_debug("Client thread %d indicated that it's done\n", client->tid);
@@ -172,7 +174,8 @@ static int client_create(struct tcp_server* server, int conn_fd) {
client->cleanup_fd = ret;
ret = event_loop_add_once(
- server->loop, client->cleanup_fd, POLLIN, client_destroy_handler, client);
+ server->loop, client->cleanup_fd, POLLIN, client_destroy_handler, client
+ );
if (ret < 0)
goto close_cleanup_fd;
@@ -209,19 +212,23 @@ static void client_queue_destroy(struct client_queue* client_queue) {
}
}
-static int tcp_server_accept_handler(UNUSED struct event_loop* loop,
- UNUSED int fd,
- UNUSED short revents,
- void* _server) {
+static int tcp_server_accept_handler(
+ UNUSED struct event_loop* loop,
+ UNUSED int fd,
+ UNUSED short revents,
+ void* _server
+) {
struct tcp_server* server = (struct tcp_server*)_server;
return tcp_server_accept(server);
}
-int tcp_server_create(struct tcp_server** _server,
- struct event_loop* loop,
- const char* port,
- tcp_server_conn_handler conn_handler,
- void* conn_handler_arg) {
+int tcp_server_create(
+ struct tcp_server** _server,
+ struct event_loop* loop,
+ const char* port,
+ tcp_server_conn_handler conn_handler,
+ void* conn_handler_arg
+) {
int ret = 0;
struct tcp_server* server = calloc(1, sizeof(struct tcp_server));
diff --git a/src/tcp_server.h b/src/tcp_server.h
index cae43fd..def7a17 100644
--- a/src/tcp_server.h
+++ b/src/tcp_server.h
@@ -14,11 +14,13 @@ struct tcp_server;
typedef int (*tcp_server_conn_handler)(int conn_fd, void* arg);
-int tcp_server_create(struct tcp_server**,
- struct event_loop*,
- const char* port,
- tcp_server_conn_handler,
- void* arg);
+int tcp_server_create(
+ struct tcp_server**,
+ struct event_loop*,
+ const char* port,
+ tcp_server_conn_handler,
+ void* arg
+);
void tcp_server_destroy(struct tcp_server*);
int tcp_server_accept(struct tcp_server*);
diff --git a/src/worker.c b/src/worker.c
index dd271a5..531192f 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -73,18 +73,22 @@ static void worker_settings_destroy(struct settings* settings) {
free(settings);
}
-static int worker_set_stopping(UNUSED struct event_loop* loop,
- UNUSED int fd,
- UNUSED short revents,
- void* _worker) {
+static int worker_set_stopping(
+ UNUSED struct event_loop* loop,
+ UNUSED int fd,
+ UNUSED short revents,
+ void* _worker
+) {
struct worker* worker = (struct worker*)_worker;
worker->stopping = 1;
return 0;
}
-static int worker_handle_cmd_start_run(const struct jsonrpc_request* request,
- UNUSED struct jsonrpc_response** response,
- void* _ctx) {
+static int worker_handle_cmd_start_run(
+ const struct jsonrpc_request* request,
+ UNUSED struct jsonrpc_response** response,
+ void* _ctx
+) {
struct cmd_conn_ctx* ctx = (struct cmd_conn_ctx*)_ctx;
struct worker* worker = (struct worker*)ctx->arg;
int ret = 0;
@@ -236,7 +240,8 @@ static int worker_get_run(struct worker* worker) {
goto close;
ret = event_loop_add_once(
- worker->event_loop, fd, POLLIN, cmd_dispatcher_handle_event, worker->cmd_dispatcher);
+ worker->event_loop, fd, POLLIN, cmd_dispatcher_handle_event, worker->cmd_dispatcher
+ );
if (ret < 0)
goto close;