fix warnings during building (#567)

* make some functions from mdb_iamproxy.c static

* fix new line symbol missing

* make apply_fmt

* fix warnings during building

* make apply_fmt

* fix issues

---------

Co-authored-by: Andrey Ovchinnikov <ch1nn1y@yandex-team.ru>
This commit is contained in:
Ovchinnikov Andrew 2024-02-07 13:43:13 +03:00 committed by GitHub
parent 91e28d1769
commit b1d611019f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 27 additions and 19 deletions

View File

@ -1561,8 +1561,9 @@ static inline od_frontend_status_t od_frontend_poll_catchup(od_client_t *client,
int absent_heartbeat_checks = 0;
while (route->last_heartbeat == 0) {
machine_sleep(ODYSSEY_CATCHUP_RECHECK_INTERVAL);
if (absent_heartbeat_checks++ >
(timeout * 1000 / ODYSSEY_CATCHUP_RECHECK_INTERVAL)) {
if ((int64_t)absent_heartbeat_checks++ > // add cast to int64_t for correct camparison (int64_t > int and ibt64_t > uint32_t)
(int64_t)(timeout * 1000 /
ODYSSEY_CATCHUP_RECHECK_INTERVAL)) {
od_debug(&instance->logger, "catchup", client, NULL,
"No heartbeat for route detected\n");
return OD_ECATCHUP_TIMEOUT;

View File

@ -249,6 +249,7 @@ od_hashmap_elt_t *od_hashmap_lock_key(od_hashmap_t *hm, od_hash_t keyhash,
int od_hashmap_unlock_key(od_hashmap_t *hm, od_hash_t keyhash,
od_hashmap_elt_t *key)
{
(void)key;
size_t bucket_index = keyhash % hm->size;
pthread_mutex_unlock(&hm->buckets[bucket_index]->mu);
return 0 /* OK */;

View File

@ -90,7 +90,6 @@ void od_config_testing(od_instance_t *instance)
error:
od_router_free(&router);
return NOT_OK_RESPONSE;
}
static inline void od_bind_version()

View File

@ -225,6 +225,12 @@ od_logger_format(od_logger_t *logger, od_logger_level_t level, char *context,
dst_pos += len;
break;
}
// fall throught fix (if client is not defined will write 'none' to log file)
len = od_snprintf(dst_pos, dst_end - dst_pos,
"none");
dst_pos += len;
break;
}
/* unixtime */
case 'n': {

View File

@ -5,8 +5,9 @@
* Scalable PostgreSQL connection pooler.
*/
#include <odyssey.h>
#include <machinarium.h>
#include <kiwi.h>
#include <odyssey.h>
#include <limits.h>
#include <stdint.h>
#include <malloc.h>
@ -58,7 +59,6 @@ machine_msg_t *mdb_iamproxy_io_read(machine_io_t *io)
machine_msg_t *msg;
uint64_t body_size = 0;
uint64_t received = 0;
/* RECEIVE HEADER */
header = machine_read(io, MDB_IAMPROXY_DEFAULT_HEADER_SIZE,
@ -114,8 +114,10 @@ free_end:
return send_result;
}
int mdb_iamproxy_authenticate_user(const char *username, const char *token,
od_instance_t *instance, od_client_t *client)
int mdb_iamproxy_authenticate_user(
char *username,
char *token, // remove const because machine_msg_write use as buf - non constant values (but do nothing ith them....)
od_instance_t *instance, od_client_t *client)
{
int32_t authentication_result =
MDB_IAMPROXY_CONN_DENIED; // stores authenticate status for user (default value: CONN_DENIED)
@ -246,7 +248,6 @@ int mdb_iamproxy_authenticate_user(const char *username, const char *token,
client->id.id, client->external_id);
/*FREE RESOURCES*/
free_external_user:
machine_msg_free(external_user);
free_auth_status:
machine_msg_free(auth_status);

View File

@ -1,13 +1,7 @@
#ifndef ODYSSEY_IAMPROXY_H
#define ODYSSEY_IAMPROXY_H
/*
* Odyssey.
*
* Scalable PostgreSQL connection pooler.
*/
int mdb_iamproxy_authenticate_user(const char *username, const char *token,
int mdb_iamproxy_authenticate_user(char *username, char *token,
od_instance_t *instance,
od_client_t *client);

View File

@ -149,4 +149,5 @@
#include "sources/frontend.h"
#include "sources/backend.h"
#include "sources/mdb_iamproxy.h"
#endif /* ODYSSEY_H */

View File

@ -27,6 +27,7 @@ void od_router_init(od_router_t *router, od_global_t *global)
static inline int od_router_immed_close_server_cb(od_server_t *server,
void **argv)
{
(void)argv;
od_route_t *route = server->route;
/* remove server for server pool */
od_pg_server_pool_set(&route->server_pool, server, OD_SERVER_UNDEF);
@ -347,7 +348,8 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client)
od_router_lock(router);
/* match latest version of route rule */
od_rule_t *rule;
od_rule_t *rule =
NULL; // initialize rule for (line 365) and flag '-Wmaybe-uninitialized'
switch (client->type) {
case OD_POOL_CLIENT_INTERNAL:
rule = od_rules_forward(&router->rules, startup->database.value,
@ -357,6 +359,8 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client)
rule = od_rules_forward(&router->rules, startup->database.value,
startup->user.value, 0);
break;
case OD_POOL_CLIENT_UNDEF: // create that case for correct work of '-Wswitch' flag
break;
}
if (rule == NULL) {

View File

@ -641,8 +641,9 @@ int od_scram_read_client_final_message(machine_io_t *io,
/*channel binding check*/
/* Fetch hash data of server's SSL certificate */
scram_rc =
machine_tls_cert_hash(io, &cbind_data, &cbind_data_len);
scram_rc = machine_tls_cert_hash(
io, &cbind_data,
(uint32_t *)&cbind_data_len); // TODO: maybe rework of machinarium beacuse it's strange that we use size_t here and uint32_t in machinarium
/* should not happen */
if (scram_rc != OK_RESPONSE) {

View File

@ -149,7 +149,7 @@ static inline void od_stat_update_of(od_atomic_u64_t *prev,
{
/* todo: this could be made more optimal */
/* prev <= current */
__atomic_store(prev, current, __ATOMIC_SEQ_CST);
__atomic_store((uint64_t *)prev, (uint64_t *)current, __ATOMIC_SEQ_CST);
}
static inline void od_stat_update(od_stat_t *dst, od_stat_t *stat)