mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cleanup: Avoid implicit pointer-to-bool conversion in if
in toxav.
This commit is contained in:
parent
933c6b7517
commit
5e724d8909
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
|
@ -23,6 +23,16 @@ jobs:
|
|||
(find . -name "*.py" -and -not -name "conanfile.py"; grep -lR '^#!.*python') \
|
||||
| xargs -n1 -P8 mypy --strict
|
||||
|
||||
tokstyle:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Docker Build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
file: other/docker/tokstyle/Dockerfile
|
||||
|
||||
build-msan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
|
@ -6,13 +6,16 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
|||
gcc \
|
||||
git \
|
||||
libmsgpack-dev \
|
||||
libopus-dev \
|
||||
libsodium-dev \
|
||||
libvpx-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 toxav/ /src/workspace/c-toxcore/toxcore/
|
||||
COPY toxcore/ /src/workspace/c-toxcore/toxcore/
|
||||
COPY toxencryptsave/ /src/workspace/c-toxcore/toxencryptsave/
|
||||
RUN /bin/check-c /src/workspace/c-toxcore/toxcore/*.c
|
||||
RUN /bin/check-c $(find /src/workspace/c-toxcore -name "*.c")
|
3
other/docker/tokstyle/run
Executable file
3
other/docker/tokstyle/run
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
docker build -f other/docker/tokstyle/Dockerfile .
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
docker build -f other/docker/typecheck/Dockerfile .
|
|
@ -191,7 +191,7 @@ void ac_iterate(ACSession *ac)
|
|||
|
||||
if (rc < 0) {
|
||||
LOGGER_WARNING(ac->log, "Decoding error: %s", opus_strerror(rc));
|
||||
} else if (ac->acb) {
|
||||
} else if (ac->acb != nullptr) {
|
||||
ac->lp_frame_duration = (rc * 1000) / ac->lp_sampling_rate;
|
||||
|
||||
ac->acb(ac->av, ac->friend_number, temp_audio_buffer, rc, ac->lp_channel_count,
|
||||
|
@ -324,7 +324,7 @@ static int jbuf_write(const Logger *log, struct JitterBuffer *q, struct RTPMessa
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (q->queue[num]) {
|
||||
if (q->queue[num] != nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ static struct RTPMessage *jbuf_read(struct JitterBuffer *q, int32_t *success)
|
|||
|
||||
unsigned int num = q->bottom % q->size;
|
||||
|
||||
if (q->queue[num]) {
|
||||
if (q->queue[num] != nullptr) {
|
||||
struct RTPMessage *ret = q->queue[num];
|
||||
q->queue[num] = nullptr;
|
||||
++q->bottom;
|
||||
|
|
|
@ -110,7 +110,7 @@ static int queue(Group_JitterBuffer *q, const Mono_Time *mono_time, Group_Audio_
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (q->queue[num]) {
|
||||
if (q->queue[num] != nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ static Group_Audio_Packet *dequeue(Group_JitterBuffer *q, int *success)
|
|||
|
||||
unsigned int num = q->bottom % q->size;
|
||||
|
||||
if (q->queue[num]) {
|
||||
if (q->queue[num] != nullptr) {
|
||||
Group_Audio_Packet *ret = q->queue[num];
|
||||
q->queue[num] = nullptr;
|
||||
++q->bottom;
|
||||
|
@ -179,7 +179,7 @@ typedef struct Group_Peer_AV {
|
|||
|
||||
static void kill_group_av(Group_AV *group_av)
|
||||
{
|
||||
if (group_av->audio_encoder) {
|
||||
if (group_av->audio_encoder != nullptr) {
|
||||
opus_encoder_destroy(group_av->audio_encoder);
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ static void kill_group_av(Group_AV *group_av)
|
|||
|
||||
static int recreate_encoder(Group_AV *group_av)
|
||||
{
|
||||
if (group_av->audio_encoder) {
|
||||
if (group_av->audio_encoder != nullptr) {
|
||||
opus_encoder_destroy(group_av->audio_encoder);
|
||||
group_av->audio_encoder = nullptr;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ static void group_av_peer_delete(void *object, uint32_t groupnumber, void *peer_
|
|||
return;
|
||||
}
|
||||
|
||||
if (peer_av->audio_decoder) {
|
||||
if (peer_av->audio_decoder != nullptr) {
|
||||
opus_decoder_destroy(peer_av->audio_decoder);
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ static void group_av_peer_delete(void *object, uint32_t groupnumber, void *peer_
|
|||
|
||||
static void group_av_groupchat_delete(void *object, uint32_t groupnumber)
|
||||
{
|
||||
if (object) {
|
||||
if (object != nullptr) {
|
||||
kill_group_av((Group_AV *)object);
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint3
|
|||
}
|
||||
|
||||
if (channels != peer_av->decoder_channels) {
|
||||
if (peer_av->audio_decoder) {
|
||||
if (peer_av->audio_decoder != nullptr) {
|
||||
opus_decoder_destroy(peer_av->audio_decoder);
|
||||
peer_av->audio_decoder = nullptr;
|
||||
}
|
||||
|
@ -379,9 +379,9 @@ static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint3
|
|||
}
|
||||
}
|
||||
|
||||
if (out_audio) {
|
||||
if (out_audio != nullptr) {
|
||||
|
||||
if (group_av->audio_data) {
|
||||
if (group_av->audio_data != nullptr) {
|
||||
group_av->audio_data(group_av->tox, groupnumber, friendgroupnumber, out_audio, out_audio_samples,
|
||||
peer_av->decoder_channels, sample_rate, group_av->userdata);
|
||||
}
|
||||
|
|
10
toxav/msi.c
10
toxav/msi.c
|
@ -164,7 +164,7 @@ int msi_kill(MSISession *session, const Logger *log)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (session->calls) {
|
||||
if (session->calls != nullptr) {
|
||||
MSIMessage msg;
|
||||
msg_init(&msg, REQU_POP);
|
||||
|
||||
|
@ -625,17 +625,17 @@ static void kill_call(MSICall *call)
|
|||
MSICall *prev = call->prev;
|
||||
MSICall *next = call->next;
|
||||
|
||||
if (prev) {
|
||||
if (prev != nullptr) {
|
||||
prev->next = next;
|
||||
} else if (next) {
|
||||
} else if (next != nullptr) {
|
||||
session->calls_head = next->friend_number;
|
||||
} else {
|
||||
goto CLEAR_CONTAINER;
|
||||
}
|
||||
|
||||
if (next) {
|
||||
if (next != nullptr) {
|
||||
next->prev = prev;
|
||||
} else if (prev) {
|
||||
} else if (prev != nullptr) {
|
||||
session->calls_tail = prev->friend_number;
|
||||
} else {
|
||||
goto CLEAR_CONTAINER;
|
||||
|
|
|
@ -85,7 +85,7 @@ RingBuffer *rb_new(int size)
|
|||
|
||||
void rb_kill(RingBuffer *b)
|
||||
{
|
||||
if (b) {
|
||||
if (b != nullptr) {
|
||||
free(b->data);
|
||||
free(b);
|
||||
}
|
||||
|
|
|
@ -423,7 +423,7 @@ static int handle_video_packet(RTPSession *session, const struct RTPHeader *head
|
|||
|
||||
struct RTPMessage *m_new = process_frame(log, session->work_buffer_list, slot_id);
|
||||
|
||||
if (m_new) {
|
||||
if (m_new != nullptr) {
|
||||
LOGGER_DEBUG(log, "-- handle_video_packet -- CALLBACK-003a b0=%d b1=%d", (int)m_new->data[0], (int)m_new->data[1]);
|
||||
update_bwc_values(log, session, m_new);
|
||||
session->mcb(session->m->mono_time, session->cs, m_new);
|
||||
|
@ -498,7 +498,7 @@ static int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t
|
|||
bwc_add_recv(session->bwc, length);
|
||||
|
||||
/* Invoke processing of active multiparted message */
|
||||
if (session->mp) {
|
||||
if (session->mp != nullptr) {
|
||||
session->mcb(session->m->mono_time, session->cs, session->mp);
|
||||
session->mp = nullptr;
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ static int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t
|
|||
|
||||
/* The message is sent in multiple parts */
|
||||
|
||||
if (session->mp) {
|
||||
if (session->mp != nullptr) {
|
||||
/* There are 2 possible situations in this case:
|
||||
* 1) being that we got the part of already processing message.
|
||||
* 2) being that we got the part of a new/old message.
|
||||
|
|
|
@ -160,7 +160,7 @@ ToxAV *toxav_new(Tox *tox, Toxav_Err_New *error)
|
|||
m = *(Messenger **)tox;
|
||||
//!TOKSTYLE+
|
||||
|
||||
if (m->msi_packet) {
|
||||
if (m->msi_packet != nullptr) {
|
||||
rc = TOXAV_ERR_NEW_MULTIPLE;
|
||||
goto RETURN;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ ToxAV *toxav_new(Tox *tox, Toxav_Err_New *error)
|
|||
|
||||
RETURN:
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ void toxav_kill(ToxAV *av)
|
|||
}
|
||||
|
||||
/* Msi kill will hang up all calls so just clean these calls */
|
||||
if (av->calls) {
|
||||
if (av->calls != nullptr) {
|
||||
ToxAVCall *it = call_get(av, av->calls_head);
|
||||
|
||||
while (it) {
|
||||
|
@ -400,7 +400,7 @@ bool toxav_call(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, uint
|
|||
RETURN:
|
||||
pthread_mutex_unlock(av->mutex);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ bool toxav_answer(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, ui
|
|||
RETURN:
|
||||
pthread_mutex_unlock(av->mutex);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, Toxav_Call_Control co
|
|||
|
||||
pthread_mutex_unlock(av->mutex);
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -704,7 +704,7 @@ bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t audio_
|
|||
pthread_mutex_unlock(av->mutex);
|
||||
RETURN:
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -776,7 +776,7 @@ bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t video_
|
|||
pthread_mutex_unlock(av->mutex);
|
||||
RETURN:
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -874,7 +874,7 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc
|
|||
|
||||
RETURN:
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
|
|||
|
||||
RETURN:
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1111,7 @@ static int callback_invite(void *toxav_inst, MSICall *call)
|
|||
call->av_call = av_call;
|
||||
av_call->msi_call = call;
|
||||
|
||||
if (toxav->ccb) {
|
||||
if (toxav->ccb != nullptr) {
|
||||
toxav->ccb(toxav, call->friend_number, call->peer_capabilities & MSI_CAP_S_AUDIO,
|
||||
call->peer_capabilities & MSI_CAP_S_VIDEO, toxav->ccb_user_data);
|
||||
} else {
|
||||
|
@ -1158,7 +1158,7 @@ static int callback_end(void *toxav_inst, MSICall *call)
|
|||
|
||||
invoke_call_state_callback(toxav, call->friend_number, TOXAV_FRIEND_CALL_STATE_FINISHED);
|
||||
|
||||
if (call->av_call) {
|
||||
if (call->av_call != nullptr) {
|
||||
call_kill_transmission(call->av_call);
|
||||
call_remove(call->av_call);
|
||||
}
|
||||
|
@ -1173,7 +1173,7 @@ static int callback_error(void *toxav_inst, MSICall *call)
|
|||
|
||||
invoke_call_state_callback(toxav, call->friend_number, TOXAV_FRIEND_CALL_STATE_ERROR);
|
||||
|
||||
if (call->av_call) {
|
||||
if (call->av_call != nullptr) {
|
||||
call_kill_transmission(call->av_call);
|
||||
call_remove(call->av_call);
|
||||
}
|
||||
|
@ -1219,11 +1219,11 @@ static bool video_bit_rate_invalid(uint32_t bit_rate)
|
|||
* we may want to prevent from passing overflowed bitrates to libvpx
|
||||
* more in detail, it's the case where bit_rate is larger than uint, but smaller than uint32_t
|
||||
*/
|
||||
return bit_rate > UINT_MAX;
|
||||
return bit_rate > UINT32_MAX;
|
||||
}
|
||||
static bool invoke_call_state_callback(ToxAV *av, uint32_t friend_number, uint32_t state)
|
||||
{
|
||||
if (av->scb) {
|
||||
if (av->scb != nullptr) {
|
||||
av->scb(av, friend_number, state, av->scb_user_data);
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1315,7 +1315,7 @@ static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *er
|
|||
|
||||
RETURN:
|
||||
|
||||
if (error) {
|
||||
if (error != nullptr) {
|
||||
*error = rc;
|
||||
}
|
||||
|
||||
|
@ -1347,24 +1347,24 @@ static ToxAVCall *call_remove(ToxAVCall *call)
|
|||
/* Set av call in msi to NULL in order to know if call if ToxAVCall is
|
||||
* removed from the msi call.
|
||||
*/
|
||||
if (call->msi_call) {
|
||||
if (call->msi_call != nullptr) {
|
||||
call->msi_call->av_call = nullptr;
|
||||
}
|
||||
|
||||
pthread_mutex_destroy(call->toxav_call_mutex);
|
||||
free(call);
|
||||
|
||||
if (prev) {
|
||||
if (prev != nullptr) {
|
||||
prev->next = next;
|
||||
} else if (next) {
|
||||
} else if (next != nullptr) {
|
||||
av->calls_head = next->friend_number;
|
||||
} else {
|
||||
goto CLEAR;
|
||||
}
|
||||
|
||||
if (next) {
|
||||
if (next != nullptr) {
|
||||
next->prev = prev;
|
||||
} else if (prev) {
|
||||
} else if (prev != nullptr) {
|
||||
av->calls_tail = prev->friend_number;
|
||||
} else {
|
||||
goto CLEAR;
|
||||
|
|
|
@ -330,7 +330,7 @@ void vc_iterate(VCSession *vc)
|
|||
for (vpx_image_t *dest = vpx_codec_get_frame(vc->decoder, &iter);
|
||||
dest != nullptr;
|
||||
dest = vpx_codec_get_frame(vc->decoder, &iter)) {
|
||||
if (vc->vcb) {
|
||||
if (vc->vcb != nullptr) {
|
||||
vc->vcb(vc->av, vc->friend_number, dest->d_w, dest->d_h,
|
||||
(const uint8_t *)dest->planes[0], (const uint8_t *)dest->planes[1], (const uint8_t *)dest->planes[2],
|
||||
dest->stride[0], dest->stride[1], dest->stride[2], vc->vcb_user_data);
|
||||
|
@ -347,7 +347,7 @@ int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg)
|
|||
* this function gets called from handle_rtp_packet() and handle_rtp_packet_v3()
|
||||
*/
|
||||
if (!vcp || !msg) {
|
||||
if (msg) {
|
||||
if (msg != nullptr) {
|
||||
free(msg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user