Hello, lately a PJSIP 2.2.1 release compiling revealed lots of compiler warnings about unsigned int comparisons '>= 0' being always true and '< 0' being always false (from what I understand, this is like writing "if (1) {}" and "if (0) {}" respectively). Looking at the code it doesn't look like this was always intended. Attached are some findings, maybe of general interest. :-) (Largely the behaviour of pjsip seems to be unaffected regarding the attached changes; the assert-statements which weren't triggered before, aren't triggered now etc.) (P.S. There are lots of warnings related to 'mixing unsigned and signed' datatypes in comparisons, these I didn't even count.) Eeri Kask -------------- next part -------------- ../make_qmake.sh: executing make_orig_diff --- ./pjlib/src/pj/os_core_unix.c.orig 2014-06-11 13:28:49.000000000 +0200 +++ ./pjlib/src/pj/os_core_unix.c 2014-06-11 13:45:14.000000000 +0200 @@ -1747,8 +1747,8 @@ event->threads_to_release = 0; event->state = EV_STATE_OFF; } else { + pj_assert(event->threads_to_release > 0); event->threads_to_release--; - pj_assert(event->threads_to_release >= 0); if (event->threads_to_release==0) event->state = EV_STATE_OFF; } --- ./pjlib/src/pj/os_error_win32.c.orig 2014-06-11 13:41:18.000000000 +0200 +++ ./pjlib/src/pj/os_error_win32.c 2014-06-11 13:49:00.000000000 +0200 @@ -146,7 +146,7 @@ PJ_DECL_UNICODE_TEMP_BUF(wbuf,128); pj_assert(buf != NULL); - pj_assert(bufsize >= 0); + pj_assert(bufsize > 0); /* * MUST NOT check stack here. @@ -210,7 +210,7 @@ if (!len) { len = pj_ansi_snprintf( buf, bufsize, "Win32 error code %u", (unsigned)os_errcode); - if (len < 0 || len >= (int)bufsize) + if ((int)len < 0 || len >= bufsize) len = bufsize-1; buf[len] = '\0'; } --- ./pjmedia/src/pjmedia/avi_player.c.orig 2014-06-11 14:32:56.000000000 +0200 +++ ./pjmedia/src/pjmedia/avi_player.c 2014-06-11 14:33:31.000000000 +0200 @@ -539,7 +539,7 @@ unsigned idx) { pj_assert(streams); - return (idx >=0 && idx < streams->num_streams ? + return ((int)idx >=0 && idx < streams->num_streams ? streams->streams[idx] : NULL); } --- ./pjmedia/src/pjmedia/codec.c.orig 2014-06-11 14:00:03.000000000 +0200 +++ ./pjmedia/src/pjmedia/codec.c 2014-06-11 14:01:56.000000000 +0200 @@ -294,7 +294,7 @@ { unsigned i; - PJ_ASSERT_RETURN(mgr && p_info && pt>=0 && pt < 96, PJ_EINVAL); + PJ_ASSERT_RETURN(mgr && p_info && (int)pt>=0 && (int)pt < 96, PJ_EINVAL); pj_mutex_lock(mgr->mutex); --- ./pjmedia/src/pjmedia/jbuf.c.orig 2014-06-11 14:00:25.000000000 +0200 +++ ./pjmedia/src/pjmedia/jbuf.c 2014-06-11 14:02:20.000000000 +0200 @@ -630,8 +630,8 @@ pjmedia_jb_discard_algo algo) { PJ_ASSERT_RETURN(jb, PJ_EINVAL); - PJ_ASSERT_RETURN(algo >= PJMEDIA_JB_DISCARD_NONE && - algo <= PJMEDIA_JB_DISCARD_PROGRESSIVE, + PJ_ASSERT_RETURN((int)algo >= PJMEDIA_JB_DISCARD_NONE && + (int)algo <= PJMEDIA_JB_DISCARD_PROGRESSIVE, PJ_EINVAL); switch(algo) { --- ./pjmedia/src/pjmedia/sdp_neg.c.orig 2014-06-11 14:00:43.000000000 +0200 +++ ./pjmedia/src/pjmedia/sdp_neg.c 2014-06-11 14:02:57.000000000 +0200 @@ -84,7 +84,7 @@ */ PJ_DEF(const char*) pjmedia_sdp_neg_state_str(pjmedia_sdp_neg_state state) { - if (state >=0 && state < (pjmedia_sdp_neg_state)PJ_ARRAY_SIZE(state_str)) + if ((int)state >=0 && (int)state < (pjmedia_sdp_neg_state)PJ_ARRAY_SIZE(state_str)) return state_str[state]; return "<?UNKNOWN?>"; --- ./pjmedia/src/pjmedia/vid_codec_util.c.orig 2014-06-11 14:33:50.000000000 +0200 +++ ./pjmedia/src/pjmedia/vid_codec_util.c 2014-06-11 14:34:10.000000000 +0200 @@ -399,7 +399,7 @@ return status; } else if (pj_stricmp(&fmtp->param[i].name, &PACKETIZATION_MODE)==0) { tmp = pj_strtoul(&fmtp->param[i].val); - if (tmp >= 0 && tmp <= 2) + if ((int)tmp >= 0 && tmp <= 2) h264_fmtp->packetization_mode = (pj_uint8_t)tmp; else return PJMEDIA_SDP_EINFMTP; --- ./pjmedia/src/pjmedia-videodev/videodev.c.orig 2014-06-11 14:07:06.000000000 +0200 +++ ./pjmedia/src/pjmedia-videodev/videodev.c 2014-06-11 14:07:35.000000000 +0200 @@ -608,7 +608,7 @@ unsigned local_idx, pjmedia_vid_dev_index *pid) { - PJ_ASSERT_RETURN(f->sys.drv_idx >= 0 && f->sys.drv_idx < MAX_DRIVERS, + PJ_ASSERT_RETURN((int)f->sys.drv_idx >= 0 && (int)f->sys.drv_idx < MAX_DRIVERS, PJ_EINVALIDOP); *pid = local_idx; return make_global_index(f->sys.drv_idx, pid); --- ./pjnath/src/pjnath/ice_strans.c.orig 2014-06-11 13:53:46.000000000 +0200 +++ ./pjnath/src/pjnath/ice_strans.c 2014-06-11 13:55:20.000000000 +0200 @@ -851,7 +851,7 @@ * type priority to ICE session so that SRFLX candidates will get * checked first. */ - if (ice_st->comp[0]->default_cand >= 0 && + if ((int)ice_st->comp[0]->default_cand >= 0 && ice_st->comp[0]->cand_list[ice_st->comp[0]->default_cand].type == PJ_ICE_CAND_TYPE_SRFLX) { @@ -1040,7 +1040,7 @@ pj_memcpy(cand, valid_pair->lcand, sizeof(pj_ice_sess_cand)); } else { pj_ice_strans_comp *comp = ice_st->comp[comp_id - 1]; - pj_assert(comp->default_cand>=0 && comp->default_cand<comp->cand_cnt); + pj_assert((int)comp->default_cand>=0 && comp->default_cand<comp->cand_cnt); pj_memcpy(cand, &comp->cand_list[comp->default_cand], sizeof(pj_ice_sess_cand)); } --- ./pjnath/src/pjnath/nat_detect.c.orig 2014-06-11 13:54:01.000000000 +0200 +++ ./pjnath/src/pjnath/nat_detect.c 2014-06-11 13:56:42.000000000 +0200 @@ -140,7 +140,7 @@ */ PJ_DEF(const char*) pj_stun_get_nat_name(pj_stun_nat_type type) { - PJ_ASSERT_RETURN(type >= 0 && type <= PJ_STUN_NAT_TYPE_PORT_RESTRICTED, + PJ_ASSERT_RETURN((int)type >= 0 && (int)type <= PJ_STUN_NAT_TYPE_PORT_RESTRICTED, "*Invalid*"); return nat_type_names[type]; --- ./pjsip/src/pjsip/sip_transport_udp.c.orig 2014-06-11 14:19:09.000000000 +0200 +++ ./pjsip/src/pjsip/sip_transport_udp.c 2014-06-11 14:19:34.000000000 +0200 @@ -173,7 +173,7 @@ pjsip_tpmgr_receive_packet(rdata->tp_info.transport->tpmgr, rdata); - if (size_eaten < 0) { + if ((int)size_eaten < 0) { pj_assert(!"It shouldn't happen!"); size_eaten = rdata->pkt_info.len; } --- ./pjsip/src/pjsip-ua/sip_inv.c.orig 2014-06-11 14:21:51.000000000 +0200 +++ ./pjsip/src/pjsip-ua/sip_inv.c 2014-06-11 14:23:26.000000000 +0200 @@ -761,8 +761,8 @@ */ PJ_DEF(const char *) pjsip_inv_state_name(pjsip_inv_state state) { - PJ_ASSERT_RETURN(state >= PJSIP_INV_STATE_NULL && - state <= PJSIP_INV_STATE_DISCONNECTED, + PJ_ASSERT_RETURN((int)state >= PJSIP_INV_STATE_NULL && + (int)state <= PJSIP_INV_STATE_DISCONNECTED, "??"); return inv_state_names[state]; --- ./pjsip/src/pjsip-ua/sip_reg.c.orig 2014-06-11 14:22:19.000000000 +0200 +++ ./pjsip/src/pjsip-ua/sip_reg.c 2014-06-11 14:25:08.000000000 +0200 @@ -213,7 +213,7 @@ info->next_reg = 0; else if (regc->auto_reg == 0) info->next_reg = 0; - else if (regc->expires < 0) + else if ((int)regc->expires < 0) info->next_reg = regc->expires; else { pj_time_val now, next_reg;