Skip to content

Commit

Permalink
uncrustify
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperpedersen committed Nov 14, 2024
1 parent f34e4f9 commit ae2a0ce
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ display_helper(char* command)
else if (//!strcmp(command, COMMAND_CONFIG_GET) ||
//!strcmp(command, COMMAND_CONFIG_LS) ||
//!strcmp(command, COMMAND_CONFIG_SET) ||
!strcmp(command, COMMAND_RELOAD))
!strcmp(command, COMMAND_RELOAD))
{
help_conf();
}
Expand Down
8 changes: 4 additions & 4 deletions src/include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,10 @@ bool
pgagroal_compare_string(const char* str1, const char* str2);

/**
* Escape a string
* @param str The original string
* @return The escaped string
*/
* Escape a string
* @param str The original string
* @return The escaped string
*/
char*
pgagroal_escape_string(char* str);

Expand Down
1 change: 0 additions & 1 deletion src/libpgagroal/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ static const EVP_CIPHER* (*get_cipher(int mode))(void);

static int encrypt_decrypt_buffer(unsigned char* origin_buffer, size_t origin_size, unsigned char** res_buffer, size_t* res_size, int enc, int mode);


int
pgagroal_encrypt(char* plaintext, char* password, char** ciphertext, int* ciphertext_length, int mode)
{
Expand Down
4 changes: 2 additions & 2 deletions src/libpgagroal/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ pgagroal_read_admins_configuration(void* shm, char* filename)
goto error;
}

if (pgagroal_decrypt(decoded, decoded_length, master_key, &password, ENCRYPTION_AES_256_CBC))
if (pgagroal_decrypt(decoded, decoded_length, master_key, &password, ENCRYPTION_AES_256_CBC))
{
status = PGAGROAL_CONFIGURATION_STATUS_CANNOT_DECRYPT;
goto error;
Expand Down Expand Up @@ -2586,7 +2586,7 @@ transfer_configuration(struct main_configuration* config, struct main_configurat
config->common.metrics_cache_max_age = reload->common.metrics_cache_max_age;
if (restart_int("metrics_cache_max_size", config->common.metrics_cache_max_size, reload->common.metrics_cache_max_size))
{
changed= true;
changed = true;
}
config->management = reload->management;

Expand Down
26 changes: 8 additions & 18 deletions src/libpgagroal/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ static int write_complete(SSL* ssl, int socket, void* buf, size_t size);
static int write_socket(int socket, void* buf, size_t size);
static int write_ssl(SSL* ssl, void* buf, size_t size);


int
pgagroal_connection_get(int* client_fd)
{
Expand All @@ -72,7 +71,7 @@ pgagroal_connection_get(int* client_fd)
}

*client_fd = fd;

return 0;

error:
Expand Down Expand Up @@ -102,7 +101,7 @@ pgagroal_connection_get_pid(pid_t pid, int* client_fd)
}

*client_fd = fd;

free(f);

return 0;
Expand All @@ -114,7 +113,6 @@ pgagroal_connection_get_pid(pid_t pid, int* client_fd)
return 1;
}


