fix all compiler warnings: array-bool, pointer-sign, tautological, unsequenced
This commit is contained in:
1 parent
a0e5446790
commit
68f4ae12c8
8 files changed
+25
-31
No files matched your search
@@ -257,10 +257,10 @@ int config_ensure_keys_and_node_id(const char *filename) {
|
||||
|
||||
// Debug: print what we found
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_CONFIG, "Checking config - priv_key='%s' (len=%zu), pub_key='%s' (len=%zu), node_id=%016llx",
|
||||
global->my_private_key_hex ? global->my_private_key_hex : "NULL",
|
||||
global->my_private_key_hex ? strlen(global->my_private_key_hex) : 0,
|
||||
global->my_public_key_hex ? global->my_public_key_hex : "NULL",
|
||||
global->my_public_key_hex ? strlen(global->my_public_key_hex) : 0,
|
||||
global->my_private_key_hex[0] ? global->my_private_key_hex : "NULL",
|
||||
global->my_private_key_hex[0] ? strlen(global->my_private_key_hex) : 0,
|
||||
global->my_public_key_hex[0] ? global->my_public_key_hex : "NULL",
|
||||
global->my_public_key_hex[0] ? strlen(global->my_public_key_hex) : 0,
|
||||
(unsigned long long)global->my_node_id);
|
||||
|
||||
|
||||
|
||||
+8
-11
@@ -57,24 +57,21 @@ int etcp_bind(struct UTUN_INSTANCE* inst, uint8_t id, etcp_recv_fn callback) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (id >= ETCP_MAX_BINDINGS) {
|
||||
if ((unsigned)id >= ETCP_MAX_BINDINGS) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP_API, "etcp_bind: Invalid ID %u (max=%d)", id, ETCP_MAX_BINDINGS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (!callback) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP_API, "etcp_bind: NULL callback for id=%u", id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (inst->api_bindings.callbacks[id] != NULL) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_ETCP_API, "etcp_bind: ID %u already bound, overwriting", id);
|
||||
DEBUG_WARN(DEBUG_CATEGORY_ETCP_API, "etcp_bind: Overwriting existing callback for id=%u", id);
|
||||
}
|
||||
|
||||
inst->api_bindings.callbacks[id] = callback;
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP_API, "etcp_bind: Bound ID %u to callback %p for instance %p",
|
||||
id, (void*)callback, (void*)inst);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP_API, "etcp_bind: Bound id=%u → callback=%p", id, (void*)callback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,8 +80,8 @@ int etcp_unbind(struct UTUN_INSTANCE* inst, uint8_t id) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP_API, "etcp_unbind: NULL instance");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (id >= ETCP_MAX_BINDINGS) {
|
||||
|
||||
if ((unsigned)id >= ETCP_MAX_BINDINGS) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP_API, "etcp_unbind: Invalid ID %u", id);
|
||||
return -1;
|
||||
}
|
||||
@@ -177,7 +174,7 @@ void etcp_int_recv(struct ll_queue* queue, void* arg) {
|
||||
}
|
||||
|
||||
// Ищем binding для этого ID в instance
|
||||
if (id < ETCP_MAX_BINDINGS && inst->api_bindings.callbacks[id] != NULL) {
|
||||
if (inst->api_bindings.callbacks[id] != NULL) {
|
||||
// Вызываем коллбэк
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP_API, "etcp_recv: Delivering packet ID %u to callback %p",
|
||||
id, (void*)inst->api_bindings.callbacks[id]);
|
||||
|
||||
@@ -478,9 +478,7 @@ int etcp_find_free_local_link_id(struct ETCP_CONN* etcp) {
|
||||
// Помечаем занятые id
|
||||
struct ETCP_LINK* link = etcp->links;
|
||||
while (link) {
|
||||
if (link->local_link_id < 256) {
|
||||
used_ids[link->local_link_id >> 3] |= (1 << (link->local_link_id & 7));
|
||||
}
|
||||
used_ids[link->local_link_id >> 3] |= (1 << (link->local_link_id & 7));
|
||||
link = link->next;
|
||||
}
|
||||
|
||||
@@ -1774,7 +1772,8 @@ process_decrypted:
|
||||
memory_pool_free(e_sock->instance->pkt_pool, pkt);
|
||||
return;
|
||||
}
|
||||
link->mtu_remote = (pkt->data[offset++] << 8) | pkt->data[offset++];
|
||||
link->mtu_remote = ((uint16_t)pkt->data[offset] << 8) | pkt->data[offset + 1];
|
||||
offset += 2;
|
||||
if (link->mtu_remote > PACKET_DATA_MAX_MTU) link->mtu_remote = PACKET_DATA_MAX_MTU;
|
||||
link->mtu = link->mtu_local < link->mtu_remote ? link->mtu_local : link->mtu_remote;
|
||||
link->remote_link_id = pkt->data[offset++];
|
||||
|
||||
@@ -232,7 +232,7 @@ int etcp_loadbalancer_get_link_status(struct ETCP_CONN* etcp) {
|
||||
}
|
||||
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] link status check: %d alive links",
|
||||
etcp->log_name ? etcp->log_name : "????→????", alive_count);
|
||||
etcp->log_name[0] ? etcp->log_name : "????→????", alive_count);
|
||||
|
||||
return (alive_count > 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
+2
-4
@@ -25,7 +25,7 @@ static void etcp_router_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry)
|
||||
uint8_t svc_id = entry->dgram[1];
|
||||
uint64_t dst_node_id = 0; memcpy(&dst_node_id, entry->dgram + 2, 8);
|
||||
if (dst_node_id == inst->node_id) {
|
||||
if (svc_id >= SVC_ROUTE_MAX_BINDINGS || !inst->router_bindings.callbacks[svc_id]) {
|
||||
if (!inst->router_bindings.callbacks[svc_id]) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "etcp_router: no handler for svc_id=%u dst=%016llx self=%016llx",
|
||||
svc_id, (unsigned long long)dst_node_id, (unsigned long long)inst->node_id);
|
||||
queue_entry_free(entry); queue_dgram_free(entry);
|
||||
@@ -80,7 +80,6 @@ void etcp_router_destroy(struct UTUN_INSTANCE* inst) {
|
||||
|
||||
int etcp_router_bind(struct UTUN_INSTANCE* inst, uint8_t svc_id, etcp_recv_fn callback) {
|
||||
if (!inst) { DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "etcp_router_bind: NULL instance"); return -1; }
|
||||
if (svc_id >= SVC_ROUTE_MAX_BINDINGS) { DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "etcp_router_bind: invalid svc_id %u", svc_id); return -1; }
|
||||
if (!callback) { DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "etcp_router_bind: NULL callback for svc_id=%u", svc_id); return -1; }
|
||||
if (inst->router_bindings.callbacks[svc_id]) DEBUG_WARN(DEBUG_CATEGORY_ETCP, "etcp_router_bind: overwriting svc_id=%u", svc_id);
|
||||
inst->router_bindings.callbacks[svc_id] = callback;
|
||||
@@ -90,7 +89,6 @@ int etcp_router_bind(struct UTUN_INSTANCE* inst, uint8_t svc_id, etcp_recv_fn ca
|
||||
|
||||
int etcp_router_unbind(struct UTUN_INSTANCE* inst, uint8_t svc_id) {
|
||||
if (!inst) { DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "etcp_router_unbind: NULL instance"); return -1; }
|
||||
if (svc_id >= SVC_ROUTE_MAX_BINDINGS) { DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "etcp_router_unbind: invalid svc_id %u", svc_id); return -1; }
|
||||
if (!inst->router_bindings.callbacks[svc_id]) { DEBUG_WARN(DEBUG_CATEGORY_ETCP, "etcp_router_unbind: svc_id=%u not bound", svc_id); return -1; }
|
||||
inst->router_bindings.callbacks[svc_id] = NULL;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "etcp_router_unbind: svc_id=%u", svc_id);
|
||||
@@ -114,7 +112,7 @@ int etcp_route_send(struct UTUN_INSTANCE* inst, uint64_t dst_node_id, struct ll_
|
||||
// Loopback — dispatch прямо локально
|
||||
if (dst_node_id == inst->node_id) {
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "etcp_route_send: loopback svc_id=%u len=%zu", svc_id, payload_len);
|
||||
if (svc_id < SVC_ROUTE_MAX_BINDINGS && inst->router_bindings.callbacks[svc_id])
|
||||
if (inst->router_bindings.callbacks[svc_id])
|
||||
inst->router_bindings.callbacks[svc_id](NULL, entry);
|
||||
else { queue_entry_free(entry); queue_dgram_free(entry); }
|
||||
return 0;
|
||||
|
||||
@@ -256,15 +256,15 @@ sc_status_t sc_init_local_keys(struct SC_MYKEYS *mykeys, const char *public_key,
|
||||
return SC_OK;
|
||||
}
|
||||
|
||||
sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const char *peer_public_key_h, int mode) {
|
||||
sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const uint8_t *peer_public_key_h, int mode) {
|
||||
uint8_t peer_public_key[SC_PUBKEY_SIZE];
|
||||
if (mode) {
|
||||
if (hex_to_binary(peer_public_key_h, peer_public_key, SC_PUBKEY_SIZE)) {
|
||||
if (hex_to_binary((const char*)peer_public_key_h, peer_public_key, SC_PUBKEY_SIZE)) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "sc_set_peer_public_key: invalid hex key format");
|
||||
return SC_ERR_INVALID_ARG;
|
||||
}
|
||||
} else {
|
||||
memcpy(peer_public_key, (const uint8_t *)peer_public_key_h, SC_PUBKEY_SIZE);
|
||||
memcpy(peer_public_key, peer_public_key_h, SC_PUBKEY_SIZE);
|
||||
}
|
||||
if (!ctx) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "sc_set_peer_public_key: invalid ctx");
|
||||
@@ -616,12 +616,12 @@ sc_status_t sc_init_local_keys(struct SC_MYKEYS *mykeys, const char *public_key,
|
||||
return SC_OK;
|
||||
}
|
||||
|
||||
sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const char *peer_public_key_h, int mode) {
|
||||
sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const uint8_t *peer_public_key_h, int mode) {
|
||||
uint8_t shared_secret[SC_SHARED_SECRET_SIZE];
|
||||
uint8_t peer_public_key[SC_PUBKEY_SIZE];
|
||||
|
||||
if (mode) {
|
||||
if (hex_to_binary(peer_public_key_h, peer_public_key, SC_PUBKEY_SIZE)) {
|
||||
if (hex_to_binary((const char*)peer_public_key_h, peer_public_key, SC_PUBKEY_SIZE)) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "sc_set_peer_public_key: invalid hex key format");
|
||||
return SC_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ struct secure_channel {
|
||||
sc_status_t sc_init_ctx(sc_context_t *ctx, struct SC_MYKEYS *mykeys);
|
||||
sc_status_t sc_generate_keypair(struct SC_MYKEYS *keys);
|
||||
sc_status_t sc_init_local_keys(struct SC_MYKEYS *mykeys, const char *public_key, const char *private_key);
|
||||
sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const char *peer_public_key, int mode);// mode: 0-bin 1-hex key format
|
||||
sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const uint8_t *peer_public_key, int mode);// mode: 0-bin 1-hex key format
|
||||
sc_status_t sc_compute_public_key_from_private(const uint8_t *private_key, uint8_t *public_key);
|
||||
|
||||
// Криптографические операции
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ struct UTUN_INSTANCE* utun_instance_create(struct UASYNC* ua, const char *config
|
||||
}
|
||||
|
||||
// Open log file only if not using global debug system output
|
||||
if (config->global.log_file) {
|
||||
if (config->global.log_file[0]) {
|
||||
debug_set_output_file(config->global.log_file);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user