cleanup: Avoid implicit bool conversions in logical operators.

This commit is contained in:
iphydf 2022-02-18 02:05:44 +00:00
parent cc045d6343
commit 87c38ece30
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
22 changed files with 216 additions and 216 deletions

View File

@ -31,7 +31,7 @@ ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
{
ACSession *ac = (ACSession *)calloc(1, sizeof(ACSession));
if (!ac) {
if (ac == nullptr) {
LOGGER_WARNING(log, "Allocation failed! Application might misbehave!");
return nullptr;
}
@ -100,7 +100,7 @@ BASE_CLEANUP:
void ac_kill(ACSession *ac)
{
if (!ac) {
if (ac == nullptr) {
return;
}
@ -116,7 +116,7 @@ void ac_kill(ACSession *ac)
void ac_iterate(ACSession *ac)
{
if (!ac) {
if (ac == nullptr) {
return;
}
@ -275,13 +275,13 @@ static struct JitterBuffer *jbuf_new(uint32_t capacity)
struct JitterBuffer *q = (struct JitterBuffer *)calloc(1, sizeof(struct JitterBuffer));
if (!q) {
if (q == nullptr) {
return nullptr;
}
q->queue = (struct RTPMessage **)calloc(size, sizeof(struct RTPMessage *));
if (!q->queue) {
if (q->queue == nullptr) {
free(q);
return nullptr;
}
@ -300,7 +300,7 @@ static void jbuf_clear(struct JitterBuffer *q)
}
static void jbuf_free(struct JitterBuffer *q)
{
if (!q) {
if (q == nullptr) {
return;
}

View File

@ -94,7 +94,7 @@ BWController *bwc_new(Messenger *m, Tox *tox, uint32_t friendnumber, m_cb *mcb,
void bwc_kill(BWController *bwc)
{
if (!bwc) {
if (bwc == nullptr) {
return;
}
@ -105,7 +105,7 @@ void bwc_kill(BWController *bwc)
void bwc_add_lost(BWController *bwc, uint32_t bytes_lost)
{
if (!bwc) {
if (bwc == nullptr) {
return;
}

View File

@ -49,13 +49,13 @@ static Group_JitterBuffer *create_queue(unsigned int capacity)
Group_JitterBuffer *q = (Group_JitterBuffer *)calloc(1, sizeof(Group_JitterBuffer));
if (!q) {
if (q == nullptr) {
return nullptr;
}
q->queue = (Group_Audio_Packet **)calloc(size, sizeof(Group_Audio_Packet *));
if (!q->queue) {
if (q->queue == nullptr) {
free(q);
return nullptr;
}
@ -77,7 +77,7 @@ static void clear_queue(Group_JitterBuffer *q)
static void terminate_queue(Group_JitterBuffer *q)
{
if (!q) {
if (q == nullptr) {
return;
}
@ -227,13 +227,13 @@ static int recreate_encoder(Group_AV *group_av)
static Group_AV *new_group_av(const Logger *log, Tox *tox, Group_Chats *g_c, audio_data_cb *audio_callback,
void *userdata)
{
if (!g_c) {
if (g_c == nullptr) {
return nullptr;
}
Group_AV *group_av = (Group_AV *)calloc(1, sizeof(Group_AV));
if (!group_av) {
if (group_av == nullptr) {
return nullptr;
}
@ -252,7 +252,7 @@ static void group_av_peer_new(void *object, uint32_t groupnumber, uint32_t frien
const Group_AV *group_av = (const Group_AV *)object;
Group_Peer_AV *peer_av = (Group_Peer_AV *)calloc(1, sizeof(Group_Peer_AV));
if (!peer_av) {
if (peer_av == nullptr) {
return;
}
@ -268,7 +268,7 @@ static void group_av_peer_delete(void *object, uint32_t groupnumber, void *peer_
{
Group_Peer_AV *peer_av = (Group_Peer_AV *)peer_object;
if (!peer_av) {
if (peer_av == nullptr) {
return;
}
@ -341,7 +341,7 @@ static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint3
out_audio = (int16_t *)malloc(num_samples * peer_av->decoder_channels * sizeof(int16_t));
if (!out_audio) {
if (out_audio == nullptr) {
free_audio_packet(pk);
return -1;
}
@ -356,17 +356,17 @@ static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint3
peer_av->last_packet_samples = out_audio_samples;
} else {
if (!peer_av->audio_decoder) {
if (peer_av->audio_decoder == nullptr) {
return -1;
}
if (!peer_av->last_packet_samples) {
if (peer_av->last_packet_samples == 0) {
return -1;
}
out_audio = (int16_t *)malloc(peer_av->last_packet_samples * peer_av->decoder_channels * sizeof(int16_t));
if (!out_audio) {
if (out_audio == nullptr) {
free_audio_packet(pk);
return -1;
}
@ -580,7 +580,7 @@ static int send_audio_packet(const Group_Chats *g_c, uint32_t groupnumber, const
Group_AV *const group_av = (Group_AV *)group_get_object(g_c, groupnumber);
if (!group_av) {
if (group_av == nullptr) {
return -1;
}
@ -610,7 +610,7 @@ int group_send_audio(Group_Chats *g_c, uint32_t groupnumber, const int16_t *pcm,
{
Group_AV *group_av = (Group_AV *)group_get_object(g_c, groupnumber);
if (!group_av) {
if (group_av == nullptr) {
return -1;
}

View File

@ -81,7 +81,7 @@ static msi_action_cb *get_callback(MSISession *session, MSICallbackID id);
void msi_register_callback(MSISession *session, msi_action_cb *callback, MSICallbackID id)
{
if (!session) {
if (session == nullptr) {
return;
}
@ -187,7 +187,7 @@ int msi_kill(MSISession *session, const Logger *log)
}
int msi_invite(MSISession *session, MSICall **call, uint32_t friend_number, uint8_t capabilities)
{
if (!session) {
if (session == nullptr) {
return -1;
}
@ -379,7 +379,7 @@ static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data
{
/* Parse raw data received from socket into MSIMessage struct */
assert(dest);
assert(dest != nullptr);
if (length == 0 || data[length - 1]) { /* End byte must have value 0 */
LOGGER_ERROR(log, "Invalid end byte");
@ -446,9 +446,9 @@ static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const void *
uint16_t *length)
{
/* Parse a single header for sending */
assert(dest);
assert(value);
assert(value_len);
assert(dest != nullptr);
assert(value != nullptr);
assert(value_len != 0);
*dest = id;
++dest;
@ -464,7 +464,7 @@ static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const void *
static int send_message(Messenger *m, uint32_t friend_number, const MSIMessage *msg)
{
/* Parse and send message */
assert(m);
assert(m != nullptr);
uint8_t parsed [MSI_MAXMSG_SIZE];
@ -509,7 +509,7 @@ static int send_message(Messenger *m, uint32_t friend_number, const MSIMessage *
static int send_error(Messenger *m, uint32_t friend_number, MSIError error)
{
/* Send error message */
assert(m);
assert(m != nullptr);
LOGGER_DEBUG(m->log, "Sending error: %d to friend: %d", error, friend_number);
@ -524,7 +524,7 @@ static int send_error(Messenger *m, uint32_t friend_number, MSIError error)
}
static int invoke_callback(MSICall *call, MSICallbackID cb)
{
assert(call);
assert(call != nullptr);
msi_action_cb *callback = get_callback(call->session, cb);
if (callback != nullptr) {
@ -552,7 +552,7 @@ FAILURE:
}
static MSICall *get_call(MSISession *session, uint32_t friend_number)
{
assert(session);
assert(session != nullptr);
if (session->calls == nullptr || session->calls_tail < friend_number) {
return nullptr;
@ -562,7 +562,7 @@ static MSICall *get_call(MSISession *session, uint32_t friend_number)
}
static MSICall *new_call(MSISession *session, uint32_t friend_number)
{
assert(session);
assert(session != nullptr);
MSICall *rc = (MSICall *)calloc(1, sizeof(MSICall));
@ -676,7 +676,7 @@ static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status,
}
static void handle_init(MSICall *call, const MSIMessage *msg)
{
assert(call);
assert(call != nullptr);
LOGGER_DEBUG(call->session->messenger->log,
"Session: %p Handling 'init' friend: %d", (void *)call->session, call->friend_number);
@ -738,7 +738,7 @@ FAILURE:
}
static void handle_push(MSICall *call, const MSIMessage *msg)
{
assert(call);
assert(call != nullptr);
LOGGER_DEBUG(call->session->messenger->log, "Session: %p Handling 'push' friend: %d", (void *)call->session,
call->friend_number);
@ -795,7 +795,7 @@ FAILURE:
}
static void handle_pop(MSICall *call, const MSIMessage *msg)
{
assert(call);
assert(call != nullptr);
LOGGER_DEBUG(call->session->messenger->log, "Session: %p Handling 'pop', friend id: %d", (void *)call->session,
call->friend_number);

View File

@ -68,14 +68,14 @@ RingBuffer *rb_new(int size)
{
RingBuffer *buf = (RingBuffer *)calloc(1, sizeof(RingBuffer));
if (!buf) {
if (buf == nullptr) {
return nullptr;
}
buf->size = size + 1; /* include empty elem */
buf->data = (void **)calloc(buf->size, sizeof(void *));
if (!buf->data) {
if (buf->data == nullptr) {
free(buf);
return nullptr;
}

View File

@ -654,7 +654,7 @@ RTPSession *rtp_new(int payload_type, Messenger *m, Tox *tox, uint32_t friendnum
RTPSession *session = (RTPSession *)calloc(1, sizeof(RTPSession));
if (!session) {
if (session == nullptr) {
LOGGER_WARNING(m->log, "Alloc failed! Program might misbehave!");
return nullptr;
}
@ -697,7 +697,7 @@ RTPSession *rtp_new(int payload_type, Messenger *m, Tox *tox, uint32_t friendnum
void rtp_kill(RTPSession *session)
{
if (!session) {
if (session == nullptr) {
return;
}
@ -751,7 +751,7 @@ int rtp_stop_receiving(RTPSession *session)
int rtp_send_data(RTPSession *session, const uint8_t *data, uint32_t length,
bool is_keyframe, const Logger *log)
{
if (!session) {
if (session == nullptr) {
LOGGER_ERROR(log, "No session!");
return -1;
}

View File

@ -223,7 +223,7 @@ void toxav_kill(ToxAV *av)
pthread_mutex_lock(av->mutex);
/* To avoid possible deadlocks */
while (av->msi && msi_kill(av->msi, av->m->log) != 0) {
while (av->msi != nullptr && msi_kill(av->msi, av->m->log) != 0) {
pthread_mutex_unlock(av->mutex);
pthread_mutex_lock(av->mutex);
}
@ -253,12 +253,12 @@ Tox *toxav_get_tox(const ToxAV *av)
uint32_t toxav_audio_iteration_interval(const ToxAV *av)
{
return av->calls ? av->audio_stats.interval : IDLE_ITERATION_INTERVAL_MS;
return av->calls != nullptr ? av->audio_stats.interval : IDLE_ITERATION_INTERVAL_MS;
}
uint32_t toxav_video_iteration_interval(const ToxAV *av)
{
return av->calls ? av->video_stats.interval : IDLE_ITERATION_INTERVAL_MS;
return av->calls != nullptr ? av->video_stats.interval : IDLE_ITERATION_INTERVAL_MS;
}
uint32_t toxav_iteration_interval(const ToxAV *av)
@ -528,7 +528,7 @@ static Toxav_Err_Call_Control call_control_handle_cancel(ToxAVCall *call)
}
static Toxav_Err_Call_Control call_control_handle_mute_audio(const ToxAVCall *call)
{
if (!(call->msi_call->self_capabilities & MSI_CAP_R_AUDIO)) {
if ((call->msi_call->self_capabilities & MSI_CAP_R_AUDIO) == 0) {
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
}
@ -543,7 +543,7 @@ static Toxav_Err_Call_Control call_control_handle_mute_audio(const ToxAVCall *ca
}
static Toxav_Err_Call_Control call_control_handle_unmute_audio(const ToxAVCall *call)
{
if (!(call->msi_call->self_capabilities ^ MSI_CAP_R_AUDIO)) {
if ((call->msi_call->self_capabilities ^ MSI_CAP_R_AUDIO) == 0) {
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
}
@ -557,7 +557,7 @@ static Toxav_Err_Call_Control call_control_handle_unmute_audio(const ToxAVCall *
}
static Toxav_Err_Call_Control call_control_handle_hide_video(const ToxAVCall *call)
{
if (!(call->msi_call->self_capabilities & MSI_CAP_R_VIDEO)) {
if ((call->msi_call->self_capabilities & MSI_CAP_R_VIDEO) == 0) {
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
}
@ -571,7 +571,7 @@ static Toxav_Err_Call_Control call_control_handle_hide_video(const ToxAVCall *ca
}
static Toxav_Err_Call_Control call_control_handle_show_video(const ToxAVCall *call)
{
if (!(call->msi_call->self_capabilities ^ MSI_CAP_R_VIDEO)) {
if ((call->msi_call->self_capabilities ^ MSI_CAP_R_VIDEO) == 0) {
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
}
@ -1060,7 +1060,7 @@ static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss,
*/
ToxAVCall *call = (ToxAVCall *)user_data;
assert(call);
assert(call != nullptr);
LOGGER_DEBUG(call->av->m->log, "Reported loss of %f%%", (double)loss * 100);
@ -1072,7 +1072,7 @@ static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss,
pthread_mutex_lock(call->av->mutex);
if (call->video_bit_rate) {
if (!call->av->vbcb) {
if (call->av->vbcb == nullptr) {
pthread_mutex_unlock(call->av->mutex);
LOGGER_WARNING(call->av->m->log, "No callback to report loss on");
return;
@ -1082,7 +1082,7 @@ static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss,
call->video_bit_rate - (call->video_bit_rate * loss),
call->av->vbcb_user_data);
} else if (call->audio_bit_rate) {
if (!call->av->abcb) {
if (call->av->abcb == nullptr) {
pthread_mutex_unlock(call->av->mutex);
LOGGER_WARNING(call->av->m->log, "No callback to report loss on");
return;

View File

@ -146,7 +146,7 @@ VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
VCSession *vc = (VCSession *)calloc(1, sizeof(VCSession));
vpx_codec_err_t rc;
if (!vc) {
if (vc == nullptr) {
LOGGER_WARNING(log, "Allocation failed! Application might misbehave!");
return nullptr;
}
@ -161,7 +161,7 @@ VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
vc->vbuf_raw = rb_new(VIDEO_DECODE_BUFFER_SIZE);
if (!vc->vbuf_raw) {
if (vc->vbuf_raw == nullptr) {
goto BASE_CLEANUP;
}
@ -266,7 +266,7 @@ BASE_CLEANUP:
void vc_kill(VCSession *vc)
{
if (!vc) {
if (vc == nullptr) {
return;
}
@ -286,7 +286,7 @@ void vc_kill(VCSession *vc)
void vc_iterate(VCSession *vc)
{
if (!vc) {
if (vc == nullptr) {
return;
}
@ -387,7 +387,7 @@ int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg)
int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist)
{
if (!vc) {
if (vc == nullptr) {
return -1;
}

View File

@ -1244,7 +1244,7 @@ uint32_t addto_lists(DHT *dht, const IP_Port *ip_port, const uint8_t *public_key
}
}
if (!friend_foundip) {
if (friend_foundip == nullptr) {
return used;
}
@ -2287,7 +2287,7 @@ static void punch_holes(DHT *dht, const IP *ip, const uint16_t *port_list, uint1
for (i = 0; i < MAX_PUNCHING_PORTS; ++i) {
/* TODO(irungentoo): Improve port guessing algorithm. */
const uint32_t it = i + dht->friends_list[friend_num].nat.punching_index;
const int8_t sign = (it % 2) ? -1 : 1;
const int8_t sign = (it % 2 != 0) ? -1 : 1;
const uint32_t delta = sign * (it / (2 * numports));
const uint32_t index = (it / 2) % numports;
const uint16_t port = port_list[index] + delta;
@ -2475,7 +2475,7 @@ static int cryptopacket_handle(void *object, const IP_Port *source, const uint8_
return 1;
}
if (!dht->cryptopackethandlers[number].function) {
if (dht->cryptopackethandlers[number].function == nullptr) {
return 1;
}
@ -2709,7 +2709,7 @@ int dht_connect_after_load(DHT *dht)
return -1;
}
if (!dht->loaded_nodes_list) {
if (dht->loaded_nodes_list == nullptr) {
return -1;
}

View File

@ -337,14 +337,14 @@ static int add_receipt(Messenger *m, int32_t friendnumber, uint32_t packet_num,
struct Receipts *new_receipts = (struct Receipts *)calloc(1, sizeof(struct Receipts));
if (!new_receipts) {
if (new_receipts == nullptr) {
return -1;
}
new_receipts->packet_num = packet_num;
new_receipts->msg_id = msg_id;
if (!m->friendlist[friendnumber].receipts_start) {
if (m->friendlist[friendnumber].receipts_start == nullptr) {
m->friendlist[friendnumber].receipts_start = new_receipts;
} else {
m->friendlist[friendnumber].receipts_end->next = new_receipts;
@ -396,7 +396,7 @@ static int do_receipts(Messenger *m, int32_t friendnumber, void *userdata)
receipts = r_next;
}
if (!m->friendlist[friendnumber].receipts_start) {
if (m->friendlist[friendnumber].receipts_start == nullptr) {
m->friendlist[friendnumber].receipts_end = nullptr;
}
@ -1282,7 +1282,7 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
if (control == FILECONTROL_ACCEPT) {
if (ft->status == FILESTATUS_TRANSFERRING) {
if (!(ft->paused & FILE_PAUSE_US)) {
if ((ft->paused & FILE_PAUSE_US) == 0) {
if (ft->paused & FILE_PAUSE_OTHER) {
return -6;
}
@ -2693,7 +2693,7 @@ bool m_register_state_plugin(Messenger *m, State_Type type, m_state_size_cb *siz
Messenger_State_Plugin *temp = (Messenger_State_Plugin *)realloc(m->options.state_plugins,
sizeof(Messenger_State_Plugin) * (m->options.state_plugins_length + 1));
if (!temp) {
if (temp == nullptr) {
return false;
}
@ -3136,7 +3136,7 @@ uint32_t count_friendlist(const Messenger *m)
* of out_list will be truncated to list_size. */
uint32_t copy_friendlist(Messenger const *m, uint32_t *out_list, uint32_t list_size)
{
if (!out_list) {
if (out_list == nullptr) {
return 0;
}
@ -3168,7 +3168,7 @@ uint32_t copy_friendlist(Messenger const *m, uint32_t *out_list, uint32_t list_s
*/
Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, Messenger_Error *error)
{
if (!options) {
if (options == nullptr) {
return nullptr;
}
@ -3178,7 +3178,7 @@ Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, Messe
Messenger *m = (Messenger *)calloc(1, sizeof(Messenger));
if (!m) {
if (m == nullptr) {
return nullptr;
}
@ -3186,7 +3186,7 @@ Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, Messe
m->fr = friendreq_new();
if (!m->fr) {
if (m->fr == nullptr) {
free(m);
return nullptr;
}
@ -3252,10 +3252,10 @@ Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, Messe
m->onion = new_onion(m->log, m->mono_time, m->dht);
m->onion_a = new_onion_announce(m->log, m->mono_time, m->dht);
m->onion_c = new_onion_client(m->log, m->mono_time, m->net_crypto);
m->onion_c = new_onion_client(m->log, m->mono_time, m->net_crypto);
m->fr_c = new_friend_connections(m->log, m->mono_time, m->onion_c, options->local_discovery_enabled);
if (!(m->onion && m->onion_a && m->onion_c && m->fr_c)) {
if (m->onion == nullptr || m->onion_a == nullptr || m->onion_c == nullptr || m->fr_c == nullptr) {
kill_friend_connections(m->fr_c);
kill_onion(m->onion);
kill_onion_announce(m->onion_a);
@ -3315,7 +3315,7 @@ Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, Messe
*/
void kill_messenger(Messenger *m)
{
if (!m) {
if (m == nullptr) {
return;
}

View File

@ -76,7 +76,7 @@ int send_pending_data(const Logger *logger, TCP_Connection *con)
con->priority_queue_start = p;
if (!p) {
if (p == nullptr) {
con->priority_queue_end = nullptr;
return 0;
}

View File

@ -65,7 +65,7 @@ uint32_t tcp_connections_count(const TCP_Connections *tcp_c)
non_null()
static int realloc_TCP_Connection_to(TCP_Connection_to **array, size_t num)
{
if (!num) {
if (num == 0) {
free(*array);
*array = nullptr;
return 0;
@ -74,7 +74,7 @@ static int realloc_TCP_Connection_to(TCP_Connection_to **array, size_t num)
TCP_Connection_to *temp_pointer =
(TCP_Connection_to *)realloc(*array, num * sizeof(TCP_Connection_to));
if (!temp_pointer) {
if (temp_pointer == nullptr) {
return -1;
}
@ -86,7 +86,7 @@ static int realloc_TCP_Connection_to(TCP_Connection_to **array, size_t num)
non_null()
static int realloc_TCP_con(TCP_con **array, size_t num)
{
if (!num) {
if (num == 0) {
free(*array);
*array = nullptr;
return 0;
@ -94,7 +94,7 @@ static int realloc_TCP_con(TCP_con **array, size_t num)
TCP_con *temp_pointer = (TCP_con *)realloc(*array, num * sizeof(TCP_con));
if (!temp_pointer) {
if (temp_pointer == nullptr) {
return -1;
}
@ -305,7 +305,7 @@ int send_packet_tcp_connection(const TCP_Connections *tcp_c, int connections_num
{
const TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);
if (!con_to) {
if (con_to == nullptr) {
return -1;
}
@ -324,7 +324,7 @@ int send_packet_tcp_connection(const TCP_Connections *tcp_c, int connections_num
tcp_con_num -= 1;
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_con_num);
if (!tcp_con) {
if (tcp_con == nullptr) {
continue;
}
@ -356,7 +356,7 @@ int send_packet_tcp_connection(const TCP_Connections *tcp_c, int connections_num
tcp_con_num -= 1;
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_con_num);
if (!tcp_con) {
if (tcp_con == nullptr) {
continue;
}
@ -433,7 +433,7 @@ int tcp_send_oob_packet(const TCP_Connections *tcp_c, unsigned int tcp_connectio
{
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -578,7 +578,7 @@ int kill_tcp_connection_to(TCP_Connections *tcp_c, int connections_number)
{
const TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);
if (!con_to) {
if (con_to == nullptr) {
return -1;
}
@ -587,7 +587,7 @@ int kill_tcp_connection_to(TCP_Connections *tcp_c, int connections_number)
unsigned int tcp_connections_number = con_to->connections[i].tcp_connection - 1;
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
continue;
}
@ -622,7 +622,7 @@ int set_tcp_connection_to_status(const TCP_Connections *tcp_c, int connections_n
{
TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);
if (!con_to) {
if (con_to == nullptr) {
return -1;
}
@ -637,7 +637,7 @@ int set_tcp_connection_to_status(const TCP_Connections *tcp_c, int connections_n
unsigned int tcp_connections_number = con_to->connections[i].tcp_connection - 1;
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
continue;
}
@ -661,7 +661,7 @@ int set_tcp_connection_to_status(const TCP_Connections *tcp_c, int connections_n
unsigned int tcp_connections_number = con_to->connections[i].tcp_connection - 1;
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
continue;
}
@ -779,7 +779,7 @@ int kill_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connections_number
{
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -805,7 +805,7 @@ static int reconnect_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connec
{
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -820,7 +820,7 @@ static int reconnect_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connec
tcp_con->connection = new_TCP_connection(tcp_c->logger, tcp_c->mono_time, &ip_port, relay_pk, tcp_c->self_public_key,
tcp_c->self_secret_key, &tcp_c->proxy_info);
if (!tcp_con->connection) {
if (tcp_con->connection == nullptr) {
kill_tcp_relay_connection(tcp_c, tcp_connections_number);
return -1;
}
@ -852,7 +852,7 @@ static int sleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connection
{
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -897,7 +897,7 @@ static int unsleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connecti
{
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -908,7 +908,7 @@ static int unsleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connecti
tcp_con->connection = new_TCP_connection(tcp_c->logger, tcp_c->mono_time, &tcp_con->ip_port, tcp_con->relay_pk,
tcp_c->self_public_key, tcp_c->self_secret_key, &tcp_c->proxy_info);
if (!tcp_con->connection) {
if (tcp_con->connection == nullptr) {
kill_tcp_relay_connection(tcp_c, tcp_connections_number);
return -1;
}
@ -933,7 +933,7 @@ static int send_tcp_relay_routing_request(const TCP_Connections *tcp_c, int tcp_
{
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -957,7 +957,7 @@ static int tcp_response_callback(void *object, uint8_t connection_id, const uint
unsigned int tcp_connections_number = tcp_con_custom_uint(tcp_client_con);
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -1035,13 +1035,13 @@ static int tcp_conn_data_callback(void *object, uint32_t number, uint8_t connect
unsigned int tcp_connections_number = tcp_con_custom_uint(tcp_client_con);
const TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
const TCP_Connection_to *con_to = get_connection(tcp_c, number);
if (!con_to) {
if (con_to == nullptr) {
return -1;
}
@ -1066,7 +1066,7 @@ static int tcp_conn_oob_callback(void *object, const uint8_t *public_key, const
unsigned int tcp_connections_number = tcp_con_custom_uint(tcp_client_con);
const TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -1108,7 +1108,7 @@ static int tcp_relay_set_callbacks(TCP_Connections *tcp_c, int tcp_connections_n
{
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -1130,7 +1130,7 @@ static int tcp_relay_on_online(TCP_Connections *tcp_c, int tcp_connections_numbe
{
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -1192,7 +1192,7 @@ static int add_tcp_relay_instance(TCP_Connections *tcp_c, const IP_Port *ip_port
tcp_con->connection = new_TCP_connection(tcp_c->logger, tcp_c->mono_time, &ipp_copy, relay_pk, tcp_c->self_public_key,
tcp_c->self_secret_key, &tcp_c->proxy_info);
if (!tcp_con->connection) {
if (tcp_con->connection == nullptr) {
return -1;
}
@ -1233,13 +1233,13 @@ int add_tcp_number_relay_connection(const TCP_Connections *tcp_c, int connection
{
TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);
if (!con_to) {
if (con_to == nullptr) {
return -1;
}
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -1272,7 +1272,7 @@ int add_tcp_relay_connection(TCP_Connections *tcp_c, int connections_number, con
{
TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);
if (!con_to) {
if (con_to == nullptr) {
return -1;
}
@ -1290,7 +1290,7 @@ int add_tcp_relay_connection(TCP_Connections *tcp_c, int connections_number, con
const TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
if (!tcp_con) {
if (tcp_con == nullptr) {
return -1;
}
@ -1308,7 +1308,7 @@ uint32_t tcp_connection_to_online_tcp_relays(const TCP_Connections *tcp_c, int c
{
const TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);
if (!con_to) {
if (con_to == nullptr) {
return 0;
}
@ -1431,7 +1431,7 @@ int set_tcp_onion_status(TCP_Connections *tcp_c, bool status)
}
}
if (!wakeup) {
if (wakeup == 0) {
break;
}
}

View File

@ -822,7 +822,7 @@ static Socket new_listening_TCP_socket(const Logger *logger, Family family, uint
if (!ok) {
char *const error = net_new_strerror(net_error());
LOGGER_ERROR(logger, "could not bind to TCP port %d (family = %d): %s",
port, family.value, error ? error : "(null)");
port, family.value, error != nullptr ? error : "(null)");
net_kill_strerror(error);
kill_sock(sock);
return net_invalid_socket;

View File

@ -224,7 +224,7 @@ static int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, cons
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -259,7 +259,7 @@ static void connect_to_saved_tcp_relays(Friend_Connections *fr_c, int friendcon_
{
const Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return;
}
@ -280,7 +280,7 @@ static unsigned int send_relays(Friend_Connections *fr_c, int friendcon_id)
{
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return 0;
}
@ -322,7 +322,7 @@ static int tcp_relay_node_callback(void *object, uint32_t number, const IP_Port
Friend_Connections *fr_c = (Friend_Connections *)object;
const Friend_Conn *friend_con = get_conn(fr_c, number);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -343,7 +343,7 @@ static void dht_ip_callback(void *object, int32_t number, const IP_Port *ip_port
Friend_Connections *const fr_c = (Friend_Connections *)object;
Friend_Conn *const friend_con = get_conn(fr_c, number);
if (!friend_con) {
if (friend_con == nullptr) {
return;
}
@ -366,7 +366,7 @@ static void change_dht_pk(Friend_Connections *fr_c, int friendcon_id, const uint
{
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return;
}
@ -391,7 +391,7 @@ static int handle_status(void *object, int number, uint8_t status, void *userdat
Friend_Connections *const fr_c = (Friend_Connections *)object;
Friend_Conn *const friend_con = get_conn(fr_c, number);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -439,7 +439,7 @@ static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_pub
Friend_Connections *const fr_c = (Friend_Connections *)object;
Friend_Conn *const friend_con = get_conn(fr_c, number);
if (!friend_con) {
if (friend_con == nullptr) {
return;
}
@ -470,7 +470,7 @@ static int handle_packet(void *object, int number, const uint8_t *data, uint16_t
Friend_Connections *const fr_c = (Friend_Connections *)object;
Friend_Conn *friend_con = get_conn(fr_c, number);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -511,7 +511,7 @@ static int handle_packet(void *object, int number, const uint8_t *data, uint16_t
friend_con = get_conn(fr_c, number);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
}
@ -529,7 +529,7 @@ static int handle_lossy_packet(void *object, int number, const uint8_t *data, ui
const Friend_Connections *const fr_c = (const Friend_Connections *)object;
const Friend_Conn *friend_con = get_conn(fr_c, number);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -542,7 +542,7 @@ static int handle_lossy_packet(void *object, int number, const uint8_t *data, ui
friend_con = get_conn(fr_c, number);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
}
@ -557,7 +557,7 @@ static int handle_new_connections(void *object, const New_Connection *n_c)
const int friendcon_id = getfriend_conn_id_pk(fr_c, n_c->public_key);
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -595,7 +595,7 @@ static int friend_new_connection(Friend_Connections *fr_c, int friendcon_id)
{
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -628,7 +628,7 @@ static int send_ping(const Friend_Connections *fr_c, int friendcon_id)
{
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -652,7 +652,7 @@ int friend_connection_lock(const Friend_Connections *fr_c, int friendcon_id)
{
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -668,7 +668,7 @@ unsigned int friend_con_connected(const Friend_Connections *fr_c, int friendcon_
{
const Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return 0;
}
@ -684,7 +684,7 @@ int get_friendcon_public_keys(uint8_t *real_pk, uint8_t *dht_temp_pk, const Frie
{
const Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -720,7 +720,7 @@ int friend_connection_callbacks(const Friend_Connections *fr_c, int friendcon_id
{
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -764,7 +764,7 @@ int friend_connection_crypt_connection_id(const Friend_Connections *fr_c, int fr
{
const Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -820,7 +820,7 @@ int kill_friend_connection(Friend_Connections *fr_c, int friendcon_id)
{
Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -866,7 +866,7 @@ int send_friend_request_packet(Friend_Connections *fr_c, int friendcon_id, uint3
const Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id);
if (!friend_con) {
if (friend_con == nullptr) {
return -1;
}
@ -1004,7 +1004,7 @@ void do_friend_connections(Friend_Connections *fr_c, void *userdata)
/** Free everything related with friend_connections. */
void kill_friend_connections(Friend_Connections *fr_c)
{
if (!fr_c) {
if (fr_c == nullptr) {
return;
}

View File

@ -374,7 +374,7 @@ static void purge_closest(Group_Chats *g_c, uint32_t groupnumber)
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return;
}
@ -409,7 +409,7 @@ static void add_closest_connections(Group_Chats *g_c, uint32_t groupnumber, void
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return;
}
@ -456,7 +456,7 @@ static bool connect_to_closest(Group_Chats *g_c, uint32_t groupnumber, void *use
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -530,7 +530,7 @@ static int note_peer_active(Group_Chats *g_c, uint32_t groupnumber, uint16_t pee
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -589,7 +589,7 @@ static void delete_any_peer_with_pk(Group_Chats *g_c, uint32_t groupnumber, cons
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return;
}
@ -624,7 +624,7 @@ static int addpeer(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_p
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -726,7 +726,7 @@ static bool delpeer(Group_Chats *g_c, uint32_t groupnumber, int peer_index, void
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -839,7 +839,7 @@ static bool freeze_peer(Group_Chats *g_c, uint32_t groupnumber, int peer_index,
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -885,7 +885,7 @@ static bool setnick(Group_Chats *g_c, uint32_t groupnumber, int peer_index, cons
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -924,7 +924,7 @@ static bool settitle(Group_Chats *g_c, uint32_t groupnumber, int peer_index, con
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -951,7 +951,7 @@ static void check_disconnected(Group_Chats *g_c, uint32_t groupnumber, void *use
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return;
}
@ -974,7 +974,7 @@ static void set_conns_type_connections(Group_Chats *g_c, uint32_t groupnumber, i
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return;
}
@ -1014,7 +1014,7 @@ static void rejoin_frozen_friend(Group_Chats *g_c, int friendcon_id)
for (uint16_t i = 0; i < g_c->num_chats; ++i) {
Group_c *g = get_group_c(g_c, i);
if (!g) {
if (g == nullptr) {
continue;
}
@ -1187,7 +1187,7 @@ int del_groupchat(Group_Chats *g_c, uint32_t groupnumber, bool leave_permanently
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1243,7 +1243,7 @@ int group_peer_pubkey(const Group_Chats *g_c, uint32_t groupnumber, uint32_t pee
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1267,7 +1267,7 @@ int group_peername_size(const Group_Chats *g_c, uint32_t groupnumber, uint32_t p
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1291,7 +1291,7 @@ int group_peername(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernu
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1320,7 +1320,7 @@ int group_frozen_last_active(const Group_Chats *g_c, uint32_t groupnumber, uint3
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1341,7 +1341,7 @@ int group_set_max_frozen(const Group_Chats *g_c, uint32_t groupnumber, uint32_t
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1358,7 +1358,7 @@ int group_number_peers(const Group_Chats *g_c, uint32_t groupnumber, bool frozen
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1375,7 +1375,7 @@ int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, uint3
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1399,7 +1399,7 @@ int group_get_type(const Group_Chats *g_c, uint32_t groupnumber)
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1415,7 +1415,7 @@ bool conference_get_id(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *id
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -1481,7 +1481,7 @@ int invite_friend(const Group_Chats *g_c, uint32_t friendnumber, uint32_t groupn
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1700,7 +1700,7 @@ int callback_groupchat_peer_new(const Group_Chats *g_c, uint32_t groupnumber, pe
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1717,7 +1717,7 @@ int callback_groupchat_peer_delete(const Group_Chats *g_c, uint32_t groupnumber,
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1734,7 +1734,7 @@ int callback_groupchat_delete(const Group_Chats *g_c, uint32_t groupnumber, grou
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1840,7 +1840,7 @@ static bool group_leave(const Group_Chats *g_c, uint32_t groupnumber, bool perma
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -1862,7 +1862,7 @@ int group_title_send(const Group_Chats *g_c, uint32_t groupnumber, const uint8_t
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1897,7 +1897,7 @@ int group_title_get_size(const Group_Chats *g_c, uint32_t groupnumber)
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -1919,7 +1919,7 @@ int group_title_get(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *title
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -2004,7 +2004,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
Group_c *g = get_group_c(g_c, groupnum);
if (!g) {
if (g == nullptr) {
return;
}
@ -2146,7 +2146,7 @@ static int handle_packet_online(const Group_Chats *g_c, int friendcon_id, const
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -2199,7 +2199,7 @@ static int handle_packet_rejoin(Group_Chats *g_c, int friendcon_id, const uint8_
Group_c *g = get_group_c(g_c, groupnum);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -2312,7 +2312,7 @@ static int handle_send_peers(Group_Chats *g_c, uint32_t groupnumber, const uint8
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -2370,7 +2370,7 @@ static void handle_direct_packet(Group_Chats *g_c, uint32_t groupnumber, const u
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return;
}
@ -2469,7 +2469,7 @@ static unsigned int send_lossy_all_connections(const Group_Chats *g_c, const Gro
}
}
if (!num_connected_closest) {
if (num_connected_closest == 0) {
return sent;
}
@ -2517,7 +2517,7 @@ static int send_message_group(const Group_Chats *g_c, uint32_t groupnumber, uint
assert(len == 0 || data != nullptr);
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -2597,7 +2597,7 @@ int send_group_lossy_packet(const Group_Chats *g_c, uint32_t groupnumber, const
// TODO(irungentoo): length check here?
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -2680,7 +2680,7 @@ static void handle_message_packet_group(Group_Chats *g_c, uint32_t groupnumber,
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return;
}
@ -2869,7 +2869,7 @@ static int g_handle_packet(void *object, int friendcon_id, const uint8_t *data,
groupnumber = net_ntohs(groupnumber);
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -2979,7 +2979,7 @@ static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uin
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -3015,7 +3015,7 @@ static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uin
send_lossy_all_connections(g_c, g, data + 1 + sizeof(uint16_t), length - (1 + sizeof(uint16_t)), index);
if (!g_c->lossy_packethandlers[message_id].function) {
if (g_c->lossy_packethandlers[message_id].function == nullptr) {
return -1;
}
@ -3036,7 +3036,7 @@ int group_set_object(const Group_Chats *g_c, uint32_t groupnumber, void *object)
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -3053,7 +3053,7 @@ int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, uint32_t
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return -1;
}
@ -3074,7 +3074,7 @@ void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber)
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return nullptr;
}
@ -3090,7 +3090,7 @@ void *group_peer_get_object(const Group_Chats *g_c, uint32_t groupnumber, uint32
{
const Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return nullptr;
}
@ -3108,7 +3108,7 @@ static bool ping_groupchat(const Group_Chats *g_c, uint32_t groupnumber)
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -3129,7 +3129,7 @@ static bool groupchat_freeze_timedout(Group_Chats *g_c, uint32_t groupnumber, vo
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g) {
if (g == nullptr) {
return false;
}
@ -3232,7 +3232,7 @@ void send_name_all_groups(const Group_Chats *g_c)
for (uint16_t i = 0; i < g_c->num_chats; ++i) {
Group_c *g = get_group_c(g_c, i);
if (!g) {
if (g == nullptr) {
continue;
}
@ -3514,7 +3514,7 @@ bool conferences_load_state_section(Group_Chats *g_c, const uint8_t *data, uint3
/** Create new groupchat instance. */
Group_Chats *new_groupchats(const Mono_Time *mono_time, Messenger *m)
{
if (!m) {
if (m == nullptr) {
return nullptr;
}
@ -3541,7 +3541,7 @@ void do_groupchats(Group_Chats *g_c, void *userdata)
for (uint16_t i = 0; i < g_c->num_chats; ++i) {
Group_c *g = get_group_c(g_c, i);
if (!g) {
if (g == nullptr) {
continue;
}
@ -3598,7 +3598,7 @@ uint32_t count_chatlist(const Group_Chats *g_c)
* of out_list will be truncated to list_size. */
uint32_t copy_chatlist(const Group_Chats *g_c, uint32_t *out_list, uint32_t list_size)
{
if (!out_list) {
if (out_list == nullptr) {
return 0;
}

View File

@ -116,7 +116,7 @@ static bool resize(BS_List *list, uint32_t new_size)
uint8_t *data = (uint8_t *)realloc(list->data, list->element_size * new_size);
if (!data) {
if (data == nullptr) {
return false;
}
@ -124,7 +124,7 @@ static bool resize(BS_List *list, uint32_t new_size)
int *ids = (int *)realloc(list->ids, sizeof(int) * new_size);
if (!ids) {
if (ids == nullptr) {
return false;
}

View File

@ -83,7 +83,7 @@ void logger_callback_log(Logger *log, logger_cb *function, void *context, void *
void logger_write(const Logger *log, Logger_Level level, const char *file, int line, const char *func,
const char *format, ...)
{
if (!log) {
if (log == nullptr) {
#ifdef USE_STDERR_LOGGER
log = &logger_stderr;
#else
@ -92,7 +92,7 @@ void logger_write(const Logger *log, Logger_Level level, const char *file, int l
#endif
}
if (!log->callback) {
if (log->callback == nullptr) {
return;
}

View File

@ -803,7 +803,7 @@ static int get_data_pointer(const Packets_Array *array, Packet_Data **data, uint
uint32_t num = number % CRYPTO_PACKET_BUFFER_SIZE;
if (!array->buffer[num]) {
if (array->buffer[num] == nullptr) {
return 0;
}
@ -854,7 +854,7 @@ static int64_t read_data_beg_buffer(Packets_Array *array, Packet_Data *data)
const uint32_t num = array->buffer_start % CRYPTO_PACKET_BUFFER_SIZE;
if (!array->buffer[num]) {
if (array->buffer[num] == nullptr) {
return -1;
}
@ -963,7 +963,7 @@ static int generate_request_packet(uint8_t *data, uint16_t length, const Packets
for (uint32_t i = recv_array->buffer_start; i != recv_array->buffer_end; ++i) {
uint32_t num = i % CRYPTO_PACKET_BUFFER_SIZE;
if (!recv_array->buffer[num]) {
if (recv_array->buffer[num] == nullptr) {
data[cur_len] = n;
n = 0;
++cur_len;
@ -1439,7 +1439,7 @@ static int send_temp_packet(Net_Crypto *c, int crypt_connection_id)
return -1;
}
if (!conn->temp_packet) {
if (conn->temp_packet == nullptr) {
return -1;
}
@ -1519,7 +1519,7 @@ static void connection_kill(Net_Crypto *c, int crypt_connection_id, void *userda
while (1) { /* TODO(irungentoo): is this really the best way to do this? */
pthread_mutex_lock(&c->connections_mutex);
if (!c->connection_use_counter) {
if (c->connection_use_counter == 0) {
break;
}
@ -1836,7 +1836,7 @@ static int create_crypto_connection(Net_Crypto *c)
while (1) { /* TODO(irungentoo): is this really the best way to do this? */
pthread_mutex_lock(&c->connections_mutex);
if (!c->connection_use_counter) {
if (c->connection_use_counter == 0) {
break;
}

View File

@ -520,7 +520,7 @@ static void loglogdata(const Logger *log, const char *message, const uint8_t *bu
data_0(buflen, buffer), data_1(buflen, buffer), buffer[buflen - 1]);
} else { /* empty or overwrite */
LOGGER_TRACE(log, "[%2u] %s %lu%c%u %s:%u (%u: %s) | %08x%08x...%02x",
buffer[0], message, res, !res ? '!' : '>', buflen,
buffer[0], message, res, res == 0 ? '!' : '>', buflen,
ip_ntoa(&ip_port->ip, ip_str, sizeof(ip_str)), net_ntohs(ip_port->port), 0, "OK",
data_0(buflen, buffer), data_1(buflen, buffer), buffer[buflen - 1]);
}
@ -1080,7 +1080,7 @@ Networking_Core *new_networking_no_udp(const Logger *log)
/** Function to cleanup networking stuff (doesn't do much right now). */
void kill_networking(Networking_Core *net)
{
if (!net) {
if (net == nullptr) {
return;
}
@ -1151,7 +1151,7 @@ bool ipport_equal(const IP_Port *a, const IP_Port *b)
/** nulls out ip */
void ip_reset(IP *ip)
{
if (!ip) {
if (ip == nullptr) {
return;
}
@ -1161,7 +1161,7 @@ void ip_reset(IP *ip)
/** nulls out ip_port */
void ipport_reset(IP_Port *ipport)
{
if (!ipport) {
if (ipport == nullptr) {
return;
}
@ -1171,7 +1171,7 @@ void ipport_reset(IP_Port *ipport)
/** nulls out ip, sets family according to flag */
void ip_init(IP *ip, bool ipv6enabled)
{
if (!ip) {
if (ip == nullptr) {
return;
}
@ -1182,7 +1182,7 @@ void ip_init(IP *ip, bool ipv6enabled)
/** checks if ip is valid */
bool ip_isset(const IP *ip)
{
if (!ip) {
if (ip == nullptr) {
return false;
}
@ -1192,7 +1192,7 @@ bool ip_isset(const IP *ip)
/** checks if ip is valid */
bool ipport_isset(const IP_Port *ipport)
{
if (!ipport) {
if (ipport == nullptr) {
return false;
}

View File

@ -946,7 +946,7 @@ static int handle_data_response(void *object, const IP_Port *source, const uint8
return 1;
}
if (!onion_c->onion_data_handlers[plain[0]].function) {
if (onion_c->onion_data_handlers[plain[0]].function == nullptr) {
return 1;
}

View File

@ -591,7 +591,7 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
// TODO(iphydf): Clarify this code, check for NULL before new_groupchats, so
// new_groupchats can assume m is non-NULL.
if (!new_groupchats(tox->mono_time, tox->m)) {
if (new_groupchats(tox->mono_time, tox->m) == nullptr) {
kill_messenger(tox->m);
if (m_error == MESSENGER_ERROR_PORT) {
@ -1108,7 +1108,7 @@ uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, Tox_Err_F
{
assert(tox != nullptr);
if (!public_key) {
if (public_key == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_ADD_NULL);
return UINT32_MAX;
}
@ -1148,7 +1148,7 @@ uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, Tox
{
assert(tox != nullptr);
if (!public_key) {
if (public_key == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_BY_PUBLIC_KEY_NULL);
return UINT32_MAX;
}
@ -1171,7 +1171,7 @@ bool tox_friend_get_public_key(const Tox *tox, uint32_t friend_number, uint8_t *
{
assert(tox != nullptr);
if (!public_key) {
if (public_key == nullptr) {
return 0;
}
@ -1254,7 +1254,7 @@ bool tox_friend_get_name(const Tox *tox, uint32_t friend_number, uint8_t *name,
{
assert(tox != nullptr);
if (!name) {
if (name == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_NULL);
return 0;
}
@ -1299,7 +1299,7 @@ bool tox_friend_get_status_message(const Tox *tox, uint32_t friend_number, uint8
{
assert(tox != nullptr);
if (!status_message) {
if (status_message == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_NULL);
return false;
}
@ -1456,12 +1456,12 @@ uint32_t tox_friend_send_message(Tox *tox, uint32_t friend_number, Tox_Message_T
{
assert(tox != nullptr);
if (!message) {
if (message == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_NULL);
return 0;
}
if (!length) {
if (length == 0) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_EMPTY);
return 0;
}
@ -1627,7 +1627,7 @@ bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32_t file_
{
assert(tox != nullptr);
if (!file_id) {
if (file_id == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FILE_GET_NULL);
return 0;
}
@ -1662,7 +1662,7 @@ uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t
uint8_t f_id[FILE_ID_LENGTH];
if (!file_id) {
if (file_id == nullptr) {
/* Tox keys are 32 bytes like FILE_ID_LENGTH. */
new_symmetric_key(f_id);
file_id = f_id;
@ -2346,7 +2346,7 @@ uint32_t tox_conference_by_id(const Tox *tox, const uint8_t *id, Tox_Err_Confere
{
assert(tox != nullptr);
if (!id) {
if (id == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_BY_ID_NULL);
return UINT32_MAX;
}
@ -2432,7 +2432,7 @@ bool tox_friend_send_lossy_packet(Tox *tox, uint32_t friend_number, const uint8_
{
assert(tox != nullptr);
if (!data) {
if (data == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_NULL);
return 0;
}
@ -2484,7 +2484,7 @@ bool tox_friend_send_lossless_packet(Tox *tox, uint32_t friend_number, const uin
{
assert(tox != nullptr);
if (!data) {
if (data == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_NULL);
return 0;
}

View File

@ -138,7 +138,7 @@ Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t pp
Tox_Pass_Key *out_key = (Tox_Pass_Key *)calloc(1, sizeof(Tox_Pass_Key));
if (!out_key) {
if (out_key == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_FAILED);
return nullptr;
}
@ -212,7 +212,7 @@ bool tox_pass_encrypt(const uint8_t *data, size_t data_len, const uint8_t *passp
Tox_Err_Key_Derivation err;
Tox_Pass_Key *key = tox_pass_key_derive(passphrase, pplength, &err);
if (!key) {
if (key == nullptr) {
if (err == TOX_ERR_KEY_DERIVATION_NULL) {
SET_ERROR_PARAMETER(error, TOX_ERR_ENCRYPTION_NULL);
} else if (err == TOX_ERR_KEY_DERIVATION_FAILED) {
@ -304,7 +304,7 @@ bool tox_pass_decrypt(const uint8_t *data, size_t length, const uint8_t *passphr
/* derive the key */
Tox_Pass_Key *key = tox_pass_key_derive_with_salt(passphrase, pplength, salt, nullptr);
if (!key) {
if (key == nullptr) {
/* out of memory most likely */
SET_ERROR_PARAMETER(error, TOX_ERR_DECRYPTION_KEY_DERIVATION_FAILED);
return 0;