cleanup: Mark Mono_Time const where possible.

This commit is contained in:
iphydf 2022-03-28 14:09:43 +00:00
parent d56cb13279
commit ad90f5bbb8
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
7 changed files with 21 additions and 21 deletions

View File

@ -26,9 +26,9 @@ static inline IP get_loopback(void)
#endif
return ip;
}
static void do_onion(Onion *onion)
static void do_onion(Mono_Time *mono_time, Onion *onion)
{
mono_time_update(onion->mono_time);
mono_time_update(mono_time);
networking_poll(onion->net, nullptr);
do_dht(onion->dht);
@ -229,16 +229,16 @@ static void test_basic(void)
handled_test_1 = 0;
do {
do_onion(onion1);
do_onion(onion2);
do_onion(mono_time1, onion1);
do_onion(mono_time2, onion2);
} while (handled_test_1 == 0);
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE_OLD, &handle_test_2, onion1);
handled_test_2 = 0;
do {
do_onion(onion1);
do_onion(onion2);
do_onion(mono_time1, onion1);
do_onion(mono_time2, onion2);
} while (handled_test_2 == 0);
Onion_Announce *onion1_a = new_onion_announce(log1, mono_time1, onion1->dht);
@ -260,8 +260,8 @@ static void test_basic(void)
handled_test_3 = 0;
do {
do_onion(onion1);
do_onion(onion2);
do_onion(mono_time1, onion1);
do_onion(mono_time2, onion2);
c_sleep(50);
} while (handled_test_3 == 0);
@ -278,8 +278,8 @@ static void test_basic(void)
dht_get_self_public_key(onion1->dht), s);
do {
do_onion(onion1);
do_onion(onion2);
do_onion(mono_time1, onion1);
do_onion(mono_time2, onion2);
c_sleep(50);
} while (memcmp(onion_announce_entry_public_key(onion2_a, ONION_ANNOUNCE_MAX_ENTRIES - 2),
dht_get_self_public_key(onion1->dht),
@ -303,8 +303,8 @@ static void test_basic(void)
handled_test_4 = 0;
do {
do_onion(onion1);
do_onion(onion2);
do_onion(mono_time1, onion1);
do_onion(mono_time2, onion2);
c_sleep(50);
} while (handled_test_4 == 0);

View File

@ -641,7 +641,7 @@ void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *o
onion->callback_object = object;
}
Onion *new_onion(const Logger *log, Mono_Time *mono_time, DHT *dht)
Onion *new_onion(const Logger *log, const Mono_Time *mono_time, DHT *dht)
{
if (dht == nullptr) {
return nullptr;

View File

@ -17,7 +17,7 @@ typedef int onion_recv_1_cb(void *object, const IP_Port *dest, const uint8_t *da
typedef struct Onion {
const Logger *log;
Mono_Time *mono_time;
const Mono_Time *mono_time;
DHT *dht;
Networking_Core *net;
uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE];
@ -143,7 +143,7 @@ non_null(1) nullable(2, 3)
void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *object);
non_null()
Onion *new_onion(const Logger *log, Mono_Time *mono_time, DHT *dht);
Onion *new_onion(const Logger *log, const Mono_Time *mono_time, DHT *dht);
non_null()
void kill_onion(Onion *onion);

View File

@ -44,7 +44,7 @@ typedef struct Onion_Announce_Entry {
struct Onion_Announce {
const Logger *log;
Mono_Time *mono_time;
const Mono_Time *mono_time;
DHT *dht;
Networking_Core *net;
Onion_Announce_Entry entries[ONION_ANNOUNCE_MAX_ENTRIES];
@ -648,7 +648,7 @@ static int handle_data_request(void *object, const IP_Port *source, const uint8_
return 0;
}
Onion_Announce *new_onion_announce(const Logger *log, Mono_Time *mono_time, DHT *dht)
Onion_Announce *new_onion_announce(const Logger *log, const Mono_Time *mono_time, DHT *dht)
{
if (dht == nullptr) {
return nullptr;

View File

@ -128,7 +128,7 @@ void onion_announce_extra_data_callback(Onion_Announce *onion_a, uint16_t extra_
pack_extra_data_cb *extra_data_callback, void *extra_data_object);
non_null()
Onion_Announce *new_onion_announce(const Logger *log, Mono_Time *mono_time, DHT *dht);
Onion_Announce *new_onion_announce(const Logger *log, const Mono_Time *mono_time, DHT *dht);
non_null()
void kill_onion_announce(Onion_Announce *onion_a);

View File

@ -98,7 +98,7 @@ typedef struct Onion_Data_Handler {
} Onion_Data_Handler;
struct Onion_Client {
Mono_Time *mono_time;
const Mono_Time *mono_time;
const Logger *logger;
DHT *dht;
@ -1920,7 +1920,7 @@ void do_onion_client(Onion_Client *onion_c)
onion_c->last_run = mono_time_get(onion_c->mono_time);
}
Onion_Client *new_onion_client(const Logger *logger, Mono_Time *mono_time, Net_Crypto *c)
Onion_Client *new_onion_client(const Logger *logger, const Mono_Time *mono_time, Net_Crypto *c)
{
if (c == nullptr) {
return nullptr;

View File

@ -197,7 +197,7 @@ non_null()
void do_onion_client(Onion_Client *onion_c);
non_null()
Onion_Client *new_onion_client(const Logger *logger, Mono_Time *mono_time, Net_Crypto *c);
Onion_Client *new_onion_client(const Logger *logger, const Mono_Time *mono_time, Net_Crypto *c);
non_null()
void kill_onion_client(Onion_Client *onion_c);