-fix compiler warnings

This commit is contained in:
Christian Grothoff 2022-11-14 05:08:11 +01:00
parent 231cdaf4f7
commit 9db572706d
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 40 additions and 109 deletions

View File

@ -26,6 +26,18 @@
#include "pg_helper.h" #include "pg_helper.h"
/**
* Connect to the database if the connection does not exist yet.
*
* @param pg the plugin-specific state
* @param skip_prepare true if we should skip prepared statement setup
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
TEH_PG_internal_setup (struct PostgresClosure *pg,
bool skip_prepare);
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TEH_PG_preflight (void *cls) TEH_PG_preflight (void *cls)
{ {
@ -38,9 +50,8 @@ TEH_PG_preflight (void *cls)
if (! pg->init) if (! pg->init)
{ {
if (GNUNET_OK != if (GNUNET_OK !=
TEH_PG_internal_setup (pg,
internal_setup (pg, false))
false))
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (NULL == pg->transaction_name) if (NULL == pg->transaction_name)

View File

@ -23,11 +23,12 @@
#include "taler_dbevents.h" #include "taler_dbevents.h"
#include "taler_pq_lib.h" #include "taler_pq_lib.h"
#include "pg_start_read_only.h" #include "pg_start_read_only.h"
#include "pg_preflight.h"
#include "pg_helper.h" #include "pg_helper.h"
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TEH_PG_start_read_only (void *cls, TEH_PG_start_read_only (void *cls,
const char *name) const char *name)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_ExecuteStatement es[] = { struct GNUNET_PQ_ExecuteStatement es[] = {

View File

@ -77,10 +77,10 @@ TEh_PG_update_kyc_process_by_row (
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
postgres_event_notify (pg, GNUNET_PQ_event_notify (pg->conn,
&rep.header, &rep.header,
NULL, NULL,
0); 0);
PREPARE (pg, PREPARE (pg,
"alert_kyc_status_change", "alert_kyc_status_change",
"INSERT INTO kyc_alerts" "INSERT INTO kyc_alerts"
@ -99,5 +99,3 @@ TEh_PG_update_kyc_process_by_row (
} }
return qs; return qs;
} }

View File

@ -130,7 +130,6 @@
} while (0) } while (0)
/** /**
* Create the necessary tables if they are not present * Create the necessary tables if they are not present
* *
@ -158,7 +157,6 @@ postgres_create_tables (void *cls)
} }
/** /**
* Setup foreign servers (shards) for already existing tables * Setup foreign servers (shards) for already existing tables
* *
@ -262,7 +260,7 @@ postgres_setup_foreign_servers (void *cls,
* @param[in,out] pg connection to initialize * @param[in,out] pg connection to initialize
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
static enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
prepare_statements (struct PostgresClosure *pg) prepare_statements (struct PostgresClosure *pg)
{ {
enum GNUNET_GenericReturnValue ret; enum GNUNET_GenericReturnValue ret;
@ -342,7 +340,7 @@ prepare_statements (struct PostgresClosure *pg)
" FROM denominations" " FROM denominations"
" LEFT JOIN " " LEFT JOIN "
" denomination_revocations USING (denominations_serial);"), " denomination_revocations USING (denominations_serial);"),
/* Used in #postgres_iterate_auditor_denominations() */ /* Used in #postgres_iterate_auditor_denominations() */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"select_auditor_denoms", "select_auditor_denoms",
@ -491,9 +489,8 @@ prepare_statements (struct PostgresClosure *pg)
",closing_fee_frac" ",closing_fee_frac"
",close_request_row" ",close_request_row"
") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9);"), ") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9);"),
/* Used in #postgres_reserves_update() when the reserve is updated */ /* Used in #postgres_reserves_update() when the reserve is updated */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"reserve_update", "reserve_update",
@ -565,7 +562,7 @@ prepare_statements (struct PostgresClosure *pg)
",ruuid" ",ruuid"
" FROM exchange_do_batch_withdraw" " FROM exchange_do_batch_withdraw"
" ($1,$2,$3,$4,$5);"), " ($1,$2,$3,$4,$5);"),
/* Used in #postgres_do_deposit() to execute a deposit, /* Used in #postgres_do_deposit() to execute a deposit,
checking the coin's balance in the process as needed. */ checking the coin's balance in the process as needed. */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
@ -1309,7 +1306,7 @@ prepare_statements (struct PostgresClosure *pg)
" WHERE dep.coin_pub=$1" " WHERE dep.coin_pub=$1"
" AND dep.merchant_pub=$3" " AND dep.merchant_pub=$3"
" AND dep.h_contract_terms=$2"), " AND dep.h_contract_terms=$2"),
/* Used in #postgres_get_wire_fee() */ /* Used in #postgres_get_wire_fee() */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"get_wire_fee", "get_wire_fee",
@ -1739,7 +1736,7 @@ prepare_statements (struct PostgresClosure *pg)
" WHERE denom_pub_hash=$2);"), " WHERE denom_pub_hash=$2);"),
/* Used in #postgres_begin_shard() */ /* Used in #postgres_begin_shard() */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"get_open_shard", "get_open_shard",
"SELECT" "SELECT"
@ -1814,9 +1811,6 @@ prepare_statements (struct PostgresClosure *pg)
"DO UPDATE SET manifest=$2"), "DO UPDATE SET manifest=$2"),
/* Used in #postgres_select_purse_by_merge_pub */ /* Used in #postgres_select_purse_by_merge_pub */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"select_purse_by_merge_pub", "select_purse_by_merge_pub",
@ -1832,8 +1826,8 @@ prepare_statements (struct PostgresClosure *pg)
",purse_sig" ",purse_sig"
" FROM purse_requests" " FROM purse_requests"
" WHERE merge_pub=$1;"), " WHERE merge_pub=$1;"),
/* Used in #postgres_do_account_merge() */ /* Used in #postgres_do_account_merge() */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"call_account_merge", "call_account_merge",
@ -1842,7 +1836,6 @@ prepare_statements (struct PostgresClosure *pg)
" ($1, $2, $3);"), " ($1, $2, $3);"),
/* Used in #postgres_update_kyc_requirement_by_row() */ /* Used in #postgres_update_kyc_requirement_by_row() */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"update_legitimization_process", "update_legitimization_process",
@ -1854,11 +1847,6 @@ prepare_statements (struct PostgresClosure *pg)
" h_payto=$3" " h_payto=$3"
" AND legitimization_process_serial_id=$1" " AND legitimization_process_serial_id=$1"
" AND provider_section=$2;"), " AND provider_section=$2;"),
GNUNET_PQ_PREPARED_STATEMENT_END GNUNET_PQ_PREPARED_STATEMENT_END
@ -1880,9 +1868,9 @@ prepare_statements (struct PostgresClosure *pg)
* @param skip_prepare true if we should skip prepared statement setup * @param skip_prepare true if we should skip prepared statement setup
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
static enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
internal_setup (struct PostgresClosure *pg, TEH_PG_internal_setup (struct PostgresClosure *pg,
bool skip_prepare) bool skip_prepare)
{ {
if (NULL == pg->conn) if (NULL == pg->conn)
{ {
@ -1936,8 +1924,6 @@ internal_setup (struct PostgresClosure *pg,
} }
/** /**
* Register callback to be invoked on events of type @a es. * Register callback to be invoked on events of type @a es.
* *
@ -2004,7 +1990,6 @@ postgres_event_notify (void *cls,
} }
/** /**
* Fetch information about a denomination key. * Fetch information about a denomination key.
* *
@ -2835,12 +2820,12 @@ postgres_reserves_in_insert (void *cls,
(We are only run in a larger transaction for performance.) */ (We are only run in a larger transaction for performance.) */
enum GNUNET_DB_QueryStatus cs; enum GNUNET_DB_QueryStatus cs;
cs = TEH_PG_commit(pg); cs = TEH_PG_commit (pg);
if (cs < 0) if (cs < 0)
return cs; return cs;
if (GNUNET_OK != if (GNUNET_OK !=
TEH_PG_start (pg, TEH_PG_start (pg,
"reserve-update-serializable")) "reserve-update-serializable"))
{ {
GNUNET_break (0); GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
@ -2920,7 +2905,7 @@ postgres_reserves_in_insert (void *cls,
if (cs < 0) if (cs < 0)
return cs; return cs;
if (GNUNET_OK != if (GNUNET_OK !=
TEH_PG_start_read_committed (pg, "reserve-insert-continued")) TEH_PG_start_read_committed (pg, "reserve-insert-continued"))
{ {
GNUNET_break (0); GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
@ -3029,8 +3014,6 @@ postgres_do_batch_withdraw (
} }
/** /**
* Compute the shard number of a given @a merchant_pub. * Compute the shard number of a given @a merchant_pub.
* *
@ -5096,7 +5079,6 @@ postgres_lookup_transfer_by_deposit (
} }
/** /**
* Obtain wire fee from database. * Obtain wire fee from database.
* *
@ -7960,8 +7942,6 @@ postgres_insert_auditor (void *cls,
} }
/** /**
* Check the last date an exchange wire account was modified. * Check the last date an exchange wire account was modified.
* *
@ -8434,8 +8414,6 @@ postgres_add_denomination_key (
} }
/** /**
* Lookup signing key meta data. * Lookup signing key meta data.
* *
@ -8537,8 +8515,6 @@ postgres_select_auditor_denom_sig (
} }
/** /**
* Function called to grab a work shard on an operation @a op. Runs in its * Function called to grab a work shard on an operation @a op. Runs in its
* own transaction. * own transaction.
@ -8565,7 +8541,7 @@ postgres_begin_shard (void *cls,
{ {
if (GNUNET_OK != if (GNUNET_OK !=
TEH_PG_start (pg, TEH_PG_start (pg,
"begin_shard")) "begin_shard"))
{ {
GNUNET_break (0); GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
@ -8803,7 +8779,6 @@ postgres_complete_shard (void *cls,
} }
/** /**
* Function called to release a revolving shard * Function called to release a revolving shard
* back into the work pool. Clears the * back into the work pool. Clears the
@ -8895,8 +8870,6 @@ postgres_set_extension_manifest (void *cls,
} }
/** /**
* Function called to store configuration data about a partner * Function called to store configuration data about a partner
* exchange that we are federated with. * exchange that we are federated with.
@ -8939,13 +8912,6 @@ postgres_insert_partner (void *cls,
} }
/** /**
* Function called to clean up one expired purse. * Function called to clean up one expired purse.
* *
@ -9045,8 +9011,6 @@ postgres_select_purse_by_merge_pub (
} }
/** /**
* Set the current @a balance in the purse * Set the current @a balance in the purse
* identified by @a purse_pub. Used by the auditor * identified by @a purse_pub. Used by the auditor
@ -9076,22 +9040,6 @@ postgres_set_purse_balance (
} }
/** /**
* Initialize Postgres database subsystem. * Initialize Postgres database subsystem.
* *
@ -9190,8 +9138,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
return NULL; return NULL;
} }
if (GNUNET_OK != if (GNUNET_OK !=
internal_setup (pg, TEH_PG_internal_setup (pg,
true)) true))
{ {
GNUNET_free (pg->exchange_url); GNUNET_free (pg->exchange_url);
GNUNET_free (pg->currency); GNUNET_free (pg->currency);
@ -9202,22 +9150,14 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin); plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin);
plugin->cls = pg; plugin->cls = pg;
plugin->create_tables = &postgres_create_tables; plugin->create_tables = &postgres_create_tables;
plugin->setup_foreign_servers = &postgres_setup_foreign_servers; plugin->setup_foreign_servers = &postgres_setup_foreign_servers;
plugin->event_listen = &postgres_event_listen; plugin->event_listen = &postgres_event_listen;
plugin->event_listen_cancel = &postgres_event_listen_cancel; plugin->event_listen_cancel = &postgres_event_listen_cancel;
plugin->event_notify = &postgres_event_notify; plugin->event_notify = &postgres_event_notify;
plugin->get_denomination_info = &postgres_get_denomination_info; plugin->get_denomination_info = &postgres_get_denomination_info;
plugin->iterate_denomination_info = &postgres_iterate_denomination_info; plugin->iterate_denomination_info = &postgres_iterate_denomination_info;
plugin->iterate_denominations = &postgres_iterate_denominations; plugin->iterate_denominations = &postgres_iterate_denominations;
plugin->iterate_active_auditors = &postgres_iterate_active_auditors; plugin->iterate_active_auditors = &postgres_iterate_active_auditors;
plugin->iterate_auditor_denominations = plugin->iterate_auditor_denominations =
&postgres_iterate_auditor_denominations; &postgres_iterate_auditor_denominations;
@ -9229,7 +9169,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
plugin->do_batch_withdraw = &postgres_do_batch_withdraw; plugin->do_batch_withdraw = &postgres_do_batch_withdraw;
plugin->get_policy_details = &postgres_get_policy_details; plugin->get_policy_details = &postgres_get_policy_details;
plugin->persist_policy_details = &postgres_persist_policy_details; plugin->persist_policy_details = &postgres_persist_policy_details;
plugin->do_deposit = &postgres_do_deposit; plugin->do_deposit = &postgres_do_deposit;
plugin->add_policy_fulfillment_proof = &postgres_add_policy_fulfillment_proof; plugin->add_policy_fulfillment_proof = &postgres_add_policy_fulfillment_proof;
plugin->do_melt = &postgres_do_melt; plugin->do_melt = &postgres_do_melt;
@ -9338,11 +9277,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &postgres_insert_auditor_denom_sig; = &postgres_insert_auditor_denom_sig;
plugin->select_auditor_denom_sig plugin->select_auditor_denom_sig
= &postgres_select_auditor_denom_sig; = &postgres_select_auditor_denom_sig;
plugin->add_denomination_key plugin->add_denomination_key
= &postgres_add_denomination_key; = &postgres_add_denomination_key;
plugin->lookup_signing_key plugin->lookup_signing_key
= &postgres_lookup_signing_key; = &postgres_lookup_signing_key;
plugin->begin_shard plugin->begin_shard
@ -9351,35 +9287,21 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &postgres_abort_shard; = &postgres_abort_shard;
plugin->complete_shard plugin->complete_shard
= &postgres_complete_shard; = &postgres_complete_shard;
plugin->release_revolving_shard plugin->release_revolving_shard
= &postgres_release_revolving_shard; = &postgres_release_revolving_shard;
plugin->delete_shard_locks plugin->delete_shard_locks
= &postgres_delete_shard_locks; = &postgres_delete_shard_locks;
plugin->set_extension_manifest plugin->set_extension_manifest
= &postgres_set_extension_manifest; = &postgres_set_extension_manifest;
plugin->insert_partner plugin->insert_partner
= &postgres_insert_partner; = &postgres_insert_partner;
plugin->expire_purse plugin->expire_purse
= &postgres_expire_purse; = &postgres_expire_purse;
plugin->select_purse_by_merge_pub plugin->select_purse_by_merge_pub
= &postgres_select_purse_by_merge_pub; = &postgres_select_purse_by_merge_pub;
plugin->set_purse_balance plugin->set_purse_balance
= &postgres_set_purse_balance; = &postgres_set_purse_balance;
/* NEW style, sort alphabetically! */ /* NEW style, sort alphabetically! */
plugin->do_reserve_open plugin->do_reserve_open
= &TEH_PG_do_reserve_open; = &TEH_PG_do_reserve_open;
@ -9464,9 +9386,9 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
plugin->lookup_kyc_requirement_by_row plugin->lookup_kyc_requirement_by_row
= &TEH_PG_lookup_kyc_requirement_by_row; = &TEH_PG_lookup_kyc_requirement_by_row;
plugin->insert_kyc_requirement_for_account plugin->insert_kyc_requirement_for_account
= &TEH_PG_insert_kyc_requirement_for_account; = &TEH_PG_insert_kyc_requirement_for_account;
plugin->lookup_kyc_process_by_account plugin->lookup_kyc_process_by_account
= &TEH_PG_lookup_kyc_process_by_account; = &TEH_PG_lookup_kyc_process_by_account;
plugin->update_kyc_process_by_row plugin->update_kyc_process_by_row
@ -9529,7 +9451,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &TEH_PG_rollback; = &TEH_PG_rollback;
return plugin; return plugin;
} }