Fix compilation warnings with stricter gcc options: -Werror -Wextra -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-shift-negative-value

This commit is contained in:
bennylp 2023-03-29 11:57:21 +07:00
parent 52fe443ea1
commit 2a69b0a5a8
5 changed files with 25 additions and 12 deletions

View File

@ -666,6 +666,15 @@ static void crc32_final(pj_crc32_context *ctx, pj_uint32_t *digest)
*digest = pj_crc32_final(ctx);
}
/* pj_md5_update() has len argument in unsigned, while other xxx_update
* are in pj_size_t, hence the wrapper
*/
static void md5_update_wrapper(pj_md5_context *ctx,
unsigned char const *buf, pj_size_t len)
{
pj_md5_update(ctx, buf, len);
}
int encryption_benchmark()
{
pj_pool_t *pool;
@ -680,7 +689,7 @@ int encryption_benchmark()
{
const char *name;
void (*init_context)(void*);
void (*update)(void*, const pj_uint8_t*, unsigned);
void (*update)(void*, const pj_uint8_t*, pj_size_t);
void (*final)(void*, void*);
pj_uint32_t t;
} algorithms[] =
@ -688,19 +697,19 @@ int encryption_benchmark()
{
"MD5 ",
(void (*)(void*))&pj_md5_init,
(void (*)(void*, const pj_uint8_t*, unsigned))&pj_md5_update,
(void (*)(void*, const pj_uint8_t*, pj_size_t))&md5_update_wrapper,
(void (*)(void*, void*))&pj_md5_final
},
{
"SHA1 ",
(void (*)(void*))&pj_sha1_init,
(void (*)(void*, const pj_uint8_t*, unsigned))&pj_sha1_update,
(void (*)(void*, const pj_uint8_t*, pj_size_t))&pj_sha1_update,
(void (*)(void*, void*))&pj_sha1_final
},
{
"CRC32",
(void (*)(void*))&pj_crc32_init,
(void (*)(void*, const pj_uint8_t*, unsigned))&crc32_update,
(void (*)(void*, const pj_uint8_t*, pj_size_t))&crc32_update,
(void (*)(void*, void*))&crc32_final
}
};

View File

@ -529,7 +529,7 @@ static int verify_strxcat(const char *cdst, const char *src, int dst_size,
int i, ret;
PJ_ASSERT_RETURN(src && strlen(cdst) <= 4, -730);
PJ_ASSERT_RETURN(strlen(cdst) < dst_size ||
PJ_ASSERT_RETURN((int)strlen(cdst) < dst_size ||
(strlen(cdst)==0 && dst_size==0), -731);
for (int ig=0; ig<sizeof(GUARDS); ++ig) {

View File

@ -449,7 +449,7 @@ static pj_status_t alsa_factory_get_dev_info(pjmedia_aud_dev_factory *f,
{
struct alsa_factory *af = (struct alsa_factory*)f;
PJ_ASSERT_RETURN(index>=0 && index<af->dev_cnt, PJ_EINVAL);
PJ_ASSERT_RETURN(index<af->dev_cnt, PJ_EINVAL);
pj_memcpy(info, &af->devs[index], sizeof(*info));
info->caps = PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |
@ -468,7 +468,7 @@ static pj_status_t alsa_factory_default_param(pjmedia_aud_dev_factory *f,
struct alsa_factory *af = (struct alsa_factory*)f;
pjmedia_aud_dev_info *adi;
PJ_ASSERT_RETURN(index>=0 && index<af->dev_cnt, PJ_EINVAL);
PJ_ASSERT_RETURN(index<af->dev_cnt, PJ_EINVAL);
adi = &af->devs[index];

View File

@ -183,8 +183,9 @@ static pj_status_t file_read3(pj_oshandle_t fd, void *data, pj_ssize_t size,
/* Normalize AVI header fields values from little-endian to host
* byte order.
*/
if (bits > 0)
if (bits > 0) {
data_to_host(data, bits, size_read);
}
if (size_read != size_to_read) {
if (psz_read)
@ -303,14 +304,15 @@ pjmedia_avi_player_create_streams(pj_pool_t *pool,
goto on_error;
/* Normalize the endian */
if (elem == sizeof(strf_video_hdr_t))
if (elem == sizeof(strf_video_hdr_t)) {
data_to_host2(&avi_hdr.strf_hdr[i],
PJ_ARRAY_SIZE(strf_video_hdr_sizes),
strf_video_hdr_sizes);
else if (elem == sizeof(strf_audio_hdr_t))
} else if (elem == sizeof(strf_audio_hdr_t)) {
data_to_host2(&avi_hdr.strf_hdr[i],
PJ_ARRAY_SIZE(strf_audio_hdr_sizes),
strf_audio_hdr_sizes);
}
/* Skip the remainder of the header */
size_to_read = avi_hdr.strl_hdr[i].list_sz - (sizeof(strl_hdr_t) -

View File

@ -440,8 +440,9 @@ PJ_DEF(void) pjsip_tpselector_add_ref(pjsip_tpselector *sel)
{
if (sel->type == PJSIP_TPSELECTOR_TRANSPORT && sel->u.transport != NULL)
pjsip_transport_add_ref(sel->u.transport);
else if (sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener != NULL)
else if (sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener != NULL) {
; /* Hmm.. looks like we don't have reference counter for listener */
}
}
@ -452,8 +453,9 @@ PJ_DEF(void) pjsip_tpselector_dec_ref(pjsip_tpselector *sel)
{
if (sel->type == PJSIP_TPSELECTOR_TRANSPORT && sel->u.transport != NULL)
pjsip_transport_dec_ref(sel->u.transport);
else if (sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener != NULL)
else if (sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener != NULL) {
; /* Hmm.. looks like we don't have reference counter for listener */
}
}