cleanup: Remove all implicit bool conversions in if-conditions.

Note to reviewer: please review carefully. This was done manually.
This commit is contained in:
iphydf 2022-02-21 14:10:31 +00:00
parent fff2b1c4e7
commit a9ccf1be26
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
18 changed files with 79 additions and 77 deletions

View File

@ -1 +1 @@
a9891d63ae5950b05e148fe9d3157d0443576c15ea42f478db550939a2cd4568 /usr/local/bin/tox-bootstrapd
dc97c6a50cf2e3d06dc24216194569b06445922a5182362af2124114653d7f71 /usr/local/bin/tox-bootstrapd

View File

@ -210,7 +210,7 @@ void ac_iterate(ACSession *ac)
int ac_queue_message(Mono_Time *mono_time, void *acp, struct RTPMessage *msg)
{
if (!acp || !msg) {
if (acp == nullptr || msg == nullptr) {
free(msg);
return -1;
}
@ -244,11 +244,12 @@ int ac_queue_message(Mono_Time *mono_time, void *acp, struct RTPMessage *msg)
int ac_reconfigure_encoder(ACSession *ac, uint32_t bit_rate, uint32_t sampling_rate, uint8_t channels)
{
if (!ac || !reconfigure_audio_encoder(ac->log, &ac->encoder, bit_rate,
sampling_rate, channels,
&ac->le_bit_rate,
&ac->le_sample_rate,
&ac->le_channel_count)) {
if (ac == nullptr || !reconfigure_audio_encoder(
ac->log, &ac->encoder, bit_rate,
sampling_rate, channels,
&ac->le_bit_rate,
&ac->le_sample_rate,
&ac->le_channel_count)) {
return -1;
}

View File

@ -118,7 +118,7 @@ void bwc_add_lost(BWController *bwc, uint32_t bytes_lost)
void bwc_add_recv(BWController *bwc, uint32_t recv_bytes)
{
if (!bwc || !recv_bytes) {
if (bwc == nullptr || recv_bytes == 0) {
return;
}
@ -178,7 +178,7 @@ static int on_update(BWController *bwc, const struct BWCMessage *msg)
const uint32_t recv = msg->recv;
const uint32_t lost = msg->lost;
if (lost && bwc->mcb) {
if (lost && bwc->mcb != nullptr) {
LOGGER_DEBUG(bwc->m->log, "recved: %u lost: %u percentage: %f %%", recv, lost,
((double)lost / (recv + lost)) * 100.0);
bwc->mcb(bwc, bwc->friend_number,

View File

@ -290,7 +290,7 @@ static void group_av_groupchat_delete(void *object, uint32_t groupnumber)
static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint32_t groupnumber,
uint32_t friendgroupnumber)
{
if (!group_av || !peer_av) {
if (group_av == nullptr || peer_av == nullptr) {
return -1;
}
@ -396,7 +396,7 @@ static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint3
static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_t friendgroupnumber, void *peer_object,
const uint8_t *packet, uint16_t length)
{
if (!peer_object || !object || length <= sizeof(uint16_t)) {
if (peer_object == nullptr || object == nullptr || length <= sizeof(uint16_t)) {
return -1;
}
@ -623,7 +623,8 @@ int group_send_audio(Group_Chats *g_c, uint32_t groupnumber, const int16_t *pcm,
return -1;
}
if (!group_av->audio_encoder || group_av->audio_channels != channels || group_av->audio_sample_rate != sample_rate) {
if (group_av->audio_encoder == nullptr || group_av->audio_channels != channels
|| group_av->audio_sample_rate != sample_rate) {
group_av->audio_channels = channels;
group_av->audio_sample_rate = sample_rate;

View File

@ -231,7 +231,7 @@ int msi_invite(MSISession *session, MSICall **call, uint32_t friend_number, uint
}
int msi_hangup(MSICall *call)
{
if (!call || !call->session) {
if (call == nullptr || call->session == nullptr) {
return -1;
}
@ -262,7 +262,7 @@ int msi_hangup(MSICall *call)
}
int msi_answer(MSICall *call, uint8_t capabilities)
{
if (!call || !call->session) {
if (call == nullptr || call->session == nullptr) {
return -1;
}
@ -301,7 +301,7 @@ int msi_answer(MSICall *call, uint8_t capabilities)
}
int msi_change_capabilities(MSICall *call, uint8_t capabilities)
{
if (!call || !call->session) {
if (call == nullptr || call->session == nullptr) {
return -1;
}

View File

@ -441,7 +441,7 @@ static int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t
{
RTPSession *session = (RTPSession *)object;
if (!session || length < RTP_HEADER_SIZE + 1) {
if (session == nullptr || length < RTP_HEADER_SIZE + 1) {
LOGGER_WARNING(m->log, "No session or invalid length of received buffer!");
return -1;
}
@ -467,7 +467,7 @@ static int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t
return -1;
}
if (header.flags & RTP_LARGE_FRAME && header.offset_full >= header.data_length_full) {
if ((header.flags & RTP_LARGE_FRAME) != 0 && header.offset_full >= header.data_length_full) {
LOGGER_ERROR(m->log, "Invalid video packet: frame offset (%u) >= full frame length (%u)",
(unsigned)header.offset_full, (unsigned)header.data_length_full);
return -1;
@ -483,7 +483,7 @@ static int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t
// The sender uses the new large-frame capable protocol and is sending a
// video packet.
if ((header.flags & RTP_LARGE_FRAME) && header.pt == (RTP_TYPE_VIDEO % 128)) {
if ((header.flags & RTP_LARGE_FRAME) != 0 && header.pt == (RTP_TYPE_VIDEO % 128)) {
return handle_video_packet(session, &header, data + RTP_HEADER_SIZE, length - RTP_HEADER_SIZE, m->log);
}

View File

@ -304,7 +304,7 @@ static void iterate_common(ToxAV *av, bool audio)
// time until the first audio or video frame is over
int32_t frame_time = IDLE_ITERATION_INTERVAL_MS;
for (ToxAVCall *i = av->calls[av->calls_head]; i; i = i->next) {
for (ToxAVCall *i = av->calls[av->calls_head]; i != nullptr; i = i->next) {
if (!i->active) {
continue;
}
@ -315,15 +315,15 @@ static void iterate_common(ToxAV *av, bool audio)
if (audio) {
ac_iterate(i->audio);
if (i->msi_call->self_capabilities & MSI_CAP_R_AUDIO &&
i->msi_call->peer_capabilities & MSI_CAP_S_AUDIO) {
if ((i->msi_call->self_capabilities & MSI_CAP_R_AUDIO) != 0 &&
(i->msi_call->peer_capabilities & MSI_CAP_S_AUDIO) != 0) {
frame_time = min_s32(i->audio->lp_frame_duration, frame_time);
}
} else {
vc_iterate(i->video);
if (i->msi_call->self_capabilities & MSI_CAP_R_VIDEO &&
i->msi_call->peer_capabilities & MSI_CAP_S_VIDEO) {
if ((i->msi_call->self_capabilities & MSI_CAP_R_VIDEO) != 0 &&
(i->msi_call->peer_capabilities & MSI_CAP_S_VIDEO) != 0) {
pthread_mutex_lock(i->video->queue_mutex);
frame_time = min_s32(i->video->lcfd, frame_time);
pthread_mutex_unlock(i->video->queue_mutex);
@ -821,8 +821,8 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc
}
if (call->audio_bit_rate == 0 ||
!(call->msi_call->self_capabilities & MSI_CAP_S_AUDIO) ||
!(call->msi_call->peer_capabilities & MSI_CAP_R_AUDIO)) {
(call->msi_call->self_capabilities & MSI_CAP_S_AUDIO) == 0 ||
(call->msi_call->peer_capabilities & MSI_CAP_R_AUDIO) == 0) {
pthread_mutex_unlock(av->mutex);
rc = TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED;
goto RETURN;
@ -948,8 +948,8 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
}
if (call->video_bit_rate == 0 ||
!(call->msi_call->self_capabilities & MSI_CAP_S_VIDEO) ||
!(call->msi_call->peer_capabilities & MSI_CAP_R_VIDEO)) {
(call->msi_call->self_capabilities & MSI_CAP_S_VIDEO) == 0 ||
(call->msi_call->peer_capabilities & MSI_CAP_R_VIDEO) == 0) {
pthread_mutex_unlock(av->mutex);
rc = TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED;
goto RETURN;
@ -1186,13 +1186,13 @@ static int callback_capabilites(void *toxav_inst, MSICall *call)
ToxAV *toxav = (ToxAV *)toxav_inst;
pthread_mutex_lock(toxav->mutex);
if (call->peer_capabilities & MSI_CAP_S_AUDIO) {
if ((call->peer_capabilities & MSI_CAP_S_AUDIO) != 0) {
rtp_allow_receiving(call->av_call->audio_rtp);
} else {
rtp_stop_receiving(call->av_call->audio_rtp);
}
if (call->peer_capabilities & MSI_CAP_S_VIDEO) {
if ((call->peer_capabilities & MSI_CAP_S_VIDEO) != 0) {
rtp_allow_receiving(call->av_call->video_rtp);
} else {
rtp_stop_receiving(call->av_call->video_rtp);

View File

@ -306,7 +306,7 @@ void vc_iterate(VCSession *vc)
uint32_t full_data_len;
if (header->flags & RTP_LARGE_FRAME) {
if ((header->flags & RTP_LARGE_FRAME) != 0) {
full_data_len = header->data_length_full;
LOGGER_DEBUG(vc->log, "vc_iterate:001:full_data_len=%d", (int)full_data_len);
} else {
@ -346,10 +346,8 @@ int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg)
* they have already been assembled.
* this function gets called from handle_rtp_packet() and handle_rtp_packet_v3()
*/
if (!vcp || !msg) {
if (msg != nullptr) {
free(msg);
}
if (vcp == nullptr || msg == nullptr) {
free(msg);
return -1;
}
@ -371,7 +369,7 @@ int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg)
pthread_mutex_lock(vc->queue_mutex);
if ((header->flags & RTP_LARGE_FRAME) && header->pt == RTP_TYPE_VIDEO % 128) {
if ((header->flags & RTP_LARGE_FRAME) != 0 && header->pt == RTP_TYPE_VIDEO % 128) {
LOGGER_DEBUG(vc->log, "rb_write msg->len=%d b0=%d b1=%d", (int)msg->len, (int)msg->data[0], (int)msg->data[1]);
}

View File

@ -326,7 +326,7 @@ void dht_get_shared_key_sent(DHT *dht, uint8_t *shared_key, const uint8_t *publi
int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_key, uint8_t *packet,
const uint8_t *recv_public_key, const uint8_t *data, uint32_t length, uint8_t request_id)
{
if (!send_public_key || !packet || !recv_public_key || !data) {
if (send_public_key == nullptr || packet == nullptr || recv_public_key == nullptr || data == nullptr) {
return -1;
}
@ -364,7 +364,8 @@ int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_ke
int handle_request(const uint8_t *self_public_key, const uint8_t *self_secret_key, uint8_t *public_key, uint8_t *data,
uint8_t *request_id, const uint8_t *packet, uint16_t length)
{
if (!self_public_key || !public_key || !data || !request_id || !packet) {
if (self_public_key == nullptr || public_key == nullptr || data == nullptr || request_id == nullptr
|| packet == nullptr) {
return -1;
}

View File

@ -1276,14 +1276,14 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
return -4;
}
if (control == FILECONTROL_PAUSE && ((ft->paused & FILE_PAUSE_US) || ft->status != FILESTATUS_TRANSFERRING)) {
if (control == FILECONTROL_PAUSE && ((ft->paused & FILE_PAUSE_US) != 0 || ft->status != FILESTATUS_TRANSFERRING)) {
return -5;
}
if (control == FILECONTROL_ACCEPT) {
if (ft->status == FILESTATUS_TRANSFERRING) {
if ((ft->paused & FILE_PAUSE_US) == 0) {
if (ft->paused & FILE_PAUSE_OTHER) {
if ((ft->paused & FILE_PAUSE_OTHER) != 0) {
return -6;
}
@ -1313,7 +1313,7 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
} else if (control == FILECONTROL_ACCEPT) {
ft->status = FILESTATUS_TRANSFERRING;
if (ft->paused & FILE_PAUSE_US) {
if ((ft->paused & FILE_PAUSE_US) != 0) {
ft->paused ^= FILE_PAUSE_US;
}
}
@ -1678,7 +1678,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
ft->status = FILESTATUS_TRANSFERRING;
++m->friendlist[friendnumber].num_sending_files;
} else {
if (ft->paused & FILE_PAUSE_OTHER) {
if ((ft->paused & FILE_PAUSE_OTHER) != 0) {
ft->paused ^= FILE_PAUSE_OTHER;
} else {
LOGGER_DEBUG(m->log, "file control (friend %d, file %d): friend told us to resume file transfer that wasn't paused",
@ -1695,7 +1695,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
}
case FILECONTROL_PAUSE: {
if ((ft->paused & FILE_PAUSE_OTHER) || ft->status != FILESTATUS_TRANSFERRING) {
if ((ft->paused & FILE_PAUSE_OTHER) != 0 || ft->status != FILESTATUS_TRANSFERRING) {
LOGGER_DEBUG(m->log, "file control (friend %d, file %d): friend told us to pause file transfer that is already paused",
friendnumber, filenumber);
return -1;
@ -3222,7 +3222,7 @@ Messenger *new_messenger(Mono_Time *mono_time, Messenger_Options *options, Messe
logger_kill(m->log);
free(m);
if (error && net_err == 1) {
if (error != nullptr && net_err == 1) {
*error = MESSENGER_ERROR_PORT;
}

View File

@ -992,7 +992,7 @@ static int tcp_status_callback(void *object, uint32_t number, uint8_t connection
TCP_con *tcp_con = get_tcp_connection(tcp_c, tcp_connections_number);
TCP_Connection_to *con_to = get_connection(tcp_c, number);
if (!con_to || !tcp_con) {
if (con_to == nullptr || tcp_con == nullptr) {
return -1;
}
@ -1075,7 +1075,7 @@ static int tcp_conn_oob_callback(void *object, const uint8_t *public_key, const
const TCP_Connection_to *con_to = get_connection(tcp_c, connections_number);
if (con_to && tcp_connection_in_conn(con_to, tcp_connections_number)) {
if (con_to != nullptr && tcp_connection_in_conn(con_to, tcp_connections_number)) {
return tcp_conn_data_callback(object, connections_number, 0, data, length, userdata);
}

View File

@ -193,7 +193,7 @@ int32_t encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key,
int32_t encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce,
const uint8_t *plain, size_t length, uint8_t *encrypted)
{
if (length == 0 || !secret_key || !nonce || !plain || !encrypted) {
if (length == 0 || secret_key == nullptr || nonce == nullptr || plain == nullptr || encrypted == nullptr) {
return -1;
}
@ -244,7 +244,8 @@ int32_t encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce,
int32_t decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce,
const uint8_t *encrypted, size_t length, uint8_t *plain)
{
if (length <= crypto_box_BOXZEROBYTES || !secret_key || !nonce || !encrypted || !plain) {
if (length <= crypto_box_BOXZEROBYTES || secret_key == nullptr || nonce == nullptr || encrypted == nullptr
|| plain == nullptr) {
return -1;
}
@ -292,7 +293,7 @@ int32_t decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce,
int32_t encrypt_data(const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *nonce,
const uint8_t *plain, size_t length, uint8_t *encrypted)
{
if (!public_key || !secret_key) {
if (public_key == nullptr || secret_key == nullptr) {
return -1;
}
@ -306,7 +307,7 @@ int32_t encrypt_data(const uint8_t *public_key, const uint8_t *secret_key, const
int32_t decrypt_data(const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *nonce,
const uint8_t *encrypted, size_t length, uint8_t *plain)
{
if (!public_key || !secret_key) {
if (public_key == nullptr || secret_key == nullptr) {
return -1;
}

View File

@ -690,7 +690,7 @@ static int addpeer(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_p
add_to_closest(g, real_pk, temp_pk);
if (do_gc_callback && g_c->peer_list_changed_callback) {
if (do_gc_callback && g_c->peer_list_changed_callback != nullptr) {
g_c->peer_list_changed_callback(g_c->m, groupnumber, userdata);
}
@ -911,7 +911,7 @@ static bool setnick(Group_Chats *g_c, uint32_t groupnumber, int peer_index, cons
g->group[peer_index].nick_len = nick_len;
if (do_gc_callback && g_c->peer_name_callback) {
if (do_gc_callback && g_c->peer_name_callback != nullptr) {
g_c->peer_name_callback(g_c->m, groupnumber, peer_index, nick, nick_len, userdata);
}
@ -1986,7 +1986,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
} else {
const Group_c *g = get_group_c(g_c, groupnumber);
if (g && g->status == GROUPCHAT_STATUS_CONNECTED) {
if (g != nullptr && g->status == GROUPCHAT_STATUS_CONNECTED) {
send_invite_response(g_c, groupnumber, friendnumber, invite_data, invite_length);
}
}
@ -3359,7 +3359,7 @@ static uint32_t conferences_section_size(const Group_Chats *g_c)
for (uint16_t i = 0; i < g_c->num_chats; ++i) {
const Group_c *g = get_group_c(g_c, i);
if (!g || g->status != GROUPCHAT_STATUS_CONNECTED) {
if (g == nullptr || g->status != GROUPCHAT_STATUS_CONNECTED) {
continue;
}
@ -3382,7 +3382,7 @@ uint8_t *conferences_save(const Group_Chats *g_c, uint8_t *data)
for (uint16_t i = 0; i < g_c->num_chats; ++i) {
const Group_c *g = get_group_c(g_c, i);
if (!g || g->status != GROUPCHAT_STATUS_CONNECTED) {
if (g == nullptr || g->status != GROUPCHAT_STATUS_CONNECTED) {
continue;
}

View File

@ -1095,7 +1095,7 @@ void kill_networking(Networking_Core *net)
bool ip_equal(const IP *a, const IP *b)
{
if (!a || !b) {
if (a == nullptr || b == nullptr) {
return false;
}
@ -1137,11 +1137,11 @@ bool ip_equal(const IP *a, const IP *b)
bool ipport_equal(const IP_Port *a, const IP_Port *b)
{
if (!a || !b) {
if (a == nullptr || b == nullptr) {
return false;
}
if (!a->port || (a->port != b->port)) {
if (a->port == 0 || (a->port != b->port)) {
return false;
}
@ -1206,7 +1206,7 @@ bool ipport_isset(const IP_Port *ipport)
/** copies an ip structure (careful about direction!) */
void ip_copy(IP *target, const IP *source)
{
if (!source || !target) {
if (source == nullptr || target == nullptr) {
return;
}
@ -1216,7 +1216,7 @@ void ip_copy(IP *target, const IP *source)
/** copies an ip_port structure (careful about direction!) */
void ipport_copy(IP_Port *target, const IP_Port *source)
{
if (!source || !target) {
if (source == nullptr || target == nullptr) {
return;
}
@ -1268,7 +1268,7 @@ const char *ip_ntoa(const IP *ip, char *ip_str, size_t length)
bool ip_parse_addr(const IP *ip, char *address, size_t length)
{
if (!address || !ip) {
if (address == nullptr || ip == nullptr) {
return false;
}
@ -1289,7 +1289,7 @@ bool ip_parse_addr(const IP *ip, char *address, size_t length)
bool addr_parse_ip(const char *address, IP *to)
{
if (!address || !to) {
if (address == nullptr || to == nullptr) {
return false;
}
@ -1318,7 +1318,7 @@ int addr_resolve(const char *address, IP *to, IP *extra)
return false;
#else
if (!address || !to) {
if (address == nullptr || to == nullptr) {
return 0;
}

View File

@ -107,7 +107,7 @@ static int ipport_unpack(IP_Port *target, const uint8_t *data, unsigned int data
*/
int create_onion_path(const DHT *dht, Onion_Path *new_path, const Node_format *nodes)
{
if (!new_path || !nodes) {
if (new_path == nullptr || nodes == nullptr) {
return -1;
}
@ -647,7 +647,7 @@ static int handle_recv_1(void *object, const IP_Port *source, const uint8_t *pac
uint16_t data_len = length - (1 + RETURN_1);
if (onion->recv_1_function &&
if (onion->recv_1_function != nullptr &&
!net_family_is_ipv4(send_to.ip.family) &&
!net_family_is_ipv6(send_to.ip.family)) {
return onion->recv_1_function(onion->callback_object, &send_to, packet + (1 + RETURN_1), data_len);

View File

@ -1805,7 +1805,7 @@ static int onion_isconnected(const Onion_Client *onion_c)
/* Consider ourselves online if we are announced to half or more nodes
* we are connected to */
if (num && announced) {
if (num != 0 && announced != 0) {
if ((num / 2) <= announced && (pnodes / 2) <= num) {
return 1;
}

View File

@ -729,7 +729,7 @@ bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t *pub
{
assert(tox != nullptr);
if (!host || !public_key) {
if (host == nullptr || public_key == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL);
return 0;
}
@ -782,7 +782,7 @@ bool tox_add_tcp_relay(Tox *tox, const char *host, uint16_t port, const uint8_t
{
assert(tox != nullptr);
if (!host || !public_key) {
if (host == nullptr || public_key == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL);
return 0;
}
@ -934,7 +934,7 @@ bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, Tox_Err_Set
{
assert(tox != nullptr);
if (!name && length != 0) {
if (name == nullptr && length != 0) {
SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL);
return 0;
}
@ -978,7 +978,7 @@ bool tox_self_set_status_message(Tox *tox, const uint8_t *status_message, size_t
{
assert(tox != nullptr);
if (!status_message && length != 0) {
if (status_message == nullptr && length != 0) {
SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL);
return 0;
}
@ -1085,7 +1085,7 @@ uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message
{
assert(tox != nullptr);
if (!address || !message) {
if (address == nullptr || message == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_ADD_NULL);
return UINT32_MAX;
}
@ -1494,7 +1494,7 @@ void tox_callback_friend_message(Tox *tox, tox_friend_message_cb *callback)
bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length)
{
if (!hash || (length && !data)) {
if (hash == nullptr || (data == nullptr && length != 0)) {
return 0;
}
@ -1655,7 +1655,7 @@ uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t
{
assert(tox != nullptr);
if (filename_length && !filename) {
if (filename == nullptr && filename_length != 0) {
SET_ERROR_PARAMETER(error, TOX_ERR_FILE_SEND_NULL);
return UINT32_MAX;
}

View File

@ -70,7 +70,7 @@ void tox_pass_key_free(Tox_Pass_Key *pass_key)
*/
bool tox_get_salt(const uint8_t *data, uint8_t *salt, Tox_Err_Get_Salt *error)
{
if (!data || !salt) {
if (data == nullptr || salt == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_GET_SALT_NULL);
return false;
}
@ -111,7 +111,7 @@ Tox_Pass_Key *tox_pass_key_derive(const uint8_t *passphrase, size_t pplength,
Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t pplength,
const uint8_t *salt, Tox_Err_Key_Derivation *error)
{
if (!salt || (!passphrase && pplength != 0)) {
if (salt == nullptr || (passphrase == nullptr && pplength != 0)) {
SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_NULL);
return nullptr;
}
@ -164,7 +164,7 @@ Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t pp
bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t *plaintext, size_t plaintext_len,
uint8_t *ciphertext, Tox_Err_Encryption *error)
{
if (plaintext_len == 0 || !plaintext || !key || !ciphertext) {
if (plaintext_len == 0 || plaintext == nullptr || key == nullptr || ciphertext == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_ENCRYPTION_NULL);
return 0;
}
@ -242,7 +242,7 @@ bool tox_pass_key_decrypt(const Tox_Pass_Key *key, const uint8_t *data, size_t l
return 0;
}
if (!data || !key || !out) {
if (data == nullptr || key == nullptr || out == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_DECRYPTION_NULL);
return 0;
}
@ -288,7 +288,7 @@ bool tox_pass_decrypt(const uint8_t *data, size_t length, const uint8_t *passphr
return 0;
}
if (!data || !passphrase || !out) {
if (data == nullptr || passphrase == nullptr || out == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_DECRYPTION_NULL);
return 0;
}