int
pgagroal_connection_id_write(int client_fd, int id)
{
Expand All @@ -141,7 +139,7 @@ int
pgagroal_connection_id_read(int client_fd, int* id)
{
char buf4[4];

*id = -1;

memset(&buf4[0], 0, sizeof(buf4));
Expand Down Expand Up @@ -231,7 +229,7 @@ pgagroal_connection_transfer_read(int client_fd, int* slot, int* fd)
struct cmsghdr* cmptr = NULL;
struct iovec iov[1];
struct msghdr msg;

*slot = -1;
*fd = -1;

Expand Down Expand Up @@ -279,7 +277,7 @@ pgagroal_connection_transfer_read(int client_fd, int* slot, int* fd)
*fd = *(int*)CMSG_DATA(cmptr);

free(cmptr);

return 0;

error:
Expand Down Expand Up @@ -318,7 +316,7 @@ int
pgagroal_connection_slot_read(int client_fd, int32_t* slot)
{
char buf4[4];

*slot = -1;

memset(&buf4[0], 0, sizeof(buf4));
Expand Down Expand Up @@ -364,7 +362,7 @@ int
pgagroal_connection_socket_read(int client_fd, int* socket)
{
char buf4[4];

*socket = -1;

memset(&buf4[0], 0, sizeof(buf4));
Expand Down Expand Up @@ -410,7 +408,7 @@ int
pgagroal_connection_pid_read(int client_fd, pid_t* pid)
{
char buf4[4];

*pid = -1;

memset(&buf4[0], 0, sizeof(buf4));
Expand Down Expand Up @@ -637,7 +635,6 @@ write_ssl(SSL* ssl, void* buf, size_t size)
return 1;
}


/* int */
/* pgagroal_management_client_done(pid_t pid) */
/* { */
Expand Down Expand Up @@ -681,10 +678,6 @@ write_ssl(SSL* ssl, void* buf, size_t size)
/* return 1; */
/* } */





/* int */
/* pgagroal_management_client_fd(int32_t slot, pid_t pid) */
/* { */
Expand Down Expand Up @@ -757,7 +750,6 @@ write_ssl(SSL* ssl, void* buf, size_t size)
/* return 1; */
/* } */


/* int */
/* pgagroal_management_remove_fd(int32_t slot, int socket, pid_t pid) */
/* { */
Expand Down Expand Up @@ -810,7 +802,6 @@ write_ssl(SSL* ssl, void* buf, size_t size)
/* return 1; */
/* } */


/* /\* */
/* * Utility function to convert PGAGROAL_VERSION into a number. */
/* * The major version is represented by a single digit. */
Expand Down Expand Up @@ -899,7 +890,6 @@ write_ssl(SSL* ssl, void* buf, size_t size)
/* return 0; */
/* } */


/* /\* */
/* * Utility function to convert command into a string. */
/* *\/ */
Expand Down
1 change: 0 additions & 1 deletion src/libpgagroal/management.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ pgagroal_management_request_details(SSL* ssl, int socket, uint8_t compression, u
return 1;
}


int
pgagroal_management_request_ping(SSL* ssl, int socket, uint8_t compression, uint8_t encryption, int32_t output_format)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libpgagroal/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pgagroal_memory_init(void)
goto error;
}
}

if (data == NULL)
{
data = calloc(1, DEFAULT_BUFFER_SIZE);
Expand Down
4 changes: 2 additions & 2 deletions src/libpgagroal/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ pgagroal_kill_connection(int slot, SSL* ssl)
{
result = 1;
}

pgagroal_disconnect(transfer_fd);

if (ssl != NULL)
Expand Down Expand Up @@ -1020,7 +1020,7 @@ pgagroal_request_flush(SSL* ssl, int client_fd, uint8_t compression, uint8_t enc
char* database = NULL;

start_time = time(NULL);

req = (struct json*)pgagroal_json_get(payload, MANAGEMENT_CATEGORY_REQUEST);
mode = (int)pgagroal_json_get(req, MANAGEMENT_ARGUMENT_MODE);
database = (char*)pgagroal_json_get(req, MANAGEMENT_ARGUMENT_DATABASE);
Expand Down
18 changes: 9 additions & 9 deletions src/libpgagroal/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pgagroal_status_details(SSL* ssl, int client_fd, uint8_t compression, uint8_t en

pgagroal_memory_init();
pgagroal_start_logging();

start_time = time(NULL);

if (pgagroal_management_create_response(payload, -1, &response))
Expand Down Expand Up @@ -223,7 +223,7 @@ status_details(bool details, struct json* response)
struct json* js = NULL;

pgagroal_json_create(&js);

pgagroal_json_put(js, MANAGEMENT_ARGUMENT_DATABASE, (uintptr_t)config->limits[i].database, ValueString);
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_USERNAME, (uintptr_t)config->limits[i].username, ValueString);

Expand All @@ -232,12 +232,12 @@ status_details(bool details, struct json* response)
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_MAX_CONNECTIONS, (uintptr_t)config->limits[i].max_size, ValueUInt32);
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_INITIAL_CONNECTIONS, (uintptr_t)config->limits[i].initial_size, ValueUInt32);
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_MIN_CONNECTIONS, (uintptr_t)config->limits[i].min_size, ValueUInt32);

pgagroal_json_append(limits, (uintptr_t)js, ValueJSON);
}

