From 1160cdb21e0b667269299853cb47a4aa88948dc3 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 12 Jun 2026 17:20:08 +0200 Subject: unify my .clang-format files --- src/run_queue.c | 82 ++++++++++++++++++++++++--------------------------------- 1 file changed, 35 insertions(+), 47 deletions(-) (limited to 'src/run_queue.c') diff --git a/src/run_queue.c b/src/run_queue.c index 2f50f92..652096a 100644 --- a/src/run_queue.c +++ b/src/run_queue.c @@ -6,6 +6,7 @@ */ #include "run_queue.h" + #include "json.h" #include "log.h" @@ -17,30 +18,33 @@ struct run { int id; - char *repo_url; - char *repo_rev; + char* repo_url; + char* repo_rev; int status; int exit_code; 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) -{ - struct run *entry = malloc(sizeof(struct run)); +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"); goto fail; } - char *repo_url = strdup(_repo_url); + char* repo_url = strdup(_repo_url); if (!repo_url) { log_errno("strdup"); goto free_entry; } - char *repo_rev = strdup(_repo_rev); + char* repo_rev = strdup(_repo_rev); if (!repo_rev) { log_errno("strdup"); goto free_repo_url; @@ -65,26 +69,22 @@ fail: return -1; } -void run_destroy(struct run *entry) -{ +void run_destroy(struct run* entry) { free(entry->repo_rev); free(entry->repo_url); free(entry); } -int run_queued(struct run **entry, const char *repo_url, const char *repo_rev) -{ +int run_queued(struct run** entry, const char* repo_url, const char* repo_rev) { return run_new(entry, -1, repo_url, repo_rev, RUN_STATUS_CREATED, -1); } -int run_created(struct run **entry, int id, const char *repo_url, const char *repo_rev) -{ +int run_created(struct run** entry, int id, const char* repo_url, const char* repo_rev) { return run_new(entry, id, repo_url, repo_rev, RUN_STATUS_CREATED, -1); } -int run_to_json(const struct run *entry, struct json_object **_json) -{ - struct json_object *json = NULL; +int run_to_json(const struct run* entry, struct json_object** _json) { + struct json_object* json = NULL; int ret = 0; ret = libjson_new_object(&json); @@ -112,55 +112,47 @@ free: return ret; } -int run_get_id(const struct run *entry) -{ +int run_get_id(const struct run* entry) { return entry->id; } -const char *run_get_repo_url(const struct run *entry) -{ +const char* run_get_repo_url(const struct run* entry) { return entry->repo_url; } -const char *run_get_repo_rev(const struct run *entry) -{ +const char* run_get_repo_rev(const struct run* entry) { return entry->repo_rev; } -void run_set_id(struct run *entry, int id) -{ +void run_set_id(struct run* entry, int id) { entry->id = id; } -void run_queue_create(struct run_queue *queue) -{ +void run_queue_create(struct run_queue* queue) { SIMPLEQ_INIT(queue); } -void run_queue_destroy(struct run_queue *queue) -{ - struct run *entry1 = SIMPLEQ_FIRST(queue); +void run_queue_destroy(struct run_queue* queue) { + struct run* entry1 = SIMPLEQ_FIRST(queue); while (entry1) { - struct run *entry2 = SIMPLEQ_NEXT(entry1, entries); + struct run* entry2 = SIMPLEQ_NEXT(entry1, entries); run_destroy(entry1); entry1 = entry2; } SIMPLEQ_INIT(queue); } -int run_queue_to_json(const struct run_queue *queue, struct json_object **_json) -{ - struct json_object *json = NULL; +int run_queue_to_json(const struct run_queue* queue, struct json_object** _json) { + struct json_object* json = NULL; int ret = 0; ret = libjson_new_array(&json); if (ret < 0) return ret; - struct run *entry = NULL; - SIMPLEQ_FOREACH(entry, queue, entries) - { - struct json_object *entry_json = NULL; + struct run* entry = NULL; + SIMPLEQ_FOREACH(entry, queue, entries) { + struct json_object* entry_json = NULL; ret = run_to_json(entry, &entry_json); if (ret < 0) goto free; @@ -181,24 +173,20 @@ free: return ret; } -int run_queue_is_empty(const struct run_queue *queue) -{ +int run_queue_is_empty(const struct run_queue* queue) { return SIMPLEQ_EMPTY(queue); } -void run_queue_add_first(struct run_queue *queue, struct run *entry) -{ +void run_queue_add_first(struct run_queue* queue, struct run* entry) { SIMPLEQ_INSERT_HEAD(queue, entry, entries); } -void run_queue_add_last(struct run_queue *queue, struct run *entry) -{ +void run_queue_add_last(struct run_queue* queue, struct run* entry) { SIMPLEQ_INSERT_TAIL(queue, entry, entries); } -struct run *run_queue_remove_first(struct run_queue *queue) -{ - struct run *entry = SIMPLEQ_FIRST(queue); +struct run* run_queue_remove_first(struct run_queue* queue) { + struct run* entry = SIMPLEQ_FIRST(queue); SIMPLEQ_REMOVE_HEAD(queue, entries); return entry; } -- cgit v1.3