fix(p5-socket): clang-format 18 reflow + cppcheck const-correctness

This commit is contained in:
2026-09-09 14:29:46 +02:00
parent 07d1dd84f7
commit f86ba7a556
7 changed files with 39 additions and 47 deletions
+4 -5
View File
@@ -382,12 +382,11 @@ static Client* connect_transfer_client(const Config* config) {
connect_opts.sockopt_count = config->sockopt_count;
bool connected;
if (config->use_tls) {
connected = client_connect_tls_ex(client, config->server_host, config->server_port,
config->tls_cert, config->tls_key, config->tls_ca,
&connect_opts);
connected =
client_connect_tls_ex(client, config->server_host, config->server_port, config->tls_cert,
config->tls_key, config->tls_ca, &connect_opts);
} else {
connected = client_connect_ex(client, config->server_host, config->server_port,
&connect_opts);
connected = client_connect_ex(client, config->server_host, config->server_port, &connect_opts);
}
if (!connected) {
client_disconnect(client);
+1 -1
View File
@@ -402,7 +402,7 @@ int config_sockopts_parse(const char* spec, SockOptEntry** out, int* out_count)
SockOptEntry* entries = NULL;
char* saveptr = NULL;
bool ok = true;
for (char* token = strtok_r(copy, ",", &saveptr); token != NULL;
for (const char* token = strtok_r(copy, ",", &saveptr); token != NULL;
token = strtok_r(NULL, ",", &saveptr)) {
if (*token == '\0') {
ok = false; /* empty entry: a stray/trailing comma */
+5 -6
View File
@@ -66,8 +66,8 @@ Server* server_create_ex(int port, const ServerBindOptions* bind_opts) {
int err = getaddrinfo(bind_address, port_str, &hints, &result);
if (err != 0 || result == NULL) {
char* escaped = bind_address ? output_escape(bind_address, false) : NULL;
fprintf(stderr, "Could not resolve bind address %s (%s)\n",
escaped ? escaped : "(wildcard)", gai_strerror(err));
fprintf(stderr, "Could not resolve bind address %s (%s)\n", escaped ? escaped : "(wildcard)",
gai_strerror(err));
free(escaped);
free(server);
return NULL;
@@ -172,8 +172,7 @@ static void plain_child_fn(int fd, void* ctx) {
}
bool server_listen(Server* server, void (*handler)(int file_descriptor)) {
log_message(LOG_LEVEL_INFO, "Start Listening on Port: %d",
server_address_port(&server->address));
log_message(LOG_LEVEL_INFO, "Start Listening on Port: %d", server_address_port(&server->address));
struct plain_ctx ctx = {handler};
accept_loop(server, plain_child_fn, &ctx, "Received Connection");
return true;
@@ -403,7 +402,7 @@ bool tcp_connect_socket_ex(Client* client, const char* host, int port,
return true;
}
bool tcp_connect_socket(Client* client, char* host, int port) {
bool tcp_connect_socket(Client* client, const char* host, int port) {
return tcp_connect_socket_ex(client, host, port, NULL);
}
@@ -414,7 +413,7 @@ bool client_connect_ex(Client* client, const char* host, int port, const TcpConn
return true;
}
bool client_connect(Client* client, char* host, int port) {
bool client_connect(Client* client, const char* host, int port) {
if (!tcp_connect_socket_ex(client, host, port, NULL))
return false;
tcp_apply_socket_timeout(client->file_descriptor);
+4 -4
View File
@@ -37,8 +37,8 @@ typedef struct {
* --sockopts). All fields are client/connection-level and never cross the
* wire config frame. */
typedef struct {
const char* bind_address; /* --address: local source address to bind, or NULL */
int family; /* AF_INET / AF_INET6 / AF_UNSPEC (from -4 / -6) */
const char* bind_address; /* --address: local source address to bind, or NULL */
int family; /* AF_INET / AF_INET6 / AF_UNSPEC (from -4 / -6) */
const SockOptEntry* sockopts; /* --sockopts allowlist entries */
int sockopt_count;
} TcpConnectOptions;
@@ -51,10 +51,10 @@ void server_accept_loop(Server* server, void (*child_fn)(int, void*), void* chil
void server_delete(Server** server);
Client* client_create();
bool client_connect_ex(Client* client, const char* host, int port, const TcpConnectOptions* opts);
bool client_connect(Client* client, char* host, int port);
bool client_connect(Client* client, const char* host, int port);
bool tcp_connect_socket_ex(Client* client, const char* host, int port,
const TcpConnectOptions* opts);
bool tcp_connect_socket(Client* client, char* host, int port);
bool tcp_connect_socket(Client* client, const char* host, int port);
void client_disconnect(Client* client);
void client_delete(Client* client);
void tcp_set_timeouts(int timeout_sec, int contimeout_sec);
+1 -1
View File
@@ -221,7 +221,7 @@ bool client_connect_tls_ex(Client* client, const char* host, int port, const cha
return true;
}
bool client_connect_tls(Client* client, char* host, int port, const char* cert_path,
bool client_connect_tls(Client* client, const char* host, int port, const char* cert_path,
const char* key_path, const char* ca_path) {
return client_connect_tls_ex(client, host, port, cert_path, key_path, ca_path, NULL);
}
+1 -1
View File
@@ -12,7 +12,7 @@ bool server_listen_tls(Server* server, void (*handler)(int file_descriptor));
bool client_connect_tls_ex(Client* client, const char* host, int port, const char* cert_path,
const char* key_path, const char* ca_path,
const TcpConnectOptions* opts);
bool client_connect_tls(Client* client, char* host, int port, const char* cert_path,
bool client_connect_tls(Client* client, const char* host, int port, const char* cert_path,
const char* key_path, const char* ca_path);
#endif