pgagroal_json_put(response, MANAGEMENT_ARGUMENT_LIMITS, (uintptr_t)limits, ValueJSON);

pgagroal_json_create(&databases);

for (int i = 0; i < NUMBER_OF_DISABLED; i++)
Expand All @@ -264,19 +264,19 @@ status_details(bool details, struct json* response)
pgagroal_json_create(&js);

pgagroal_json_put(js, MANAGEMENT_ARGUMENT_DATABASE, (uintptr_t)"*", ValueString);
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_ENABLED, (uintptr_t)!config->all_disabled, ValueBool);
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_ENABLED, (uintptr_t) !config->all_disabled, ValueBool);

pgagroal_json_append(databases, (uintptr_t)js, ValueJSON);
}

pgagroal_json_put(response, MANAGEMENT_ARGUMENT_DATABASES, (uintptr_t)databases, ValueJSON);

for (int i = 0; i < config->max_connections; i++)
{
struct json* js = NULL;

pgagroal_json_create(&js);

pgagroal_json_put(js, MANAGEMENT_ARGUMENT_START_TIME, (uintptr_t)config->connections[i].start_time, ValueInt64);
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_TIMESTAMP, (uintptr_t)config->connections[i].timestamp, ValueInt64);

Expand All @@ -286,7 +286,7 @@ status_details(bool details, struct json* response)
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_DATABASE, (uintptr_t)config->connections[i].database, ValueString);
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_USERNAME, (uintptr_t)config->connections[i].username, ValueString);
pgagroal_json_put(js, MANAGEMENT_ARGUMENT_APPNAME, (uintptr_t)config->connections[i].appname, ValueString);

pgagroal_json_append(connections, (uintptr_t)js, ValueJSON);
}

Expand Down
48 changes: 24 additions & 24 deletions src/libpgagroal/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1272,30 +1272,30 @@ pgagroal_escape_string(char* str)
{
switch (str[i])
{
case '\\':
case '\"':
translated_ec_string[idx] = '\\';
idx++;
translated_ec_string[idx] = str[i];
break;
case '\n':
translated_ec_string[idx] = '\\';
idx++;
translated_ec_string[idx] = 'n';
break;
case '\t':
translated_ec_string[idx] = '\\';
idx++;
translated_ec_string[idx] = 't';
break;
case '\r':
translated_ec_string[idx] = '\\';
idx++;
translated_ec_string[idx] = 'r';
break;
default:
translated_ec_string[idx] = str[i];
break;
case '\\':
case '\"':
translated_ec_string[idx] = '\\';
idx++;
translated_ec_string[idx] = str[i];
break;
case '\n':
translated_ec_string[idx] = '\\';
idx++;
translated_ec_string[idx] = 'n';
break;
case '\t':
translated_ec_string[idx] = '\\';
idx++;
translated_ec_string[idx] = 't';
break;
case '\r':
translated_ec_string[idx] = '\\';
idx++;
translated_ec_string[idx] = 'r';
break;
default:
translated_ec_string[idx] = str[i];
break;
}
}
translated_ec_string[idx] = '\0'; // terminator
Expand Down
1 change: 0 additions & 1 deletion src/libpgagroal/zstandard_compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,3 @@ pgagroal_zstdd_string(unsigned char* compressed_buffer, size_t compressed_size,

return 0;
}

Loading

0 comments on commit ae2a0ce

Please sign in to comment.