From cdd6d1cfed523ee36174d143f0761098f6eecf3f Mon Sep 17 00:00:00 2001 From: TapTap Date: Mon, 20 Jul 2026 22:00:58 +0200 Subject: [PATCH] fix: clang-format compliance --- src/shared/config.c | 9 ++++++--- src/shared/file.c | 3 ++- src/shared/metadata.c | 3 ++- src/shared/protocol.c | 2 +- src/shared/transport_tcp.c | 3 ++- src/shared/transport_tls.c | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/shared/config.c b/src/shared/config.c index b474768..b9ff23c 100644 --- a/src/shared/config.c +++ b/src/shared/config.c @@ -15,7 +15,8 @@ Config* config_create(char* version, char* send_directory, char* receive_directo bool use_sendfile, unsigned long long chunk_size) { Config* config = malloc(sizeof(Config)); - if (config == NULL) return NULL; + if (config == NULL) + return NULL; config->version = version; config->send_directory = send_directory; config->receive_root_directory = receive_directory; @@ -255,7 +256,8 @@ Config* config_receive(int file_descriptor) { if (!receive_int(file_descriptor, &ec)) goto error; if (ec > MAX_PATTERN_COUNT) { - log_message(LOG_LEVEL_ERROR, "Exclude pattern count %d exceeds maximum %d", ec, MAX_PATTERN_COUNT); + log_message(LOG_LEVEL_ERROR, "Exclude pattern count %d exceeds maximum %d", ec, + MAX_PATTERN_COUNT); goto error; } if ((size_t)ec > SIZE_MAX / sizeof(char*)) { @@ -287,7 +289,8 @@ Config* config_receive(int file_descriptor) { if (!receive_int(file_descriptor, &ic)) goto error; if (ic > MAX_PATTERN_COUNT) { - log_message(LOG_LEVEL_ERROR, "Include pattern count %d exceeds maximum %d", ic, MAX_PATTERN_COUNT); + log_message(LOG_LEVEL_ERROR, "Include pattern count %d exceeds maximum %d", ic, + MAX_PATTERN_COUNT); goto error; } if ((size_t)ic > SIZE_MAX / sizeof(char*)) { diff --git a/src/shared/file.c b/src/shared/file.c index 883c58c..5a412cd 100644 --- a/src/shared/file.c +++ b/src/shared/file.c @@ -203,7 +203,8 @@ bool file_save_to_disk(const char* root_directory, File* file) { if (file->type == FILE_TYPE_SYMLINK && file->link_target) { // Validate link_target — reject absolute paths or traversal if (file->link_target[0] == '/' || strstr(file->link_target, "..") != NULL) { - log_message(LOG_LEVEL_ERROR, "Path traversal blocked in symlink target: %s", file->link_target); + log_message(LOG_LEVEL_ERROR, "Path traversal blocked in symlink target: %s", + file->link_target); return false; } char* disk_path = path_cat((char*)root_directory, file->path); diff --git a/src/shared/metadata.c b/src/shared/metadata.c index fb27ae1..b4de62e 100644 --- a/src/shared/metadata.c +++ b/src/shared/metadata.c @@ -41,7 +41,8 @@ FileMetadata* metadata_from_buf(char** buf) { if (!present) return NULL; FileMetadata* m = malloc(sizeof(FileMetadata)); - if (m == NULL) return NULL; + if (m == NULL) + return NULL; int32_t mode; memcpy(&mode, *buf, sizeof(mode)); *buf += sizeof(mode); diff --git a/src/shared/protocol.c b/src/shared/protocol.c index eb7eb9f..f07b8a1 100644 --- a/src/shared/protocol.c +++ b/src/shared/protocol.c @@ -197,7 +197,7 @@ bool send_data(int file_descriptor, const Data* data) { return true; } -#define MAX_DATA_SIZE (1024ULL * 1024 * 1024) // 1 GB +#define MAX_DATA_SIZE (1024ULL * 1024 * 1024) // 1 GB Data* receive_data(int file_descriptor) { unsigned long long size = 0; diff --git a/src/shared/transport_tcp.c b/src/shared/transport_tcp.c index 9a85c76..4f2e8e7 100644 --- a/src/shared/transport_tcp.c +++ b/src/shared/transport_tcp.c @@ -165,7 +165,8 @@ static void accept_loop(Server* server, void (*child_fn)(int, void*), void* chil int fd = accept(server->file_descriptor, (struct sockaddr*)&client_addr, &client_len); if (fd < 0) { if (errno == EINTR) { - if (g_tcp_cleanup_requested) break; + if (g_tcp_cleanup_requested) + break; continue; } perror("Could not accept the connection"); diff --git a/src/shared/transport_tls.c b/src/shared/transport_tls.c index 95bfd53..5b2f594 100644 --- a/src/shared/transport_tls.c +++ b/src/shared/transport_tls.c @@ -171,7 +171,7 @@ bool client_connect_tls(Client* client, char* host, int port, const char* cert_p // Set SNI and enable hostname verification SSL_set_tlsext_host_name(ssl, host); - X509_VERIFY_PARAM *param = SSL_get0_param(ssl); + X509_VERIFY_PARAM* param = SSL_get0_param(ssl); if (param) { X509_VERIFY_PARAM_set1_host(param, host, 0); }