build: fix 7 risky warnings + slim debug profile to -g1
Warning fixes (from a 730-warning full-build census; these were the semantically risky ones): - test_repl_majority.c:272: remove a broken "field-existence" loop whose condition (i < ep != NULL) parsed wrong (-Wparentheses); the direct pending_ack_count write it guarded already exists and still fails the build if the field disappears. - ha.c:8593: ha_rdhup_election_hook now takes const xce_candidate_t** so RDHUP election can hand over candidates straight from the const peers_cfg without stripping const. All 5 test-side hook impls only (void)peers -- signature updated in ha.h + 3 test files. - ha.c:726/872/10804 endpoint_connect: constify the host parameter of endpoint_connect/socket_connect (netio.h/netio.c). The functions only pass host to gethostbyname(); peer->hostname etc. can now flow in without discarding const. All callers are read-only and unaffected. Debug profile (src/meson.build): drop -gdwarf-4 -g3 -fvar-tracking(-assignments) in favor of -ggdb -g1. Debug objects were ~16x larger with full DWARF (scheduler.c: 1.3MB vs 0.08MB), pushing the build tree to 3.9G; at -g1 it is 850M and a clean build drops from 6m43s to 4m36s. -g1 keeps file/line and backtraces; gdb variable/ macro inspection needs the asan profile. -fno-omit-frame-pointer kept. Verified: controller_unit_test 1342/1342, xcelib_test 758/758, all 126 scheduler suites + 18 worker suites green; modified sources compile with zero warnings. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
edb63e6095
commit
f1801fbef9
9 changed files with 24 additions and 27 deletions
|
|
@ -8585,7 +8585,7 @@ static void ha_enter_real_election(ha_state_t *ha, cluster_t *c)
|
|||
if (c->myconf && c->myconf->peers_cfg.candidates_count > 0) {
|
||||
const xce_cluster_config_t *cfg = &c->myconf->peers_cfg;
|
||||
int n = cfg->candidates_count > 0 ? cfg->candidates_count - 1 : 0;
|
||||
xce_candidate_t *peer_ptrs[MAX_HA_CANDIDATES];
|
||||
const xce_candidate_t *peer_ptrs[MAX_HA_CANDIDATES];
|
||||
int np = 0;
|
||||
for (int i = 0; i < cfg->candidates_count && np < n; i++) {
|
||||
if (strcmp(cfg->candidates[i].name,
|
||||
|
|
@ -9313,7 +9313,7 @@ void ha_start_election_async(ha_state_t *ha, cluster_t *c,
|
|||
* this instead of the real ha_start_election_async(). Req 6.3, 6.5, 9.3.
|
||||
*/
|
||||
void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers, const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag, uint64_t my_lsn,
|
||||
const char *my_name) = NULL;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2237,7 +2237,7 @@ uint64_t ha_trigger_manual_failover_for_test(ha_state_t *ha);
|
|||
* Requirements: 6.3, 6.5, 9.3.
|
||||
*/
|
||||
extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers, const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag, uint64_t my_lsn,
|
||||
const char *my_name);
|
||||
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ static void test_rdhup_on_minus_one_fd_is_safe(void)
|
|||
* async re-election (Req 6.3, 6.5, 9.3).
|
||||
*/
|
||||
extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers, const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag, uint64_t my_lsn,
|
||||
const char *my_name);
|
||||
|
||||
|
|
@ -272,7 +272,7 @@ static int g_rdhup_hook_n_peers = -1;
|
|||
static ha_state_t *g_rdhup_hook_ha = NULL;
|
||||
|
||||
static void rdhup_election_spy(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers, const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag, uint64_t my_lsn,
|
||||
const char *my_name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1503,7 +1503,7 @@ extern int ha_prevote_active_round_timer_for_test(uint64_t *round_out,
|
|||
extern void ha_prevote_round_timer_clear_for_test(void);
|
||||
extern _Atomic int ha_liveness_arm_count_for_test;
|
||||
extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers, const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag, uint64_t my_lsn,
|
||||
const char *my_name);
|
||||
|
||||
|
|
@ -1705,7 +1705,7 @@ static void test_r2_f2_refused_promotion_steps_down_and_rearms(void)
|
|||
*/
|
||||
static int g_r2_election_spy_calls = 0;
|
||||
static void r2_election_spy(ha_state_t *ha, cluster_t *c, int n_peers,
|
||||
xce_candidate_t **peers, uint64_t tag,
|
||||
const xce_candidate_t **peers, uint64_t tag,
|
||||
uint64_t lsn, const char *name)
|
||||
{
|
||||
(void)ha; (void)c; (void)n_peers; (void)peers; (void)tag; (void)lsn;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ extern int (*ha_phase2_hook)(void *c);
|
|||
extern int (*ha_push_config_hook)(void *c);
|
||||
extern int (*ha_send_ctrlhello_hook)(void *c);
|
||||
extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers, const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag, uint64_t my_lsn,
|
||||
const char *my_name);
|
||||
|
||||
|
|
@ -115,7 +115,8 @@ typedef struct {
|
|||
static rdhup_hook_state_t g_rdhup_state;
|
||||
|
||||
static void rdhup_election_drives_evaluate(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers,
|
||||
const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag,
|
||||
uint64_t my_lsn,
|
||||
const char *my_name)
|
||||
|
|
@ -401,7 +402,7 @@ static void test_rdhup_primary_dispatch_gate_opens(void)
|
|||
static int g_guard_hook_calls = 0;
|
||||
|
||||
static void counting_election_hook(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers, const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag, uint64_t my_lsn,
|
||||
const char *my_name)
|
||||
{
|
||||
|
|
@ -521,7 +522,7 @@ static uint64_t g_captured_my_lsn = 0;
|
|||
static uint64_t g_captured_my_tag = 0;
|
||||
|
||||
static void capture_lsn_hook(ha_state_t *ha, cluster_t *c,
|
||||
int n_peers, xce_candidate_t **peers,
|
||||
int n_peers, const xce_candidate_t **peers,
|
||||
uint64_t my_config_tag, uint64_t my_lsn,
|
||||
const char *my_name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -268,13 +268,8 @@ static void test_broadcast_over_limit_removes_standby(void)
|
|||
repl_add_standby(&r, &ep0, "sb0", 7000);
|
||||
|
||||
/* Artificially inflate pending_ack_count past the limit.
|
||||
* After overflow the standby should be evicted (in_catch_up=1 or removed). */
|
||||
for (int i = 0; i < r.standbys[0].ep != NULL ? 1 : 0; i++) {
|
||||
/* Access the pending_ack_count field — this will fail to compile if
|
||||
* the field does not exist on standby_conn_t */
|
||||
r.standbys[0].pending_ack_count = MAX_PENDING_ACKS + 1;
|
||||
}
|
||||
/* Also verify the field exists via a direct write */
|
||||
* After overflow the standby should be evicted (in_catch_up=1 or removed).
|
||||
* This also fails to compile if the field is missing on standby_conn_t. */
|
||||
r.standbys[0].pending_ack_count = MAX_PENDING_ACKS + 1;
|
||||
|
||||
/* Broadcast a wal entry — the over-limit standby should be evicted */
|
||||
|
|
|
|||
|
|
@ -181,12 +181,12 @@ extern void free_packet(io_packet_t*);
|
|||
|
||||
extern endpoint_t* endpoint_get(void);
|
||||
extern int endpoint_init(endpoint_t*, int, int, int, int);
|
||||
extern int endpoint_connect(endpoint_t*, char*, int, int);
|
||||
extern int endpoint_connect(endpoint_t*, const char*, int, int);
|
||||
/* socket_connect: bounded, non-blocking TCP connect on an existing fd.
|
||||
* connect_timeout_ms == 0 uses DEFAULT_CONNECT_TIMEOUT_MS (config.h).
|
||||
* Returns 0 on success (fd left non-blocking), -ETIMEDOUT on bound expiry,
|
||||
* or -<errno> on error. raft-drive-async R2.3. */
|
||||
extern int socket_connect(int sock, char* host, int port,
|
||||
extern int socket_connect(int sock, const char* host, int port,
|
||||
int connect_timeout_ms);
|
||||
extern int endpoint_accept(endpoint_t*, endpoint_t*);
|
||||
extern int endpoint_set_conn_handler(endpoint_t*, conn_handler_t);
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ static int socket_create(int domain, int type, int port, int backlog)
|
|||
* -ETIMEDOUT — poll bound expired before the connect completed
|
||||
* -<errno> — name resolution / socket / connect error (e.g. -ECONNREFUSED)
|
||||
*/
|
||||
int socket_connect(int sock, char* host, int port, int connect_timeout_ms)
|
||||
int socket_connect(int sock, const char* host, int port, int connect_timeout_ms)
|
||||
{
|
||||
struct sockaddr_in server;
|
||||
struct hostent* hp;
|
||||
|
|
@ -899,7 +899,7 @@ int endpoint_init(endpoint_t* ep, int domain, int type, int port, int backlog)
|
|||
return fd;
|
||||
}
|
||||
|
||||
int endpoint_connect(endpoint_t* ep, char* host, int port,
|
||||
int endpoint_connect(endpoint_t* ep, const char* host, int port,
|
||||
int connect_timeout_ms)
|
||||
{
|
||||
int rc = -1;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,11 @@ component = get_option('component')
|
|||
with_debug = false
|
||||
|
||||
if get_option('buildtype') == 'debug'
|
||||
# add -DWITH_DEBUG=1
|
||||
# Debug profile: -O0 with line-tables-only debug info (-g1). Objects at -g3
|
||||
# carry full macro/variable DWARF and were ~16x larger (scheduler.c object:
|
||||
# 1.3MB at -g3 vs 0.08MB at -g1), which made the build tree balloon to
|
||||
# multi-GB. -g1 keeps file/line and backtraces; variable/macro inspection
|
||||
# in gdb is lost -- use the asan profile for that when debugging state.
|
||||
add_project_arguments(['-DWITH_DEBUG=1',
|
||||
'-DDEBUG',
|
||||
'-O0',
|
||||
|
|
@ -18,10 +22,7 @@ if get_option('buildtype') == 'debug'
|
|||
'-fno-inline',
|
||||
'-fno-omit-frame-pointer',
|
||||
'-ggdb',
|
||||
'-gdwarf-4',
|
||||
'-g3',
|
||||
'-fvar-tracking',
|
||||
'-fvar-tracking-assignments',
|
||||
'-g1',
|
||||
], language: ['c', 'cpp'])
|
||||
add_project_link_arguments('-fno-lto', language: ['c', 'cpp'])
|
||||
with_debug = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue