mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
refactor: Compare pointers in if conditions to nullptr.
Don't use implicit ptr-to-bool conversion.
This commit is contained in:
parent
43fc2374bc
commit
933c6b7517
|
@ -10,6 +10,7 @@ ALLOWLIST: Tuple[str, ...] = (
|
|||
"stdbool.h",
|
||||
"stddef.h",
|
||||
"stdint.h",
|
||||
"time.h", # time_t used in Messenger.h TODO(iphydf): maybe don't?
|
||||
# msgpack, currently not abstracted away
|
||||
"msgpack.h",
|
||||
# toxav stuff, maybe not worth abstracting away
|
||||
|
|
|
@ -1 +1 @@
|
|||
c0dc82c8f4418f900e662076a2002363838f60eb55950a04d6cda0698b06e687 /usr/local/bin/tox-bootstrapd
|
||||
e76672b3b101846848d17ea141c541975db2b9edaad26d193073bbef4c07f310 /usr/local/bin/tox-bootstrapd
|
||||
|
|
18
other/docker/typecheck/Dockerfile
Normal file
18
other/docker/typecheck/Dockerfile
Normal file
|
@ -0,0 +1,18 @@
|
|||
FROM toxchat/haskell:hs-tokstyle AS tokstyle
|
||||
FROM ubuntu:20.04
|
||||
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||
ca-certificates \
|
||||
gcc \
|
||||
git \
|
||||
libmsgpack-dev \
|
||||
libsodium-dev \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=tokstyle /bin/check-c /bin/
|
||||
RUN ["git", "clone", "--depth=1", "https://github.com/TokTok/hs-tokstyle", "/src/workspace/hs-tokstyle"]
|
||||
|
||||
COPY toxcore/ /src/workspace/c-toxcore/toxcore/
|
||||
COPY toxencryptsave/ /src/workspace/c-toxcore/toxencryptsave/
|
||||
RUN /bin/check-c /src/workspace/c-toxcore/toxcore/*.c
|
3
other/docker/typecheck/run
Executable file
3
other/docker/typecheck/run
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
docker build -f other/docker/typecheck/Dockerfile .
|
|
@ -542,9 +542,8 @@ int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, bool
|
|||
return -1;
|
||||
}
|
||||
|
||||
*ip_port = (IP_Port) {
|
||||
0
|
||||
};
|
||||
const IP_Port empty_ip_port = {{{0}}};
|
||||
*ip_port = empty_ip_port;
|
||||
|
||||
if (is_ipv4) {
|
||||
const uint32_t size = 1 + SIZE_IP4 + sizeof(uint16_t);
|
||||
|
@ -641,7 +640,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
|
|||
assert(increment == PACKED_NODE_SIZE_IP4 || increment == PACKED_NODE_SIZE_IP6);
|
||||
}
|
||||
|
||||
if (processed_data_len) {
|
||||
if (processed_data_len != nullptr) {
|
||||
*processed_data_len = len_processed;
|
||||
}
|
||||
|
||||
|
@ -799,9 +798,8 @@ static int client_or_ip_port_in_list(const Logger *log, const Mono_Time *mono_ti
|
|||
LOGGER_DEBUG(log, "coipil[%u]: switching public_key (ipv%d)", index, ip_version);
|
||||
|
||||
/* kill the other address, if it was set */
|
||||
*assoc = (IPPTsPng) {
|
||||
0
|
||||
};
|
||||
const IPPTsPng empty_ipptspng = {{{{0}}}};
|
||||
*assoc = empty_ipptspng;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -958,12 +956,12 @@ static int dht_cmp_entry(const void *a, const void *b)
|
|||
|
||||
/** Is it ok to store node with public_key in client.
|
||||
*
|
||||
* return 0 if node can't be stored.
|
||||
* return 1 if it can.
|
||||
* return false if node can't be stored.
|
||||
* return true if it can.
|
||||
*/
|
||||
non_null()
|
||||
static unsigned int store_node_ok(const Client_data *client, uint64_t cur_time, const uint8_t *public_key,
|
||||
const uint8_t *comp_public_key)
|
||||
static bool store_node_ok(const Client_data *client, uint64_t cur_time, const uint8_t *public_key,
|
||||
const uint8_t *comp_public_key)
|
||||
{
|
||||
return (assoc_timeout(cur_time, &client->assoc4)
|
||||
&& assoc_timeout(cur_time, &client->assoc6))
|
||||
|
@ -1251,7 +1249,7 @@ uint32_t addto_lists(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key
|
|||
}
|
||||
|
||||
for (uint32_t i = 0; i < friend_foundip->lock_count; ++i) {
|
||||
if (friend_foundip->callbacks[i].ip_callback) {
|
||||
if (friend_foundip->callbacks[i].ip_callback != nullptr) {
|
||||
friend_foundip->callbacks[i].ip_callback(friend_foundip->callbacks[i].data,
|
||||
friend_foundip->callbacks[i].number, &ipp_copy);
|
||||
}
|
||||
|
@ -1567,7 +1565,7 @@ static int handle_sendnodes_ipv6(void *object, const IP_Port *source, const uint
|
|||
ping_node_from_getnodes_ok(dht, plain_nodes[i].public_key, &plain_nodes[i].ip_port);
|
||||
returnedip_ports(dht, &plain_nodes[i].ip_port, plain_nodes[i].public_key, packet + 1);
|
||||
|
||||
if (dht->get_nodes_response) {
|
||||
if (dht->get_nodes_response != nullptr) {
|
||||
dht->get_nodes_response(dht, &plain_nodes[i], userdata);
|
||||
}
|
||||
}
|
||||
|
@ -1589,7 +1587,7 @@ static void dht_friend_lock(DHT_Friend *const dht_friend, dht_ip_cb *ip_callback
|
|||
dht_friend->callbacks[lock_num].data = data;
|
||||
dht_friend->callbacks[lock_num].number = number;
|
||||
|
||||
if (lock_count) {
|
||||
if (lock_count != nullptr) {
|
||||
*lock_count = lock_num + 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ static int do_receipts(Messenger *m, int32_t friendnumber, void *userdata)
|
|||
break;
|
||||
}
|
||||
|
||||
if (m->read_receipt) {
|
||||
if (m->read_receipt != nullptr) {
|
||||
m->read_receipt(m, friendnumber, receipts->msg_id, userdata);
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ int m_delfriend(Messenger *m, int32_t friendnumber)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (m->friend_connectionstatuschange_internal) {
|
||||
if (m->friend_connectionstatuschange_internal != nullptr) {
|
||||
m->friend_connectionstatuschange_internal(m, friendnumber, 0, m->friend_connectionstatuschange_internal_userdata);
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,7 @@ int m_get_friend_connectionstatus(const Messenger *m, int32_t friendnumber)
|
|||
}
|
||||
|
||||
bool direct_connected = 0;
|
||||
unsigned int num_online_relays = 0;
|
||||
uint32_t num_online_relays = 0;
|
||||
int crypt_conn_id = friend_connection_crypt_connection_id(m->fr_c, m->friendlist[friendnumber].friendcon_id);
|
||||
|
||||
if (!crypto_connection_status(m->net_crypto, crypt_conn_id, &direct_connected, &num_online_relays)) {
|
||||
|
@ -469,7 +469,7 @@ int m_get_friend_connectionstatus(const Messenger *m, int32_t friendnumber)
|
|||
return CONNECTION_UDP;
|
||||
}
|
||||
|
||||
if (num_online_relays) {
|
||||
if (num_online_relays != 0) {
|
||||
return CONNECTION_TCP;
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,7 @@ int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, con
|
|||
|
||||
add_receipt(m, friendnumber, packet_num, msg_id);
|
||||
|
||||
if (message_id) {
|
||||
if (message_id != nullptr) {
|
||||
*message_id = msg_id;
|
||||
}
|
||||
|
||||
|
@ -959,7 +959,7 @@ static void check_friend_tcp_udp(Messenger *m, int32_t friendnumber, void *userd
|
|||
}
|
||||
|
||||
if (last_connection_udp_tcp != ret) {
|
||||
if (m->friend_connectionstatuschange) {
|
||||
if (m->friend_connectionstatuschange != nullptr) {
|
||||
m->friend_connectionstatuschange(m, friendnumber, ret, userdata);
|
||||
}
|
||||
}
|
||||
|
@ -995,7 +995,7 @@ static void check_friend_connectionstatus(Messenger *m, int32_t friendnumber, ui
|
|||
|
||||
check_friend_tcp_udp(m, friendnumber, userdata);
|
||||
|
||||
if (m->friend_connectionstatuschange_internal) {
|
||||
if (m->friend_connectionstatuschange_internal != nullptr) {
|
||||
m->friend_connectionstatuschange_internal(m, friendnumber, is_online,
|
||||
m->friend_connectionstatuschange_internal_userdata);
|
||||
}
|
||||
|
@ -1535,7 +1535,7 @@ static bool do_all_filetransfers(Messenger *m, int32_t friendnumber, void *userd
|
|||
|
||||
// If the file transfer is complete, we request a chunk of size 0.
|
||||
if (ft->status == FILESTATUS_FINISHED && friend_received_packet(m, friendnumber, ft->last_packet_number) == 0) {
|
||||
if (m->file_reqchunk) {
|
||||
if (m->file_reqchunk != nullptr) {
|
||||
m->file_reqchunk(m, friendnumber, i, ft->transferred, 0, userdata);
|
||||
}
|
||||
|
||||
|
@ -1558,7 +1558,7 @@ static bool do_all_filetransfers(Messenger *m, int32_t friendnumber, void *userd
|
|||
const uint64_t position = ft->requested;
|
||||
ft->requested += length;
|
||||
|
||||
if (m->file_reqchunk) {
|
||||
if (m->file_reqchunk != nullptr) {
|
||||
m->file_reqchunk(m, friendnumber, i, position, length, userdata);
|
||||
}
|
||||
|
||||
|
@ -1687,7 +1687,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
|
|||
}
|
||||
}
|
||||
|
||||
if (m->file_filecontrol) {
|
||||
if (m->file_filecontrol != nullptr) {
|
||||
m->file_filecontrol(m, friendnumber, real_filenumber, control_type, userdata);
|
||||
}
|
||||
|
||||
|
@ -1703,7 +1703,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
|
|||
|
||||
ft->paused |= FILE_PAUSE_OTHER;
|
||||
|
||||
if (m->file_filecontrol) {
|
||||
if (m->file_filecontrol != nullptr) {
|
||||
m->file_filecontrol(m, friendnumber, real_filenumber, control_type, userdata);
|
||||
}
|
||||
|
||||
|
@ -1711,7 +1711,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
|
|||
}
|
||||
|
||||
case FILECONTROL_KILL: {
|
||||
if (m->file_filecontrol) {
|
||||
if (m->file_filecontrol != nullptr) {
|
||||
m->file_filecontrol(m, friendnumber, real_filenumber, control_type, userdata);
|
||||
}
|
||||
|
||||
|
@ -1794,14 +1794,14 @@ static int m_handle_lossy_packet(void *object, int friend_num, const uint8_t *pa
|
|||
const RTP_Packet_Handler *const ph =
|
||||
&m->friendlist[friend_num].lossy_rtp_packethandlers[packet[0] % PACKET_ID_RANGE_LOSSY_AV_SIZE];
|
||||
|
||||
if (ph->function) {
|
||||
if (ph->function != nullptr) {
|
||||
return ph->function(m, friend_num, packet, length, ph->object);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (m->lossy_packethandler) {
|
||||
if (m->lossy_packethandler != nullptr) {
|
||||
m->lossy_packethandler(m, friend_num, packet[0], packet, length, userdata);
|
||||
}
|
||||
|
||||
|
@ -1887,7 +1887,7 @@ static int handle_custom_lossless_packet(void *object, int friend_num, const uin
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (m->lossless_packethandler) {
|
||||
if (m->lossless_packethandler != nullptr) {
|
||||
m->lossless_packethandler(m, friend_num, packet[0], packet, length, userdata);
|
||||
}
|
||||
|
||||
|
@ -2014,7 +2014,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
data_terminated[data_length] = 0;
|
||||
|
||||
/* inform of namechange before we overwrite the old name */
|
||||
if (m->friend_namechange) {
|
||||
if (m->friend_namechange != nullptr) {
|
||||
m->friend_namechange(m, i, data_terminated, data_length, userdata);
|
||||
}
|
||||
|
||||
|
@ -2034,7 +2034,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
memcpy(data_terminated, data, data_length);
|
||||
data_terminated[data_length] = 0;
|
||||
|
||||
if (m->friend_statusmessagechange) {
|
||||
if (m->friend_statusmessagechange != nullptr) {
|
||||
m->friend_statusmessagechange(m, i, data_terminated, data_length, userdata);
|
||||
}
|
||||
|
||||
|
@ -2053,7 +2053,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
break;
|
||||
}
|
||||
|
||||
if (m->friend_userstatuschange) {
|
||||
if (m->friend_userstatuschange != nullptr) {
|
||||
m->friend_userstatuschange(m, i, status, userdata);
|
||||
}
|
||||
|
||||
|
@ -2070,7 +2070,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
|
||||
set_friend_typing(m, i, typing);
|
||||
|
||||
if (m->friend_typingchange) {
|
||||
if (m->friend_typingchange != nullptr) {
|
||||
m->friend_typingchange(m, i, typing, userdata);
|
||||
}
|
||||
|
||||
|
@ -2092,7 +2092,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
message_terminated[message_length] = 0;
|
||||
uint8_t type = packet_id - PACKET_ID_MESSAGE;
|
||||
|
||||
if (m->friend_message) {
|
||||
if (m->friend_message != nullptr) {
|
||||
m->friend_message(m, i, type, message_terminated, message_length, userdata);
|
||||
}
|
||||
|
||||
|
@ -2104,7 +2104,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
break;
|
||||
}
|
||||
|
||||
if (m->conference_invite) {
|
||||
if (m->conference_invite != nullptr) {
|
||||
m->conference_invite(m, i, data, data_length, userdata);
|
||||
}
|
||||
|
||||
|
@ -2166,7 +2166,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
real_filenumber += 1;
|
||||
real_filenumber <<= 16;
|
||||
|
||||
if (m->file_sendrequest) {
|
||||
if (m->file_sendrequest != nullptr) {
|
||||
m->file_sendrequest(m, i, real_filenumber, file_type, filesize, filename, filename_length,
|
||||
userdata);
|
||||
}
|
||||
|
@ -2239,7 +2239,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
file_data_length = ft->size - ft->transferred;
|
||||
}
|
||||
|
||||
if (m->file_filedata) {
|
||||
if (m->file_filedata != nullptr) {
|
||||
m->file_filedata(m, i, real_filenumber, position, file_data, file_data_length, userdata);
|
||||
}
|
||||
|
||||
|
@ -2251,7 +2251,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
position = ft->transferred;
|
||||
|
||||
/* Full file received. */
|
||||
if (m->file_filedata) {
|
||||
if (m->file_filedata != nullptr) {
|
||||
m->file_filedata(m, i, real_filenumber, position, file_data, file_data_length, userdata);
|
||||
}
|
||||
}
|
||||
|
@ -2269,7 +2269,7 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
|||
break;
|
||||
}
|
||||
|
||||
if (m->msi_packet) {
|
||||
if (m->msi_packet != nullptr) {
|
||||
m->msi_packet(m, i, data, data_length, m->msi_packet_userdata);
|
||||
}
|
||||
|
||||
|
@ -2349,10 +2349,10 @@ static void do_friends(Messenger *m, void *userdata)
|
|||
non_null(1) nullable(2)
|
||||
static void connection_status_callback(Messenger *m, void *userdata)
|
||||
{
|
||||
unsigned int conn_status = onion_connection_status(m->onion_c);
|
||||
Onion_Connection_Status conn_status = onion_connection_status(m->onion_c);
|
||||
|
||||
if (conn_status != m->last_connection_status) {
|
||||
if (m->core_connection_change) {
|
||||
if (m->core_connection_change != nullptr) {
|
||||
m->core_connection_change(m, conn_status, userdata);
|
||||
}
|
||||
|
||||
|
@ -2414,7 +2414,7 @@ void do_messenger(Messenger *m, void *userdata)
|
|||
|
||||
m->num_loaded_relays = 0;
|
||||
|
||||
if (m->tcp_server) {
|
||||
if (m->tcp_server != nullptr) {
|
||||
/* Add self tcp server. */
|
||||
IP_Port local_ip_port;
|
||||
local_ip_port.port = m->options.tcp_server_port;
|
||||
|
@ -2429,7 +2429,7 @@ void do_messenger(Messenger *m, void *userdata)
|
|||
do_dht(m->dht);
|
||||
}
|
||||
|
||||
if (m->tcp_server) {
|
||||
if (m->tcp_server != nullptr) {
|
||||
do_TCP_server(m->tcp_server, m->mono_time);
|
||||
}
|
||||
|
||||
|
@ -2503,7 +2503,7 @@ void do_messenger(Messenger *m, void *userdata)
|
|||
const Friend *const msgfptr = dht2m[friend_idx] >= 0 ? &m->friendlist[dht2m[friend_idx]] : nullptr;
|
||||
const DHT_Friend *const dhtfptr = dht_get_friend(m->dht, friend_idx);
|
||||
|
||||
if (msgfptr) {
|
||||
if (msgfptr != nullptr) {
|
||||
char id_str[IDSTRING_LEN];
|
||||
LOGGER_TRACE(m->log, "F[%2u:%2u] <%s> %s",
|
||||
dht2m[friend_idx], friend_idx, msgfptr->name,
|
||||
|
@ -2996,7 +2996,7 @@ static uint32_t tcp_relay_size(const Messenger *m)
|
|||
non_null()
|
||||
static uint8_t *save_tcp_relays(const Messenger *m, uint8_t *data)
|
||||
{
|
||||
Node_format relays[NUM_SAVED_TCP_RELAYS] = {0};
|
||||
Node_format relays[NUM_SAVED_TCP_RELAYS] = {{{0}}};
|
||||
uint8_t *temp_data = data;
|
||||
data = state_write_section_header(temp_data, STATE_COOKIE_TYPE, 0, STATE_TYPE_TCP_RELAY);
|
||||
|
||||
|
@ -3170,7 +3170,7 @@ Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, unsig
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = MESSENGER_ERROR_OTHER;
|
||||
}
|
||||
|
||||
|
@ -3283,7 +3283,7 @@ Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, unsig
|
|||
logger_kill(m->log);
|
||||
free(m);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = MESSENGER_ERROR_TCP_SERVER;
|
||||
}
|
||||
|
||||
|
@ -3301,7 +3301,7 @@ Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, unsig
|
|||
|
||||
m_register_default_plugins(m);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = MESSENGER_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
@ -3317,7 +3317,7 @@ void kill_messenger(Messenger *m)
|
|||
return;
|
||||
}
|
||||
|
||||
if (m->tcp_server) {
|
||||
if (m->tcp_server != nullptr) {
|
||||
kill_TCP_server(m->tcp_server);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#ifndef C_TOXCORE_TOXCORE_MESSENGER_H
|
||||
#define C_TOXCORE_TOXCORE_MESSENGER_H
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "TCP_server.h"
|
||||
#include "friend_connection.h"
|
||||
#include "friend_requests.h"
|
||||
|
@ -158,7 +160,7 @@ typedef enum Filekind {
|
|||
} Filekind;
|
||||
|
||||
|
||||
typedef void m_self_connection_status_cb(Messenger *m, unsigned int connection_status, void *user_data);
|
||||
typedef void m_self_connection_status_cb(Messenger *m, Onion_Connection_Status connection_status, void *user_data);
|
||||
typedef void m_friend_status_cb(Messenger *m, uint32_t friend_number, unsigned int status, void *user_data);
|
||||
typedef void m_friend_connection_status_cb(Messenger *m, uint32_t friend_number, unsigned int connection_status,
|
||||
void *user_data);
|
||||
|
@ -291,7 +293,7 @@ struct Messenger {
|
|||
m_friend_lossless_packet_cb *lossless_packethandler;
|
||||
|
||||
m_self_connection_status_cb *core_connection_change;
|
||||
unsigned int last_connection_status;
|
||||
Onion_Connection_Status last_connection_status;
|
||||
|
||||
Messenger_Options options;
|
||||
};
|
||||
|
|
|
@ -158,7 +158,7 @@ static int proxy_http_read_connection_response(const Logger *logger, const TCP_C
|
|||
|
||||
data[sizeof(data) - 1] = 0;
|
||||
|
||||
if (strstr((const char *)data, success)) {
|
||||
if (strstr((const char *)data, success) != nullptr) {
|
||||
// drain all data
|
||||
const uint16_t data_left = net_socket_data_recv_buffer(tcp_conn->con.sock);
|
||||
|
||||
|
@ -528,7 +528,7 @@ TCP_Client_Connection *new_TCP_connection(const Logger *logger, const Mono_Time
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const TCP_Proxy_Info default_proxyinfo = {0};
|
||||
const TCP_Proxy_Info default_proxyinfo = {{{{0}}}};
|
||||
|
||||
if (proxy_info == nullptr) {
|
||||
proxy_info = &default_proxyinfo;
|
||||
|
@ -633,7 +633,7 @@ static int handle_TCP_client_packet(const Logger *logger, TCP_Client_Connection
|
|||
conn->connections[con_id].number = -1;
|
||||
memcpy(conn->connections[con_id].public_key, data + 2, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
|
||||
if (conn->response_callback) {
|
||||
if (conn->response_callback != nullptr) {
|
||||
conn->response_callback(conn->response_callback_object, con_id, conn->connections[con_id].public_key);
|
||||
}
|
||||
|
||||
|
@ -657,7 +657,7 @@ static int handle_TCP_client_packet(const Logger *logger, TCP_Client_Connection
|
|||
|
||||
conn->connections[con_id].status = 2;
|
||||
|
||||
if (conn->status_callback) {
|
||||
if (conn->status_callback != nullptr) {
|
||||
conn->status_callback(conn->status_callback_object, conn->connections[con_id].number, con_id,
|
||||
conn->connections[con_id].status);
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ static int handle_TCP_client_packet(const Logger *logger, TCP_Client_Connection
|
|||
|
||||
conn->connections[con_id].status = 1;
|
||||
|
||||
if (conn->status_callback) {
|
||||
if (conn->status_callback != nullptr) {
|
||||
conn->status_callback(conn->status_callback_object, conn->connections[con_id].number, con_id,
|
||||
conn->connections[con_id].status);
|
||||
}
|
||||
|
@ -730,7 +730,7 @@ static int handle_TCP_client_packet(const Logger *logger, TCP_Client_Connection
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (conn->oob_data_callback) {
|
||||
if (conn->oob_data_callback != nullptr) {
|
||||
conn->oob_data_callback(conn->oob_data_callback_object, data + 1, data + 1 + CRYPTO_PUBLIC_KEY_SIZE,
|
||||
length - (1 + CRYPTO_PUBLIC_KEY_SIZE), userdata);
|
||||
}
|
||||
|
@ -750,7 +750,7 @@ static int handle_TCP_client_packet(const Logger *logger, TCP_Client_Connection
|
|||
|
||||
uint8_t con_id = data[0] - NUM_RESERVED_PORTS;
|
||||
|
||||
if (conn->data_callback) {
|
||||
if (conn->data_callback != nullptr) {
|
||||
conn->data_callback(conn->data_callback_object, conn->connections[con_id].number, con_id, data + 1, length - 1,
|
||||
userdata);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ bool add_priority(TCP_Connection *con, const uint8_t *packet, uint16_t size, uin
|
|||
|
||||
memcpy(new_list->data, packet, size);
|
||||
|
||||
if (p) {
|
||||
if (p != nullptr) {
|
||||
p->next = new_list;
|
||||
} else {
|
||||
con->priority_queue_start = new_list;
|
||||
|
|
|
@ -505,7 +505,7 @@ static int find_tcp_connection_to(const TCP_Connections *tcp_c, const uint8_t *p
|
|||
for (unsigned int i = 0; i < tcp_c->connections_length; ++i) {
|
||||
const TCP_Connection_to *con_to = get_connection(tcp_c, i);
|
||||
|
||||
if (con_to) {
|
||||
if (con_to != nullptr) {
|
||||
if (public_key_cmp(con_to->public_key, public_key) == 0) {
|
||||
return i;
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ static int find_tcp_connection_relay(const TCP_Connections *tcp_c, const uint8_t
|
|||
for (uint32_t i = 0; i < tcp_c->tcp_connections_length; ++i) {
|
||||
const TCP_con *tcp_con = get_tcp_connection(tcp_c, i);
|
||||
|
||||
if (tcp_con) {
|
||||
if (tcp_con != nullptr) {
|
||||
if (tcp_con->status == TCP_CONN_SLEEPING) {
|
||||
if (public_key_cmp(tcp_con->relay_pk, relay_pk) == 0) {
|
||||
return i;
|
||||
|
@ -731,11 +731,11 @@ static int rm_tcp_connection_from_conn(TCP_Connection_to *con_to, unsigned int t
|
|||
* return -1 on failure.
|
||||
*/
|
||||
non_null()
|
||||
static unsigned int online_tcp_connection_from_conn(const TCP_Connection_to *con_to)
|
||||
static uint32_t online_tcp_connection_from_conn(const TCP_Connection_to *con_to)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
uint32_t count = 0;
|
||||
|
||||
for (unsigned int i = 0; i < MAX_FRIEND_TCP_CONNECTIONS; ++i) {
|
||||
for (uint32_t i = 0; i < MAX_FRIEND_TCP_CONNECTIONS; ++i) {
|
||||
if (con_to->connections[i].tcp_connection) {
|
||||
if (con_to->connections[i].status == TCP_CONNECTIONS_STATUS_ONLINE) {
|
||||
++count;
|
||||
|
@ -786,7 +786,7 @@ int kill_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connections_number
|
|||
for (unsigned int i = 0; i < tcp_c->connections_length; ++i) {
|
||||
TCP_Connection_to *con_to = get_connection(tcp_c, i);
|
||||
|
||||
if (con_to) {
|
||||
if (con_to != nullptr) {
|
||||
rm_tcp_connection_from_conn(con_to, tcp_connections_number);
|
||||
}
|
||||
}
|
||||
|
@ -828,7 +828,7 @@ static int reconnect_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connec
|
|||
for (unsigned int i = 0; i < tcp_c->connections_length; ++i) {
|
||||
TCP_Connection_to *con_to = get_connection(tcp_c, i);
|
||||
|
||||
if (con_to) {
|
||||
if (con_to != nullptr) {
|
||||
set_tcp_connection_status(con_to, tcp_connections_number, TCP_CONNECTIONS_STATUS_NONE, 0);
|
||||
}
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ static int sleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connection
|
|||
for (unsigned int i = 0; i < tcp_c->connections_length; ++i) {
|
||||
TCP_Connection_to *con_to = get_connection(tcp_c, i);
|
||||
|
||||
if (con_to) {
|
||||
if (con_to != nullptr) {
|
||||
set_tcp_connection_status(con_to, tcp_connections_number, TCP_CONNECTIONS_STATUS_NONE, 0);
|
||||
}
|
||||
}
|
||||
|
@ -1044,7 +1044,7 @@ static int tcp_conn_data_callback(void *object, uint32_t number, uint8_t connect
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (tcp_c->tcp_data_callback) {
|
||||
if (tcp_c->tcp_data_callback != nullptr) {
|
||||
tcp_c->tcp_data_callback(tcp_c->tcp_data_callback_object, con_to->id, data, length, userdata);
|
||||
}
|
||||
|
||||
|
@ -1078,7 +1078,7 @@ static int tcp_conn_oob_callback(void *object, const uint8_t *public_key, const
|
|||
return tcp_conn_data_callback(object, connections_number, 0, data, length, userdata);
|
||||
}
|
||||
|
||||
if (tcp_c->tcp_oob_callback) {
|
||||
if (tcp_c->tcp_oob_callback != nullptr) {
|
||||
tcp_c->tcp_oob_callback(tcp_c->tcp_oob_callback_object, public_key, tcp_connections_number, data, length, userdata);
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ static int tcp_onion_callback(void *object, const uint8_t *data, uint16_t length
|
|||
{
|
||||
TCP_Connections *tcp_c = (TCP_Connections *)object;
|
||||
|
||||
if (tcp_c->tcp_onion_callback) {
|
||||
if (tcp_c->tcp_onion_callback != nullptr) {
|
||||
tcp_c->tcp_onion_callback(tcp_c->tcp_onion_callback_object, data, length, userdata);
|
||||
}
|
||||
|
||||
|
@ -1133,15 +1133,15 @@ static int tcp_relay_on_online(TCP_Connections *tcp_c, int tcp_connections_numbe
|
|||
return -1;
|
||||
}
|
||||
|
||||
unsigned int sent = 0;
|
||||
bool sent_any = false;
|
||||
|
||||
for (unsigned int i = 0; i < tcp_c->connections_length; ++i) {
|
||||
TCP_Connection_to *con_to = get_connection(tcp_c, i);
|
||||
|
||||
if (con_to) {
|
||||
if (con_to != nullptr) {
|
||||
if (tcp_connection_in_conn(con_to, tcp_connections_number)) {
|
||||
if (send_tcp_relay_routing_request(tcp_c, tcp_connections_number, con_to->public_key) == 0) {
|
||||
++sent;
|
||||
sent_any = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1151,7 +1151,7 @@ static int tcp_relay_on_online(TCP_Connections *tcp_c, int tcp_connections_numbe
|
|||
tcp_con->status = TCP_CONN_CONNECTED;
|
||||
|
||||
/* If this connection isn't used by any connection, we don't need to wait for them to come online. */
|
||||
if (sent) {
|
||||
if (sent_any) {
|
||||
tcp_con->connected_time = mono_time_get(tcp_c->mono_time);
|
||||
} else {
|
||||
tcp_con->connected_time = 0;
|
||||
|
@ -1303,7 +1303,7 @@ int add_tcp_relay_connection(TCP_Connections *tcp_c, int connections_number, con
|
|||
/** return number of online tcp relays tied to the connection on success.
|
||||
* return 0 on failure.
|
||||
*/
|
||||
unsigned int tcp_connection_to_online_tcp_relays(const TCP_Connections *tcp_c, int connections_number)
|
||||
uint32_t tcp_connection_to_online_tcp_relays(const TCP_Connections *tcp_c, int connections_number)
|
||||
{
|
||||
const TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);
|
||||
|
||||
|
@ -1368,7 +1368,7 @@ int set_tcp_onion_status(TCP_Connections *tcp_c, bool status)
|
|||
for (uint32_t i = 0; i < tcp_c->tcp_connections_length; ++i) {
|
||||
TCP_con *tcp_con = get_tcp_connection(tcp_c, i);
|
||||
|
||||
if (tcp_con) {
|
||||
if (tcp_con != nullptr) {
|
||||
if (tcp_con->status == TCP_CONN_CONNECTED && !tcp_con->onion) {
|
||||
++tcp_c->onion_num_conns;
|
||||
tcp_con->onion = 1;
|
||||
|
@ -1386,7 +1386,7 @@ int set_tcp_onion_status(TCP_Connections *tcp_c, bool status)
|
|||
for (uint32_t i = 0; i < tcp_c->tcp_connections_length; ++i) {
|
||||
TCP_con *tcp_con = get_tcp_connection(tcp_c, i);
|
||||
|
||||
if (tcp_con) {
|
||||
if (tcp_con != nullptr) {
|
||||
if (tcp_con->status == TCP_CONN_SLEEPING) {
|
||||
tcp_con->unsleep = 1;
|
||||
}
|
||||
|
@ -1403,7 +1403,7 @@ int set_tcp_onion_status(TCP_Connections *tcp_c, bool status)
|
|||
for (uint32_t i = 0; i < tcp_c->tcp_connections_length; ++i) {
|
||||
TCP_con *tcp_con = get_tcp_connection(tcp_c, i);
|
||||
|
||||
if (tcp_con) {
|
||||
if (tcp_con != nullptr) {
|
||||
if (tcp_con->onion) {
|
||||
--tcp_c->onion_num_conns;
|
||||
tcp_con->onion = 0;
|
||||
|
|
|
@ -190,7 +190,7 @@ int set_tcp_connection_to_status(const TCP_Connections *tcp_c, int connections_n
|
|||
* return 0 on failure.
|
||||
*/
|
||||
non_null()
|
||||
unsigned int tcp_connection_to_online_tcp_relays(const TCP_Connections *tcp_c, int connections_number);
|
||||
uint32_t tcp_connection_to_online_tcp_relays(const TCP_Connections *tcp_c, int connections_number);
|
||||
|
||||
/** Add a TCP relay tied to a connection.
|
||||
*
|
||||
|
|
|
@ -341,7 +341,7 @@ static int handle_TCP_handshake(const Logger *logger, TCP_Secure_Connection *con
|
|||
return -1;
|
||||
}
|
||||
|
||||
IP_Port ipp = {0};
|
||||
IP_Port ipp = {{{0}}};
|
||||
|
||||
if (TCP_SERVER_HANDSHAKE_SIZE != net_send(logger, con->con.sock, response, TCP_SERVER_HANDSHAKE_SIZE, &ipp)) {
|
||||
crypto_memzero(shared_key, sizeof(shared_key));
|
||||
|
@ -673,7 +673,7 @@ static int handle_TCP_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
|
|||
case TCP_PACKET_ONION_REQUEST: {
|
||||
LOGGER_TRACE(tcp_server->logger, "handling onion request for %d", con_id);
|
||||
|
||||
if (tcp_server->onion) {
|
||||
if (tcp_server->onion != nullptr) {
|
||||
if (length <= 1 + CRYPTO_NONCE_SIZE + ONION_SEND_BASE * 2) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ TCP_Server *new_TCP_server(const Logger *logger, uint8_t ipv6_enabled, uint16_t
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (onion) {
|
||||
if (onion != nullptr) {
|
||||
temp->onion = onion;
|
||||
set_callback_handle_recv_1(onion, &handle_onion_recv_1, temp);
|
||||
}
|
||||
|
@ -1266,7 +1266,7 @@ void kill_TCP_server(TCP_Server *tcp_server)
|
|||
kill_sock(tcp_server->socks_listening[i]);
|
||||
}
|
||||
|
||||
if (tcp_server->onion) {
|
||||
if (tcp_server->onion != nullptr) {
|
||||
set_callback_handle_recv_1(tcp_server->onion, nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef C_TOXCORE_TOXCORE_CCOMPAT_H
|
||||
#define C_TOXCORE_TOXCORE_CCOMPAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h> // NULL, size_t
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ int getfriend_conn_id_pk(const Friend_Connections *fr_c, const uint8_t *real_pk)
|
|||
for (uint32_t i = 0; i < fr_c->num_cons; ++i) {
|
||||
const Friend_Conn *friend_con = get_conn(fr_c, i);
|
||||
|
||||
if (friend_con) {
|
||||
if (friend_con != nullptr) {
|
||||
if (public_key_cmp(friend_con->real_public_key, real_pk) == 0) {
|
||||
return i;
|
||||
}
|
||||
|
@ -412,12 +412,12 @@ static int handle_status(void *object, int number, uint8_t status, void *userdat
|
|||
}
|
||||
|
||||
if (status_changed) {
|
||||
if (fr_c->global_status_callback) {
|
||||
if (fr_c->global_status_callback != nullptr) {
|
||||
fr_c->global_status_callback(fr_c->global_status_callback_object, number, status, userdata);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < MAX_FRIEND_CONNECTION_CALLBACKS; ++i) {
|
||||
if (friend_con->callbacks[i].status_callback) {
|
||||
if (friend_con->callbacks[i].status_callback != nullptr) {
|
||||
friend_con->callbacks[i].status_callback(
|
||||
friend_con->callbacks[i].callback_object,
|
||||
friend_con->callbacks[i].callback_id, status, userdata);
|
||||
|
@ -471,7 +471,7 @@ static int handle_packet(void *object, int number, const uint8_t *data, uint16_t
|
|||
}
|
||||
|
||||
if (data[0] == PACKET_ID_FRIEND_REQUESTS) {
|
||||
if (fr_c->fr_request_callback) {
|
||||
if (fr_c->fr_request_callback != nullptr) {
|
||||
fr_c->fr_request_callback(fr_c->fr_request_object, friend_con->real_public_key, data, length, userdata);
|
||||
}
|
||||
|
||||
|
@ -499,7 +499,7 @@ static int handle_packet(void *object, int number, const uint8_t *data, uint16_t
|
|||
}
|
||||
|
||||
for (unsigned i = 0; i < MAX_FRIEND_CONNECTION_CALLBACKS; ++i) {
|
||||
if (friend_con->callbacks[i].data_callback) {
|
||||
if (friend_con->callbacks[i].data_callback != nullptr) {
|
||||
friend_con->callbacks[i].data_callback(
|
||||
friend_con->callbacks[i].callback_object,
|
||||
friend_con->callbacks[i].callback_id, data, length, userdata);
|
||||
|
@ -530,7 +530,7 @@ static int handle_lossy_packet(void *object, int number, const uint8_t *data, ui
|
|||
}
|
||||
|
||||
for (unsigned i = 0; i < MAX_FRIEND_CONNECTION_CALLBACKS; ++i) {
|
||||
if (friend_con->callbacks[i].lossy_data_callback) {
|
||||
if (friend_con->callbacks[i].lossy_data_callback != nullptr) {
|
||||
friend_con->callbacks[i].lossy_data_callback(
|
||||
friend_con->callbacks[i].callback_object,
|
||||
friend_con->callbacks[i].callback_id, data, length, userdata);
|
||||
|
@ -684,11 +684,11 @@ int get_friendcon_public_keys(uint8_t *real_pk, uint8_t *dht_temp_pk, const Frie
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (real_pk) {
|
||||
if (real_pk != nullptr) {
|
||||
memcpy(real_pk, friend_con->real_public_key, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
}
|
||||
|
||||
if (dht_temp_pk) {
|
||||
if (dht_temp_pk != nullptr) {
|
||||
memcpy(dht_temp_pk, friend_con->dht_temp_pk, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
}
|
||||
|
||||
|
@ -953,7 +953,7 @@ void do_friend_connections(Friend_Connections *fr_c, void *userdata)
|
|||
for (uint32_t i = 0; i < fr_c->num_cons; ++i) {
|
||||
Friend_Conn *const friend_con = get_conn(fr_c, i);
|
||||
|
||||
if (friend_con) {
|
||||
if (friend_con != nullptr) {
|
||||
if (friend_con->status == FRIENDCONN_STATUS_CONNECTING) {
|
||||
if (friend_con->dht_pk_lastrecv + FRIEND_DHT_TIMEOUT < temp_time) {
|
||||
if (friend_con->dht_lock) {
|
||||
|
|
|
@ -137,7 +137,7 @@ static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, co
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (fr->filter_function) {
|
||||
if (fr->filter_function != nullptr) {
|
||||
if (fr->filter_function(source_pubkey, fr->filter_function_userdata) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -568,11 +568,11 @@ static int note_peer_active(Group_Chats *g_c, uint32_t groupnumber, uint16_t pee
|
|||
|
||||
delete_frozen(g, frozen_index);
|
||||
|
||||
if (g_c->peer_list_changed_callback) {
|
||||
if (g_c->peer_list_changed_callback != nullptr) {
|
||||
g_c->peer_list_changed_callback(g_c->m, groupnumber, userdata);
|
||||
}
|
||||
|
||||
if (g->peer_on_join) {
|
||||
if (g->peer_on_join != nullptr) {
|
||||
g->peer_on_join(g->object, groupnumber, thawed_index);
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ static int addpeer(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_p
|
|||
g_c->peer_list_changed_callback(g_c->m, groupnumber, userdata);
|
||||
}
|
||||
|
||||
if (g->peer_on_join) {
|
||||
if (g->peer_on_join != nullptr) {
|
||||
g->peer_on_join(g->object, groupnumber, new_index);
|
||||
}
|
||||
|
||||
|
@ -768,11 +768,11 @@ static bool delpeer(Group_Chats *g_c, uint32_t groupnumber, int peer_index, void
|
|||
g->group = temp;
|
||||
}
|
||||
|
||||
if (g_c->peer_list_changed_callback) {
|
||||
if (g_c->peer_list_changed_callback != nullptr) {
|
||||
g_c->peer_list_changed_callback(g_c->m, groupnumber, userdata);
|
||||
}
|
||||
|
||||
if (g->peer_on_leave) {
|
||||
if (g->peer_on_leave != nullptr) {
|
||||
g->peer_on_leave(g->object, groupnumber, peer_object);
|
||||
}
|
||||
|
||||
|
@ -938,7 +938,7 @@ static bool settitle(Group_Chats *g_c, uint32_t groupnumber, int peer_index, con
|
|||
|
||||
g->title_fresh = true;
|
||||
|
||||
if (g_c->title_callback) {
|
||||
if (g_c->title_callback != nullptr) {
|
||||
g_c->title_callback(g_c->m, groupnumber, peer_index, title, title_len, userdata);
|
||||
}
|
||||
|
||||
|
@ -1203,7 +1203,7 @@ int del_groupchat(Group_Chats *g_c, uint32_t groupnumber, bool leave_permanently
|
|||
}
|
||||
|
||||
for (uint32_t i = 0; i < g->numpeers; ++i) {
|
||||
if (g->peer_on_leave) {
|
||||
if (g->peer_on_leave != nullptr) {
|
||||
g->peer_on_leave(g->object, groupnumber, g->group[i].object);
|
||||
}
|
||||
}
|
||||
|
@ -1211,7 +1211,7 @@ int del_groupchat(Group_Chats *g_c, uint32_t groupnumber, bool leave_permanently
|
|||
free(g->group);
|
||||
free(g->frozen);
|
||||
|
||||
if (g->group_on_delete) {
|
||||
if (g->group_on_delete != nullptr) {
|
||||
g->group_on_delete(g->object, groupnumber);
|
||||
}
|
||||
|
||||
|
@ -1428,12 +1428,12 @@ bool conference_get_id(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *id
|
|||
|
||||
/** Send a group packet to friendcon_id.
|
||||
*
|
||||
* return 1 on success
|
||||
* return 0 on failure
|
||||
* return true on success
|
||||
* return false on failure
|
||||
*/
|
||||
non_null()
|
||||
static unsigned int send_packet_group_peer(const Friend_Connections *fr_c, int friendcon_id, uint8_t packet_id,
|
||||
uint16_t group_num, const uint8_t *data, uint16_t length)
|
||||
static bool send_packet_group_peer(const Friend_Connections *fr_c, int friendcon_id, uint8_t packet_id,
|
||||
uint16_t group_num, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (1 + sizeof(uint16_t) + length > MAX_CRYPTO_DATA_SIZE) {
|
||||
return 0;
|
||||
|
@ -1450,12 +1450,12 @@ static unsigned int send_packet_group_peer(const Friend_Connections *fr_c, int f
|
|||
|
||||
/** Send a group lossy packet to friendcon_id.
|
||||
*
|
||||
* return 1 on success
|
||||
* return 0 on failure
|
||||
* return true on success
|
||||
* return false on failure
|
||||
*/
|
||||
non_null()
|
||||
static unsigned int send_lossy_group_peer(const Friend_Connections *fr_c, int friendcon_id, uint8_t packet_id,
|
||||
uint16_t group_num, const uint8_t *data, uint16_t length)
|
||||
static bool send_lossy_group_peer(const Friend_Connections *fr_c, int friendcon_id, uint8_t packet_id,
|
||||
uint16_t group_num, const uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (1 + sizeof(uint16_t) + length > MAX_CRYPTO_DATA_SIZE) {
|
||||
return 0;
|
||||
|
@ -1973,7 +1973,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
|
|||
const int groupnumber = get_group_num(g_c, data[1 + sizeof(uint16_t)], data + 1 + sizeof(uint16_t) + 1);
|
||||
|
||||
if (groupnumber == -1) {
|
||||
if (g_c->invite_callback) {
|
||||
if (g_c->invite_callback != nullptr) {
|
||||
g_c->invite_callback(m, friendnumber, invite_data[sizeof(uint16_t)], invite_data, invite_length, userdata);
|
||||
}
|
||||
|
||||
|
@ -2329,7 +2329,7 @@ static int handle_send_peers(Group_Chats *g_c, uint32_t groupnumber, const uint8
|
|||
g->peer_number = peer_num;
|
||||
g->status = GROUPCHAT_STATUS_CONNECTED;
|
||||
|
||||
if (g_c->connected_callback) {
|
||||
if (g_c->connected_callback != nullptr) {
|
||||
g_c->connected_callback(g_c->m, groupnumber, userdata);
|
||||
}
|
||||
|
||||
|
@ -2812,7 +2812,7 @@ static void handle_message_packet_group(Group_Chats *g_c, uint32_t groupnumber,
|
|||
newmsg[msg_data_len] = 0;
|
||||
|
||||
// TODO(irungentoo):
|
||||
if (g_c->message_callback) {
|
||||
if (g_c->message_callback != nullptr) {
|
||||
g_c->message_callback(g_c->m, groupnumber, index, 0, newmsg, msg_data_len, userdata);
|
||||
}
|
||||
|
||||
|
@ -2829,7 +2829,7 @@ static void handle_message_packet_group(Group_Chats *g_c, uint32_t groupnumber,
|
|||
newmsg[msg_data_len] = 0;
|
||||
|
||||
// TODO(irungentoo):
|
||||
if (g_c->message_callback) {
|
||||
if (g_c->message_callback != nullptr) {
|
||||
g_c->message_callback(g_c->m, groupnumber, index, 1, newmsg, msg_data_len, userdata);
|
||||
}
|
||||
|
||||
|
|
|
@ -620,7 +620,7 @@ static int add_ip_port_connection(Net_Crypto *c, int crypt_connection_id, const
|
|||
non_null()
|
||||
static IP_Port return_ip_port_connection(const Net_Crypto *c, int crypt_connection_id)
|
||||
{
|
||||
const IP_Port empty = {0};
|
||||
const IP_Port empty = {{{0}}};
|
||||
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
|
@ -766,7 +766,7 @@ static int add_data_to_buffer(Packets_Array *array, uint32_t number, const Packe
|
|||
|
||||
uint32_t num = number % CRYPTO_PACKET_BUFFER_SIZE;
|
||||
|
||||
if (array->buffer[num]) {
|
||||
if (array->buffer[num] != nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -885,7 +885,7 @@ static int clear_buffer_until(Packets_Array *array, uint32_t number)
|
|||
for (i = array->buffer_start; i != number; ++i) {
|
||||
uint32_t num = i % CRYPTO_PACKET_BUFFER_SIZE;
|
||||
|
||||
if (array->buffer[num]) {
|
||||
if (array->buffer[num] != nullptr) {
|
||||
free(array->buffer[num]);
|
||||
array->buffer[num] = nullptr;
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ static int clear_buffer(Packets_Array *array)
|
|||
for (i = array->buffer_start; i != array->buffer_end; ++i) {
|
||||
uint32_t num = i % CRYPTO_PACKET_BUFFER_SIZE;
|
||||
|
||||
if (array->buffer[num]) {
|
||||
if (array->buffer[num] != nullptr) {
|
||||
free(array->buffer[num]);
|
||||
array->buffer[num] = nullptr;
|
||||
}
|
||||
|
@ -1027,7 +1027,7 @@ static int handle_request_packet(Mono_Time *mono_time, Packets_Array *send_array
|
|||
uint32_t num = i % CRYPTO_PACKET_BUFFER_SIZE;
|
||||
|
||||
if (n == data[0]) {
|
||||
if (send_array->buffer[num]) {
|
||||
if (send_array->buffer[num] != nullptr) {
|
||||
uint64_t sent_time = send_array->buffer[num]->sent_time;
|
||||
|
||||
if ((sent_time + rtt_time) < temp_time) {
|
||||
|
@ -1040,7 +1040,7 @@ static int handle_request_packet(Mono_Time *mono_time, Packets_Array *send_array
|
|||
n = 0;
|
||||
++requested;
|
||||
} else {
|
||||
if (send_array->buffer[num]) {
|
||||
if (send_array->buffer[num] != nullptr) {
|
||||
l_sent_time = max_u64(l_sent_time, send_array->buffer[num]->sent_time);
|
||||
|
||||
free(send_array->buffer[num]);
|
||||
|
@ -1387,7 +1387,7 @@ static int new_temp_packet(const Net_Crypto *c, int crypt_connection_id, const u
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (conn->temp_packet) {
|
||||
if (conn->temp_packet != nullptr) {
|
||||
free(conn->temp_packet);
|
||||
}
|
||||
|
||||
|
@ -1413,7 +1413,7 @@ static int clear_temp_packet(const Net_Crypto *c, int crypt_connection_id)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (conn->temp_packet) {
|
||||
if (conn->temp_packet != nullptr) {
|
||||
free(conn->temp_packet);
|
||||
}
|
||||
|
||||
|
@ -1511,7 +1511,7 @@ static void connection_kill(Net_Crypto *c, int crypt_connection_id, void *userda
|
|||
return;
|
||||
}
|
||||
|
||||
if (conn->connection_status_callback) {
|
||||
if (conn->connection_status_callback != nullptr) {
|
||||
conn->connection_status_callback(conn->connection_status_callback_object, conn->connection_status_callback_id, 0,
|
||||
userdata);
|
||||
}
|
||||
|
@ -1598,7 +1598,7 @@ static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const
|
|||
clear_temp_packet(c, crypt_connection_id);
|
||||
conn->status = CRYPTO_CONN_ESTABLISHED;
|
||||
|
||||
if (conn->connection_status_callback) {
|
||||
if (conn->connection_status_callback != nullptr) {
|
||||
conn->connection_status_callback(conn->connection_status_callback_object, conn->connection_status_callback_id, 1,
|
||||
userdata);
|
||||
}
|
||||
|
@ -1640,7 +1640,7 @@ static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const
|
|||
break;
|
||||
}
|
||||
|
||||
if (conn->connection_data_callback) {
|
||||
if (conn->connection_data_callback != nullptr) {
|
||||
conn->connection_data_callback(conn->connection_data_callback_object, conn->connection_data_callback_id, dt.data,
|
||||
dt.length, userdata);
|
||||
}
|
||||
|
@ -1659,7 +1659,7 @@ static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const
|
|||
|
||||
set_buffer_end(&conn->recv_array, num);
|
||||
|
||||
if (conn->connection_lossy_data_callback) {
|
||||
if (conn->connection_lossy_data_callback != nullptr) {
|
||||
conn->connection_lossy_data_callback(conn->connection_lossy_data_callback_object,
|
||||
conn->connection_lossy_data_callback_id, real_data, real_length, userdata);
|
||||
}
|
||||
|
@ -1746,7 +1746,7 @@ static int handle_packet_crypto_hs(Net_Crypto *c, int crypt_connection_id, const
|
|||
|
||||
conn->status = CRYPTO_CONN_NOT_CONFIRMED;
|
||||
} else {
|
||||
if (conn->dht_pk_callback) {
|
||||
if (conn->dht_pk_callback != nullptr) {
|
||||
conn->dht_pk_callback(conn->dht_pk_callback_object, conn->dht_pk_callback_number, dht_public_key, userdata);
|
||||
}
|
||||
}
|
||||
|
@ -2953,7 +2953,7 @@ int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t
|
|||
|
||||
int ret = -1;
|
||||
|
||||
if (conn) {
|
||||
if (conn != nullptr) {
|
||||
pthread_mutex_lock(conn->mutex);
|
||||
uint32_t buffer_start = conn->recv_array.buffer_start;
|
||||
uint32_t buffer_end = conn->send_array.buffer_end;
|
||||
|
@ -2979,7 +2979,7 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id)
|
|||
|
||||
int ret = -1;
|
||||
|
||||
if (conn) {
|
||||
if (conn != nullptr) {
|
||||
if (conn->status == CRYPTO_CONN_ESTABLISHED) {
|
||||
send_kill_packet(c, crypt_connection_id);
|
||||
}
|
||||
|
@ -3000,7 +3000,7 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id)
|
|||
}
|
||||
|
||||
bool crypto_connection_status(const Net_Crypto *c, int crypt_connection_id, bool *direct_connected,
|
||||
unsigned int *online_tcp_relays)
|
||||
uint32_t *online_tcp_relays)
|
||||
{
|
||||
const Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
|
||||
|
||||
|
@ -3008,7 +3008,7 @@ bool crypto_connection_status(const Net_Crypto *c, int crypt_connection_id, bool
|
|||
return false;
|
||||
}
|
||||
|
||||
if (direct_connected) {
|
||||
if (direct_connected != nullptr) {
|
||||
*direct_connected = 0;
|
||||
|
||||
const uint64_t current_time = mono_time_get(c->mono_time);
|
||||
|
@ -3020,7 +3020,7 @@ bool crypto_connection_status(const Net_Crypto *c, int crypt_connection_id, bool
|
|||
}
|
||||
}
|
||||
|
||||
if (online_tcp_relays) {
|
||||
if (online_tcp_relays != nullptr) {
|
||||
*online_tcp_relays = tcp_connection_to_online_tcp_relays(c->tcp_c, conn->connection_number_tcp);
|
||||
}
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id);
|
|||
*/
|
||||
non_null(1, 3) nullable(4)
|
||||
bool crypto_connection_status(
|
||||
const Net_Crypto *c, int crypt_connection_id, bool *direct_connected, unsigned int *online_tcp_relays);
|
||||
const Net_Crypto *c, int crypt_connection_id, bool *direct_connected, uint32_t *online_tcp_relays);
|
||||
|
||||
/** Generate our public and private keys.
|
||||
* Only call this function the first time the program starts.
|
||||
|
|
|
@ -835,7 +835,7 @@ Networking_Core *new_networking_ex(const Logger *log, const IP *ip, uint16_t por
|
|||
port_to = temp;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = 2;
|
||||
}
|
||||
|
||||
|
@ -871,7 +871,7 @@ Networking_Core *new_networking_ex(const Logger *log, const IP *ip, uint16_t por
|
|||
net_kill_strerror(strerror);
|
||||
free(temp);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = 1;
|
||||
}
|
||||
|
||||
|
@ -907,7 +907,7 @@ Networking_Core *new_networking_ex(const Logger *log, const IP *ip, uint16_t por
|
|||
if (!set_socket_nosigpipe(temp->sock)) {
|
||||
kill_networking(temp);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = 1;
|
||||
}
|
||||
|
||||
|
@ -918,7 +918,7 @@ Networking_Core *new_networking_ex(const Logger *log, const IP *ip, uint16_t por
|
|||
if (!set_socket_nonblock(temp->sock)) {
|
||||
kill_networking(temp);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = 1;
|
||||
}
|
||||
|
||||
|
@ -1028,7 +1028,7 @@ Networking_Core *new_networking_ex(const Logger *log, const IP *ip, uint16_t por
|
|||
errno = 0;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = 0;
|
||||
}
|
||||
|
||||
|
@ -1052,7 +1052,7 @@ Networking_Core *new_networking_ex(const Logger *log, const IP *ip, uint16_t por
|
|||
net_kill_strerror(strerror);
|
||||
kill_networking(temp);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = 1;
|
||||
}
|
||||
|
||||
|
@ -1238,7 +1238,7 @@ const char *ip_ntoa(const IP *ip, char *ip_str, size_t length)
|
|||
return ip_str;
|
||||
}
|
||||
|
||||
if (ip) {
|
||||
if (ip != nullptr) {
|
||||
if (net_family_is_ipv4(ip->family)) {
|
||||
/* returns standard quad-dotted notation */
|
||||
struct in_addr addr;
|
||||
|
@ -1462,7 +1462,7 @@ int32_t net_getipport(const char *node, IP_Port **res, int tox_type)
|
|||
return 1;
|
||||
#else
|
||||
// Try parsing as IP address first.
|
||||
IP_Port parsed = {0};
|
||||
IP_Port parsed = {{{0}}};
|
||||
|
||||
if (addr_parse_ip(node, &parsed.ip)) {
|
||||
IP_Port *tmp = (IP_Port *)calloc(1, sizeof(IP_Port));
|
||||
|
|
|
@ -985,7 +985,7 @@ static int handle_dhtpk_announce(void *object, const uint8_t *source_pubkey, con
|
|||
|
||||
onion_c->friends_list[friend_num].last_noreplay = no_replay;
|
||||
|
||||
if (onion_c->friends_list[friend_num].dht_pk_callback) {
|
||||
if (onion_c->friends_list[friend_num].dht_pk_callback != nullptr) {
|
||||
onion_c->friends_list[friend_num].dht_pk_callback(onion_c->friends_list[friend_num].dht_pk_callback_object,
|
||||
onion_c->friends_list[friend_num].dht_pk_callback_number, data + 1 + sizeof(uint64_t), userdata);
|
||||
}
|
||||
|
@ -1010,7 +1010,7 @@ static int handle_dhtpk_announce(void *object, const uint8_t *source_pubkey, con
|
|||
if (net_family_is_ipv4(family) || net_family_is_ipv6(family)) {
|
||||
dht_getnodes(onion_c->dht, &nodes[i].ip_port, nodes[i].public_key, onion_c->friends_list[friend_num].dht_public_key);
|
||||
} else if (net_family_is_tcp_ipv4(family) || net_family_is_tcp_ipv6(family)) {
|
||||
if (onion_c->friends_list[friend_num].tcp_relay_node_callback) {
|
||||
if (onion_c->friends_list[friend_num].tcp_relay_node_callback != nullptr) {
|
||||
void *obj = onion_c->friends_list[friend_num].tcp_relay_node_callback_object;
|
||||
uint32_t number = onion_c->friends_list[friend_num].tcp_relay_node_callback_number;
|
||||
onion_c->friends_list[friend_num].tcp_relay_node_callback(obj, number, &nodes[i].ip_port, nodes[i].public_key);
|
||||
|
@ -1029,7 +1029,7 @@ static int handle_tcp_onion(void *object, const uint8_t *data, uint16_t length,
|
|||
return 1;
|
||||
}
|
||||
|
||||
IP_Port ip_port = {0};
|
||||
IP_Port ip_port = {{{0}}};
|
||||
ip_port.ip.family = net_family_tcp_family;
|
||||
|
||||
if (data[0] == NET_PACKET_ANNOUNCE_RESPONSE) {
|
||||
|
@ -1816,21 +1816,17 @@ static int onion_isconnected(const Onion_Client *onion_c)
|
|||
|
||||
#define ONION_CONNECTION_SECONDS 3
|
||||
|
||||
/** return 0 if we are not connected to the network.
|
||||
* return 1 if we are connected with TCP only.
|
||||
* return 2 if we are also connected with UDP.
|
||||
*/
|
||||
unsigned int onion_connection_status(const Onion_Client *onion_c)
|
||||
Onion_Connection_Status onion_connection_status(const Onion_Client *onion_c)
|
||||
{
|
||||
if (onion_c->onion_connected >= ONION_CONNECTION_SECONDS) {
|
||||
if (onion_c->udp_connected) {
|
||||
return 2;
|
||||
return ONION_CONNECTION_STATUS_UDP;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return ONION_CONNECTION_STATUS_TCP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ONION_CONNECTION_STATUS_NONE;
|
||||
}
|
||||
|
||||
void do_onion_client(Onion_Client *onion_c)
|
||||
|
@ -1862,7 +1858,7 @@ void do_onion_client(Onion_Client *onion_c)
|
|||
set_tcp_onion_status(nc_get_tcp_c(onion_c->c), !onion_c->udp_connected);
|
||||
}
|
||||
|
||||
if (onion_connection_status(onion_c)) {
|
||||
if (onion_connection_status(onion_c) != ONION_CONNECTION_STATUS_NONE) {
|
||||
for (unsigned i = 0; i < onion_c->num_friends; ++i) {
|
||||
do_friend(onion_c, i);
|
||||
}
|
||||
|
|
|
@ -194,11 +194,16 @@ non_null()
|
|||
void kill_onion_client(Onion_Client *onion_c);
|
||||
|
||||
|
||||
/** return 0 if we are not connected to the network.
|
||||
* return 1 if we are connected with TCP only.
|
||||
* return 2 if we are also connected with UDP.
|
||||
*/
|
||||
typedef enum Onion_Connection_Status {
|
||||
/** We are not connected to the network. */
|
||||
ONION_CONNECTION_STATUS_NONE = 0,
|
||||
/** We are connected with TCP only. */
|
||||
ONION_CONNECTION_STATUS_TCP = 1,
|
||||
/** We are also connected with UDP. */
|
||||
ONION_CONNECTION_STATUS_UDP = 2,
|
||||
} Onion_Connection_Status;
|
||||
|
||||
non_null()
|
||||
unsigned int onion_connection_status(const Onion_Client *onion_c);
|
||||
Onion_Connection_Status onion_connection_status(const Onion_Client *onion_c);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#define SET_ERROR_PARAMETER(param, x) \
|
||||
do { \
|
||||
if (param) { \
|
||||
if (param != nullptr) { \
|
||||
*param = x; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -108,7 +108,7 @@ struct Tox_Userdata {
|
|||
};
|
||||
|
||||
non_null(1) nullable(3)
|
||||
static void tox_self_connection_status_handler(Messenger *m, unsigned int connection_status, void *user_data)
|
||||
static void tox_self_connection_status_handler(Messenger *m, Onion_Connection_Status connection_status, void *user_data)
|
||||
{
|
||||
struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data;
|
||||
|
||||
|
@ -751,6 +751,7 @@ bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t *pub
|
|||
}
|
||||
|
||||
lock(tox);
|
||||
assert(count >= 0);
|
||||
|
||||
for (int32_t i = 0; i < count; ++i) {
|
||||
root[i].port = net_htons(port);
|
||||
|
@ -766,7 +767,7 @@ bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t *pub
|
|||
|
||||
net_freeipport(root);
|
||||
|
||||
if (count) {
|
||||
if (count > 0) {
|
||||
SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_OK);
|
||||
return 1;
|
||||
}
|
||||
|
@ -802,6 +803,7 @@ bool tox_add_tcp_relay(Tox *tox, const char *host, uint16_t port, const uint8_t
|
|||
}
|
||||
|
||||
lock(tox);
|
||||
assert(count >= 0);
|
||||
|
||||
for (int32_t i = 0; i < count; ++i) {
|
||||
root[i].port = net_htons(port);
|
||||
|
@ -813,7 +815,7 @@ bool tox_add_tcp_relay(Tox *tox, const char *host, uint16_t port, const uint8_t
|
|||
|
||||
net_freeipport(root);
|
||||
|
||||
if (count) {
|
||||
if (count > 0) {
|
||||
SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_OK);
|
||||
return 1;
|
||||
}
|
||||
|
@ -879,7 +881,7 @@ void tox_self_get_address(const Tox *tox, uint8_t *address)
|
|||
{
|
||||
assert(tox != nullptr);
|
||||
|
||||
if (address) {
|
||||
if (address != nullptr) {
|
||||
lock(tox);
|
||||
getaddress(tox->m, address);
|
||||
unlock(tox);
|
||||
|
@ -907,7 +909,7 @@ void tox_self_get_public_key(const Tox *tox, uint8_t *public_key)
|
|||
{
|
||||
assert(tox != nullptr);
|
||||
|
||||
if (public_key) {
|
||||
if (public_key != nullptr) {
|
||||
lock(tox);
|
||||
memcpy(public_key, nc_get_self_public_key(tox->m->net_crypto), CRYPTO_PUBLIC_KEY_SIZE);
|
||||
unlock(tox);
|
||||
|
@ -918,7 +920,7 @@ void tox_self_get_secret_key(const Tox *tox, uint8_t *secret_key)
|
|||
{
|
||||
assert(tox != nullptr);
|
||||
|
||||
if (secret_key) {
|
||||
if (secret_key != nullptr) {
|
||||
lock(tox);
|
||||
memcpy(secret_key, nc_get_self_secret_key(tox->m->net_crypto), CRYPTO_SECRET_KEY_SIZE);
|
||||
unlock(tox);
|
||||
|
@ -962,7 +964,7 @@ void tox_self_get_name(const Tox *tox, uint8_t *name)
|
|||
{
|
||||
assert(tox != nullptr);
|
||||
|
||||
if (name) {
|
||||
if (name != nullptr) {
|
||||
lock(tox);
|
||||
getself_name(tox->m, name);
|
||||
unlock(tox);
|
||||
|
@ -1004,7 +1006,7 @@ void tox_self_get_status_message(const Tox *tox, uint8_t *status_message)
|
|||
{
|
||||
assert(tox != nullptr);
|
||||
|
||||
if (status_message) {
|
||||
if (status_message != nullptr) {
|
||||
lock(tox);
|
||||
m_copy_self_statusmessage(tox->m, status_message);
|
||||
unlock(tox);
|
||||
|
@ -1221,7 +1223,7 @@ void tox_self_get_friend_list(const Tox *tox, uint32_t *friend_list)
|
|||
{
|
||||
assert(tox != nullptr);
|
||||
|
||||
if (friend_list) {
|
||||
if (friend_list != nullptr) {
|
||||
lock(tox);
|
||||
// TODO(irungentoo): size parameter?
|
||||
copy_friendlist(tox->m, friend_list, count_friendlist(tox->m));
|
||||
|
@ -2525,7 +2527,7 @@ void tox_self_get_dht_id(const Tox *tox, uint8_t *dht_id)
|
|||
{
|
||||
assert(tox != nullptr);
|
||||
|
||||
if (dht_id) {
|
||||
if (dht_id != nullptr) {
|
||||
lock(tox);
|
||||
memcpy(dht_id, dht_get_self_public_key(tox->m->dht), CRYPTO_PUBLIC_KEY_SIZE);
|
||||
unlock(tox);
|
||||
|
@ -2570,7 +2572,7 @@ uint16_t tox_self_get_tcp_port(const Tox *tox, Tox_Err_Get_Port *error)
|
|||
assert(tox != nullptr);
|
||||
lock(tox);
|
||||
|
||||
if (tox->m->tcp_server) {
|
||||
if (tox->m->tcp_server != nullptr) {
|
||||
SET_ERROR_PARAMETER(error, TOX_ERR_GET_PORT_OK);
|
||||
uint16_t ret = tox->m->options.tcp_server_port;
|
||||
unlock(tox);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#define SET_ERROR_PARAMETER(param, x) \
|
||||
do { \
|
||||
if (param) { \
|
||||
if (param != nullptr) { \
|
||||
*param = x; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -87,7 +87,7 @@ void tox_options_set_savedata_data(struct Tox_Options *options, const uint8_t *d
|
|||
|
||||
void tox_options_default(struct Tox_Options *options)
|
||||
{
|
||||
if (options) {
|
||||
if (options != nullptr) {
|
||||
struct Tox_Options default_options = { 0 };
|
||||
*options = default_options;
|
||||
tox_options_set_ipv6_enabled(options, true);
|
||||
|
@ -103,7 +103,7 @@ struct Tox_Options *tox_options_new(Tox_Err_Options_New *error)
|
|||
{
|
||||
struct Tox_Options *options = (struct Tox_Options *)calloc(1, sizeof(struct Tox_Options));
|
||||
|
||||
if (options) {
|
||||
if (options != nullptr) {
|
||||
tox_options_default(options);
|
||||
SET_ERROR_PARAMETER(error, TOX_ERR_OPTIONS_NEW_OK);
|
||||
return options;
|
||||
|
|
|
@ -27,7 +27,7 @@ static_assert(TOX_PASS_ENCRYPTION_EXTRA_LENGTH == (crypto_box_MACBYTES + crypto_
|
|||
|
||||
#define SET_ERROR_PARAMETER(param, x) \
|
||||
do { \
|
||||
if (param) { \
|
||||
if (param != nullptr) { \
|
||||
*param = x; \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user