From 3a6f8976fdf1b12a649820c450dea5df1e867116 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 21 Sep 2017 16:48:05 +0200 Subject: [PATCH] cast to fix build --- coreapi/account_creator.c | 2 +- coreapi/bellesip_sal/sal_impl.c | 10 +++--- coreapi/bellesip_sal/sal_op_events.c | 2 +- coreapi/bellesip_sal/sal_op_publish.c | 2 +- coreapi/bellesip_sal/sal_op_registration.c | 2 +- coreapi/bellesip_sal/sal_sdp.c | 4 +-- coreapi/call_log.c | 2 +- coreapi/chat.c | 2 +- coreapi/ec-calibrator.c | 2 +- coreapi/enum.c | 2 +- coreapi/lime.c | 20 ++++++------ coreapi/linphonecall.c | 2 +- coreapi/linphonecore.c | 34 ++++++++++---------- coreapi/lpc2xml.c | 2 +- coreapi/message_storage.c | 4 +-- coreapi/misc.c | 4 +-- coreapi/presence.c | 20 ++++++------ coreapi/proxy.c | 22 ++++++------- coreapi/sal/sal.c | 2 +- coreapi/sipsetup.c | 2 +- coreapi/sqlite3_bctbx_vfs.c | 6 ++-- include/linphone/utils/utils.h | 4 +++ src/c-wrapper/api/c-call-params.cpp | 12 ++++---- src/chat/is-composing.cpp | 23 ++++++++------ src/chat/is-composing.h | 6 ++-- src/conference/session/media-session-p.h | 2 +- src/conference/session/media-session.cpp | 18 +++++------ src/nat/ice-agent.cpp | 4 +-- src/nat/stun-client.cpp | 4 +-- src/utils/utils.cpp | 36 ++++++++++++++++++++-- 30 files changed, 147 insertions(+), 110 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index e6902ef2b..791201466 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -45,7 +45,7 @@ static const char* ha1_for_passwd(const char* username, const char* realm, const static unsigned int validate_uri(const char* username, const char* domain, const char* display_name) { LinphoneAddress* addr; - int status = 0; + unsigned int status = 0; LinphoneProxyConfig* proxy = linphone_proxy_config_new(); linphone_proxy_config_set_identity(proxy, "sip:?@domain.com"); diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index ccdb2d197..da8ce0f7d 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -641,7 +641,7 @@ static int sal_add_listen_port(Sal *ctx, SalAddress* addr, bool_t is_tunneled){ sal_transport_to_string(sal_address_get_transport(addr))); } if (lp) { - belle_sip_listening_point_set_keep_alive(lp,ctx->keep_alive); + belle_sip_listening_point_set_keep_alive(lp,(int)ctx->keep_alive); result = belle_sip_provider_add_listening_point(ctx->prov,lp); if (sal_address_get_transport(addr)==SalTransportTLS) { set_tls_properties(ctx); @@ -716,7 +716,7 @@ void sal_set_keepalive_period(Sal *ctx,unsigned int value){ for (iterator=belle_sip_provider_get_listening_points(ctx->prov);iterator!=NULL;iterator=iterator->next) { lp=(belle_sip_listening_point_t*)iterator->data; if (ctx->use_tcp_tls_keep_alive || strcasecmp(belle_sip_listening_point_get_transport(lp),"udp")==0) { - belle_sip_listening_point_set_keep_alive(lp,ctx->keep_alive); + belle_sip_listening_point_set_keep_alive(lp,(int)ctx->keep_alive); } } } @@ -1079,7 +1079,7 @@ int sal_generate_uuid(char *uuid, size_t len) { return -1; } for (i = 0; i < 6; i++) - written+=snprintf(uuid+written,len-written,"%2.2x", uuid_struct.node[i]); + written+=snprintf(uuid+written,len-(size_t)written,"%2.2x", uuid_struct.node[i]); uuid[len-1]='\0'; return 0; } @@ -1106,7 +1106,7 @@ static void make_supported_header(Sal *sal){ const char *tag=(const char*)it->data; size_t taglen=strlen(tag); if (alltags==NULL || (written+taglen+1>=buflen)) alltags=reinterpret_cast(ms_realloc(alltags,(buflen=buflen*2))); - written+=snprintf(alltags+written,buflen-written,it->next ? "%s, " : "%s",tag); + written+=(size_t)snprintf(alltags+written,buflen-written,it->next ? "%s, " : "%s",tag); } if (alltags){ sal->supported=belle_sip_header_create("Supported",alltags); @@ -1287,7 +1287,7 @@ unsigned char * sal_get_random_bytes(unsigned char *ret, size_t size){ } char *sal_get_random_token(int size){ - return belle_sip_random_token(reinterpret_cast(ms_malloc(size)),size); + return belle_sip_random_token(reinterpret_cast(ms_malloc((size_t)size)),(size_t)size); } unsigned int sal_get_random(void){ diff --git a/coreapi/bellesip_sal/sal_op_events.c b/coreapi/bellesip_sal/sal_op_events.c index d3198fde9..ef0a2cb17 100644 --- a/coreapi/bellesip_sal/sal_op_events.c +++ b/coreapi/bellesip_sal/sal_op_events.c @@ -52,7 +52,7 @@ static void subscribe_refresher_listener (belle_sip_refresher_t* refresher if (status_code == 503) { /*refresher returns 503 for IO error*/ reason = SalReasonIOError; } - sal_error_info_set(&op->error_info, reason, "SIP", status_code,reason_phrase,NULL); + sal_error_info_set(&op->error_info, reason, "SIP", (int)status_code,reason_phrase,NULL); op->base.root->callbacks.subscribe_response(op,sss, will_retry); }else if (status_code==0){ op->base.root->callbacks.on_expire(op); diff --git a/coreapi/bellesip_sal/sal_op_publish.c b/coreapi/bellesip_sal/sal_op_publish.c index 2de596519..5907c2cd6 100644 --- a/coreapi/bellesip_sal/sal_op_publish.c +++ b/coreapi/bellesip_sal/sal_op_publish.c @@ -36,7 +36,7 @@ static void publish_refresher_listener (belle_sip_refresher_t* refresher sip_etag_string = belle_sip_header_get_unparsed_value(sip_etag); } sal_op_set_entity_tag(op, sip_etag_string); - sal_error_info_set(&op->error_info,SalReasonUnknown, "SIP", status_code,reason_phrase,NULL); + sal_error_info_set(&op->error_info,SalReasonUnknown, "SIP", (int)status_code,reason_phrase,NULL); sal_op_assign_recv_headers(op,(belle_sip_message_t*)response); op->base.root->callbacks.on_publish_response(op); } diff --git a/coreapi/bellesip_sal/sal_op_registration.c b/coreapi/bellesip_sal/sal_op_registration.c index 0bff2470d..e21e88803 100644 --- a/coreapi/bellesip_sal/sal_op_registration.c +++ b/coreapi/bellesip_sal/sal_op_registration.c @@ -32,7 +32,7 @@ static void register_refresher_listener (belle_sip_refresher_t* refresher /*only take first one for now*/ op->auth_info=sal_auth_info_create((belle_sip_auth_event_t*)(belle_sip_refresher_get_auth_events(refresher)->data)); } - sal_error_info_set(&op->error_info,SalReasonUnknown, "SIP", status_code,reason_phrase,NULL); + sal_error_info_set(&op->error_info,SalReasonUnknown, "SIP", (int)status_code,reason_phrase,NULL); if (status_code>=200){ sal_op_assign_recv_headers(op,(belle_sip_message_t*)response); } diff --git a/coreapi/bellesip_sal/sal_sdp.c b/coreapi/bellesip_sal/sal_sdp.c index c2a059d22..ab3478fb6 100644 --- a/coreapi/bellesip_sal/sal_sdp.c +++ b/coreapi/bellesip_sal/sal_sdp.c @@ -42,7 +42,7 @@ static void add_ice_candidates(belle_sdp_media_description_t *md, const SalStrea return; } if (candidate->raddr[0] != '\0') { - nb = snprintf(buffer + nb, sizeof(buffer) - nb, " raddr %s rport %d", candidate->raddr, candidate->rport); + nb = snprintf(buffer + nb, sizeof(buffer) - (size_t)nb, " raddr %s rport %d", candidate->raddr, candidate->rport); if (nb < 0) { ms_error("Cannot add ICE candidate attribute!"); return; @@ -63,7 +63,7 @@ static void add_ice_remote_candidates(belle_sdp_media_description_t *md, const S for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; i++) { candidate = &desc->ice_remote_candidates[i]; if ((candidate->addr[0] != '\0') && (candidate->port != 0)) { - offset = snprintf(ptr, buffer + sizeof(buffer) - ptr, "%s%d %s %d", (i > 0) ? " " : "", i + 1, candidate->addr, candidate->port); + offset = snprintf(ptr, (size_t)(buffer + sizeof(buffer) - ptr), "%s%d %s %d", (i > 0) ? " " : "", i + 1, candidate->addr, candidate->port); if (offset < 0) { ms_error("Cannot add ICE remote-candidates attribute!"); return; diff --git a/coreapi/call_log.c b/coreapi/call_log.c index b1c98aeab..479c0a5d6 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -137,7 +137,7 @@ bctbx_list_t * call_logs_read_from_config_file(LinphoneCore *lc){ continue; cl=linphone_call_log_new(static_cast(lp_config_get_int(cfg,logsection,"dir",0)),from,to); cl->status=static_cast(lp_config_get_int(cfg,logsection,"status",0)); - sec=lp_config_get_int64(cfg,logsection,"start_date_time",0); + sec=(uint64_t)lp_config_get_int64(cfg,logsection,"start_date_time",0); if (sec) { /*new call log format with date expressed in seconds */ cl->start_date_time=(time_t)sec; diff --git a/coreapi/chat.c b/coreapi/chat.c index 08c0af543..6d69e0788 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -162,7 +162,7 @@ void create_file_transfer_information_from_vnd_gsma_rcs_ft_http_xml(LinphoneChat while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"file-size")) { xmlChar *fileSizeString = xmlNodeListGetString(xmlMessageBody, cur->xmlChildrenNode, 1); - linphone_content_set_size(content, strtol((const char *)fileSizeString, NULL, 10)); + linphone_content_set_size(content, (size_t)strtol((const char *)fileSizeString, NULL, 10)); xmlFree(fileSizeString); } diff --git a/coreapi/ec-calibrator.c b/coreapi/ec-calibrator.c index 10578af9a..4a8ee1282 100644 --- a/coreapi/ec-calibrator.c +++ b/coreapi/ec-calibrator.c @@ -318,7 +318,7 @@ int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibration ms_error("Echo calibration is still on going !"); return -1; } - rate = lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000); + rate = (unsigned int)lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000); lc->ecc=ec_calibrator_new(lc->factory, lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,rate,cb,audio_init_cb,audio_uninit_cb,cb_data); lc->ecc->play_cool_tones = !!lp_config_get_int(lc->config, "sound", "ec_calibrator_cool_tones", 0); ec_calibrator_start(lc->ecc); diff --git a/coreapi/enum.c b/coreapi/enum.c index 9b18bc1a0..3444efbba 100644 --- a/coreapi/enum.c +++ b/coreapi/enum.c @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. static char *create_enum_domain(const char *number){ long len=(long)strlen(number); - char *domain=reinterpret_cast(ms_malloc((len*2)+10)); + char *domain=reinterpret_cast(ms_malloc((size_t)(len*2)+10)); long i,j; for (i=0,j=len-1;j>=0;j--){ diff --git a/coreapi/lime.c b/coreapi/lime.c index 35f1080db..9deb4cbdf 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -93,21 +93,21 @@ int lime_getCachedSndKeysByURI(void *cachedb, limeURIKeys_t *associatedKeys) { /* retrieve values : peerZid, sndKey, sndSId, sndIndex, valid from columns 1,2,3,4,5 */ length = sqlite3_column_bytes(sqlStmt, 1); if (length==12) { /* peerZID */ - memcpy(currentPeerKey->peerZID, sqlite3_column_blob(sqlStmt, 1), length); + memcpy(currentPeerKey->peerZID, sqlite3_column_blob(sqlStmt, 1), (size_t)length); } else { /* something wrong with that one, skip it */ continue; } length = sqlite3_column_bytes(sqlStmt, 2); if (length==32) { /* sndKey */ - memcpy(currentPeerKey->key, sqlite3_column_blob(sqlStmt, 2), length); + memcpy(currentPeerKey->key, sqlite3_column_blob(sqlStmt, 2), (size_t)length); } else { /* something wrong with that one, skip it */ continue; } length = sqlite3_column_bytes(sqlStmt, 3); if (length==32) { /* sndSId */ - memcpy(currentPeerKey->sessionId, sqlite3_column_blob(sqlStmt, 3), length); + memcpy(currentPeerKey->sessionId, sqlite3_column_blob(sqlStmt, 3), (size_t)length); } else { /* something wrong with that one, skip it */ continue; } @@ -126,14 +126,14 @@ int lime_getCachedSndKeysByURI(void *cachedb, limeURIKeys_t *associatedKeys) { length = sqlite3_column_bytes(sqlStmt, 5); if (length==8) { /* sndIndex : 8 bytes of a int64_t, stored as a blob in big endian */ uint8_t *validity = (uint8_t *)sqlite3_column_blob(sqlStmt, 5); - validityTimeSpec.tv_sec = ((uint64_t)(validity[0]))<<56 | + validityTimeSpec.tv_sec = (int64_t)(((uint64_t)(validity[0]))<<56 | ((uint64_t)(validity[1]))<<48 | ((uint64_t)(validity[2]))<<40 | ((uint64_t)(validity[3]))<<32 | ((uint64_t)(validity[4]))<<24 | ((uint64_t)(validity[5]))<<16 | ((uint64_t)(validity[6]))<<8 | - ((uint64_t)(validity[7])); + ((uint64_t)(validity[7]))); } else { /* something wrong with that one, skip it */ continue; } @@ -210,7 +210,7 @@ int lime_getCachedRcvKeyByZid(void *cachedb, limeKey_t *associatedKey, const cha /* retrieve values : rcvKey, rcvSId, rcvIndex from columns 1,2,3 */ length = sqlite3_column_bytes(sqlStmt, 1); if (length==32) { /* rcvKey */ - memcpy(associatedKey->key, sqlite3_column_blob(sqlStmt, 1), length); + memcpy(associatedKey->key, sqlite3_column_blob(sqlStmt, 1), (size_t)length); } else { /* something wrong */ sqlite3_finalize(sqlStmt); return LIME_NO_VALID_KEY_FOUND_FOR_PEER; @@ -218,7 +218,7 @@ int lime_getCachedRcvKeyByZid(void *cachedb, limeKey_t *associatedKey, const cha length = sqlite3_column_bytes(sqlStmt, 2); if (length==32) { /* rcvSId */ - memcpy(associatedKey->sessionId, sqlite3_column_blob(sqlStmt, 2), length); + memcpy(associatedKey->sessionId, sqlite3_column_blob(sqlStmt, 2), (size_t)length); } else { /* something wrong */ sqlite3_finalize(sqlStmt); return LIME_NO_VALID_KEY_FOUND_FOR_PEER; @@ -275,7 +275,7 @@ int lime_setCachedKey(void *cachedb, limeKey_t *associatedKey, uint8_t role, uin /* shall we update valid column? Enforce only when receiver, if timeSpan is 0, just ignore */ if (validityTimeSpan > 0 && role == LIME_RECEIVER) { bctbx_get_utc_cur_time(¤tTime); - bctbx_timespec_add(¤tTime, validityTimeSpan); + bctbx_timespec_add(¤tTime, (int64_t)validityTimeSpan); /* store the int64_t in big endian in the cache(cache is not typed, all data seen as blob) */ colValues[3][0] = (uint8_t)((currentTime.tv_sec>>56)&0xFF); colValues[3][1] = (uint8_t)((currentTime.tv_sec>>48)&0xFF); @@ -566,8 +566,8 @@ int lime_createMultipartMessage(void *cachedb, const char *contentType, uint8_t /* dump the whole message doc into the output */ xmlDocDumpFormatMemoryEnc(xmlOutputMessage, &local_output, &xmlStringLength, "UTF-8", 0); - *output = (uint8_t *)ms_malloc(xmlStringLength + 1); - memcpy(*output, local_output, xmlStringLength); + *output = (uint8_t *)ms_malloc((size_t)xmlStringLength + 1); + memcpy(*output, local_output, (size_t)xmlStringLength); (*output)[xmlStringLength] = '\0'; xmlFree(local_output); diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 9962d373a..6afea2b22 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -125,4 +125,4 @@ void set_playback_gain_db(AudioStream *st, float gain){ if (st->volrecv){ ms_filter_call_method(st->volrecv,MS_VOLUME_SET_DB_GAIN,&gain); }else ms_warning("Could not apply playback gain: gain control wasn't activated."); -} +} \ No newline at end of file diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index c646bfbdc..43c4520c4 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -510,8 +510,8 @@ void linphone_core_set_log_level(OrtpLogLevel loglevel) { void linphone_core_set_log_level_mask(unsigned int loglevel) { //we only have 2 domain for now ortp and belle-sip - bctbx_set_log_level_mask(ORTP_LOG_DOMAIN, loglevel); - bctbx_set_log_level_mask("bzrtp", loglevel); /*need something to set log lvel for all domains*/ + bctbx_set_log_level_mask(ORTP_LOG_DOMAIN, (int)loglevel); + bctbx_set_log_level_mask("bzrtp", (int)loglevel); /*need something to set log lvel for all domains*/ sal_set_log_level((OrtpLogLevel)loglevel); } unsigned int linphone_core_get_log_level_mask(void) { @@ -535,7 +535,7 @@ static int _open_log_collection_file_with_idx(int idx) { return -1; } - liblinphone_log_collection_file_size = statbuf.st_size; + liblinphone_log_collection_file_size = (size_t)statbuf.st_size; return 0; } @@ -623,7 +623,7 @@ static void linphone_core_log_collection_handler(const char *domain, OrtpLogLeve 1900 + lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, (int)(tp.tv_usec / 1000), lname, msg); fflush(liblinphone_log_collection_file); if (ret > 0) { - liblinphone_log_collection_file_size += ret; + liblinphone_log_collection_file_size += (size_t)ret; if (liblinphone_log_collection_file_size > liblinphone_log_collection_max_file_size) { _close_log_collection_file(); _open_log_collection_file(); @@ -945,7 +945,7 @@ static size_t get_size_of_file_to_upload(const char *filename) { fstat(fileno(output_file), &statbuf); fclose(output_file); ms_free(output_filename); - return statbuf.st_size; + return (size_t)statbuf.st_size; } void linphone_core_upload_log_collection(LinphoneCore *core) { @@ -1382,7 +1382,7 @@ static void sip_config_read(LinphoneCore *lc) { !!lp_config_get_int(lc->config,"sip","register_only_when_upnp_is_ok",1); lc->sip_conf.ping_with_options= !!lp_config_get_int(lc->config,"sip","ping_with_options",0); lc->sip_conf.auto_net_state_mon = !!lp_config_get_int(lc->config,"sip","auto_net_state_mon",1); - lc->sip_conf.keepalive_period = lp_config_get_int(lc->config,"sip","keepalive_period",10000); + lc->sip_conf.keepalive_period = (unsigned int)lp_config_get_int(lc->config,"sip","keepalive_period",10000); lc->sip_conf.tcp_tls_keepalive = !!lp_config_get_int(lc->config,"sip","tcp_tls_keepalive",0); linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0)); sal_use_one_matching_codec_policy(lc->sal, !!lp_config_get_int(lc->config,"sip","only_one_codec",0)); @@ -3161,7 +3161,7 @@ void linphone_core_iterate(LinphoneCore *lc){ if (lc->prevtime_ms == 0){ lc->prevtime_ms = curtime_ms; } - if ((diff_time=curtime_ms-lc->prevtime_ms) >= 1000){ + if ((diff_time=(int64_t)(curtime_ms-lc->prevtime_ms)) >= 1000){ one_second_elapsed=TRUE; if (diff_time>3000){ /*since monotonic time doesn't increment while machine is sleeping, we don't want to catchup too much*/ @@ -3199,7 +3199,7 @@ void linphone_core_iterate(LinphoneCore *lc){ } if (lc->ringstream && lc->ringstream_autorelease && lc->dmfs_playing_start_time!=0 - && (curtime_ms/1000 - lc->dmfs_playing_start_time)>5){ + && (curtime_ms/1000 - (uint64_t)lc->dmfs_playing_start_time)>5){ MSPlayerState state; bool_t stop=TRUE; if (lc->ringstream->source && ms_filter_call_method(lc->ringstream->source,MS_PLAYER_GET_STATE,&state)==0){ @@ -4762,8 +4762,8 @@ static void toggle_video_preview(LinphoneCore *lc, bool_t val){ if (!vdef || linphone_video_definition_is_undefined(vdef)) { vdef = linphone_core_get_preferred_video_definition(lc); } - vsize.width = linphone_video_definition_get_width(vdef); - vsize.height = linphone_video_definition_get_height(vdef); + vsize.width = (int)linphone_video_definition_get_width(vdef); + vsize.height = (int)linphone_video_definition_get_height(vdef); lc->previewstream=video_preview_new(lc->factory); video_preview_set_size(lc->previewstream,vsize); if (display_filter) @@ -5325,7 +5325,7 @@ void linphone_core_set_preferred_video_definition(LinphoneCore *lc, LinphoneVide void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize) { linphone_core_set_preferred_video_definition(lc, - linphone_factory_find_supported_video_definition(linphone_factory_get(), vsize.width, vsize.height)); + linphone_factory_find_supported_video_definition(linphone_factory_get(), (unsigned int)vsize.width, (unsigned int)vsize.height)); } void linphone_core_set_preview_video_definition(LinphoneCore *lc, LinphoneVideoDefinition *vdef) { @@ -5354,7 +5354,7 @@ void linphone_core_set_preview_video_definition(LinphoneCore *lc, LinphoneVideoD void linphone_core_set_preview_video_size(LinphoneCore *lc, MSVideoSize vsize) { linphone_core_set_preview_video_definition(lc, - linphone_factory_find_supported_video_definition(linphone_factory_get(), vsize.width, vsize.height)); + linphone_factory_find_supported_video_definition(linphone_factory_get(), (unsigned int)vsize.width, (unsigned int)vsize.height)); } const LinphoneVideoDefinition * linphone_core_get_preview_video_definition(const LinphoneCore *lc) { @@ -5363,8 +5363,8 @@ const LinphoneVideoDefinition * linphone_core_get_preview_video_definition(const MSVideoSize linphone_core_get_preview_video_size(const LinphoneCore *lc) { MSVideoSize vsize = { 0 }; - vsize.width = linphone_video_definition_get_width(lc->video_conf.preview_vdef); - vsize.height = linphone_video_definition_get_height(lc->video_conf.preview_vdef); + vsize.width = (int)linphone_video_definition_get_width(lc->video_conf.preview_vdef); + vsize.height = (int)linphone_video_definition_get_height(lc->video_conf.preview_vdef); return vsize; } @@ -5386,7 +5386,7 @@ LinphoneVideoDefinition * linphone_core_get_current_preview_video_definition(con if (lc->previewstream) { vsize = video_preview_get_current_size(lc->previewstream); } - return linphone_factory_find_supported_video_definition(linphone_factory_get(), vsize.width, vsize.height); + return linphone_factory_find_supported_video_definition(linphone_factory_get(), (unsigned int)vsize.width, (unsigned int)vsize.height); #else ms_error("Video support is disabled"); return NULL; @@ -5429,8 +5429,8 @@ const LinphoneVideoDefinition * linphone_core_get_preferred_video_definition(con MSVideoSize linphone_core_get_preferred_video_size(const LinphoneCore *lc) { MSVideoSize vsize = { 0 }; - vsize.width = linphone_video_definition_get_width(lc->video_conf.vdef); - vsize.height = linphone_video_definition_get_height(lc->video_conf.vdef); + vsize.width = (int)linphone_video_definition_get_width(lc->video_conf.vdef); + vsize.height = (int)linphone_video_definition_get_height(lc->video_conf.vdef); return vsize; } diff --git a/coreapi/lpc2xml.c b/coreapi/lpc2xml.c index 0fe709116..52f1f2dd8 100644 --- a/coreapi/lpc2xml.c +++ b/coreapi/lpc2xml.c @@ -48,7 +48,7 @@ static xmlChar* convert_iso_to_utf8(const char *in) { ms_free(out); return NULL; } else { - out = reinterpret_cast(ms_realloc(out, out_size + 1)); + out = reinterpret_cast(ms_realloc(out, (size_t)out_size + 1)); out[out_size] = '\0'; } } diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index cad03b178..ee3b9b2f8 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -209,14 +209,14 @@ static int linphone_chat_message_store_content(LinphoneChatMessage *msg) { ); linphone_sql_request(lc->db, buf); sqlite3_free(buf); - id = (unsigned int) sqlite3_last_insert_rowid (lc->db); + id = (int) sqlite3_last_insert_rowid (lc->db); } return id; } unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){ LinphoneCore *lc=linphone_chat_room_get_core(linphone_chat_message_get_chat_room(msg)); - int id = 0; + unsigned int id = 0; if (lc->db){ int content_id = -1; diff --git a/coreapi/misc.c b/coreapi/misc.c index f8c639a34..f7c0cb7bf 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -320,7 +320,7 @@ unsigned int linphone_core_get_audio_features(LinphoneCore *lc){ if (ret==AUDIO_STREAM_FEATURE_ALL){ /*since call recording is specified before creation of the stream in linphonecore, * it will be requested on demand. It is not necessary to include it all the time*/ - ret&=~AUDIO_STREAM_FEATURE_MIXED_RECORDING; + ret&=(unsigned int) ~AUDIO_STREAM_FEATURE_MIXED_RECORDING; } return ret; } @@ -640,7 +640,7 @@ const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc){ char *pos; char *nextpos; char *params; - int found=0; + unsigned long found=0; MSCryptoSuite *result=NULL; pos=tmp; do{ diff --git a/coreapi/presence.c b/coreapi/presence.c index 43c7a8ffd..e8e87f181 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -373,7 +373,7 @@ static void presence_model_get_activity(const LinphonePresencePerson *person, st if (st->current_idx != (unsigned)-1) { unsigned int size = (unsigned int)bctbx_list_size(person->activities); if (st->requested_idx < (st->current_idx + size)) { - st->activity = (LinphonePresenceActivity *)bctbx_list_nth_data(person->activities, st->requested_idx - st->current_idx); + st->activity = (LinphonePresenceActivity *)bctbx_list_nth_data(person->activities, (int)(st->requested_idx - st->current_idx)); st->current_idx = (unsigned)-1; } else { st->current_idx += size; @@ -621,7 +621,7 @@ LinphonePresenceService * linphone_presence_model_get_nth_service(const Linphone if ((model == NULL) || (idx >= linphone_presence_model_get_nb_services(model))) return NULL; - return (LinphonePresenceService *)bctbx_list_nth_data(model->services, idx); + return (LinphonePresenceService *)bctbx_list_nth_data(model->services, (int)idx); } LinphoneStatus linphone_presence_model_add_service(LinphonePresenceModel *model, LinphonePresenceService *service) { @@ -647,7 +647,7 @@ LinphonePresencePerson * linphone_presence_model_get_nth_person(const LinphonePr if ((model == NULL) || (idx >= linphone_presence_model_get_nb_persons(model))) return NULL; - return (LinphonePresencePerson *)bctbx_list_nth_data(model->persons, idx); + return (LinphonePresencePerson *)bctbx_list_nth_data(model->persons, (int)idx); } LinphoneStatus linphone_presence_model_add_person(LinphonePresenceModel *model, LinphonePresencePerson *person) { @@ -783,7 +783,7 @@ LinphonePresenceNote * linphone_presence_service_get_nth_note(const LinphonePres if ((service == NULL) || (idx >= linphone_presence_service_get_nb_notes(service))) return NULL; - return (LinphonePresenceNote *)bctbx_list_nth_data(service->notes, idx); + return (LinphonePresenceNote *)bctbx_list_nth_data(service->notes, (int)idx); } LinphoneStatus linphone_presence_service_add_note(LinphonePresenceService *service, LinphonePresenceNote *note) { @@ -844,7 +844,7 @@ unsigned int linphone_presence_person_get_nb_activities(const LinphonePresencePe LinphonePresenceActivity * linphone_presence_person_get_nth_activity(const LinphonePresencePerson *person, unsigned int idx) { if ((person == NULL) || (idx >= linphone_presence_person_get_nb_activities(person))) return NULL; - return (LinphonePresenceActivity *)bctbx_list_nth_data(person->activities, idx); + return (LinphonePresenceActivity *)bctbx_list_nth_data(person->activities, (int)idx); } LinphoneStatus linphone_presence_person_add_activity(LinphonePresencePerson *person, LinphonePresenceActivity *activity) { @@ -870,7 +870,7 @@ unsigned int linphone_presence_person_get_nb_notes(const LinphonePresencePerson LinphonePresenceNote * linphone_presence_person_get_nth_note(const LinphonePresencePerson *person, unsigned int idx) { if ((person == NULL) || (idx >= linphone_presence_person_get_nb_notes(person))) return NULL; - return (LinphonePresenceNote *)bctbx_list_nth_data(person->notes, idx); + return (LinphonePresenceNote *)bctbx_list_nth_data(person->notes, (int)idx); } LinphoneStatus linphone_presence_person_add_note(LinphonePresencePerson *person, LinphonePresenceNote *note) { @@ -895,7 +895,7 @@ unsigned int linphone_presence_person_get_nb_activities_notes(const LinphonePres LinphonePresenceNote * linphone_presence_person_get_nth_activities_note(const LinphonePresencePerson *person, unsigned int idx) { if ((person == NULL) || (idx >= linphone_presence_person_get_nb_activities_notes(person))) return NULL; - return (LinphonePresenceNote *)bctbx_list_nth_data(person->activities_notes, idx); + return (LinphonePresenceNote *)bctbx_list_nth_data(person->activities_notes, (int)idx); } LinphoneStatus linphone_presence_person_add_activities_note(LinphonePresencePerson *person, LinphonePresenceNote *note) { @@ -1275,7 +1275,7 @@ static int process_pidf_xml_presence_services(xmlparsing_context_t *xml_ctx, Lin if (service != NULL) { if (timestamp_str != NULL) presence_service_set_timestamp(service, parse_timestamp(timestamp_str)); if (contact_str != NULL) linphone_presence_service_set_contact(service, contact_str); - process_pidf_xml_presence_service_notes(xml_ctx, service, i); + process_pidf_xml_presence_service_notes(xml_ctx, service, (unsigned int)i); linphone_presence_model_add_service(model, service); linphone_presence_service_unref(service); } @@ -1415,9 +1415,9 @@ static int process_pidf_xml_presence_persons(xmlparsing_context_t *xml_ctx, Linp person = presence_person_new(person_id_str, timestamp); if (person != NULL) { - err = process_pidf_xml_presence_person_activities(xml_ctx, person, i); + err = process_pidf_xml_presence_person_activities(xml_ctx, person, (unsigned int)i); if (err == 0) { - err = process_pidf_xml_presence_person_notes(xml_ctx, person, i); + err = process_pidf_xml_presence_person_notes(xml_ctx, person, (unsigned int)i); } if (err == 0) { presence_model_add_person(model, person); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index db61462b2..ce6d4aa21 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -119,7 +119,7 @@ static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *cf cfg->reg_sendregister = lc ? !!lp_config_get_default_int(lc->config, "proxy", "reg_sendregister", 1) : 1; cfg->dial_prefix = dial_prefix ? ms_strdup(dial_prefix) : NULL; cfg->dial_escape_plus = lc ? !!lp_config_get_default_int(lc->config, "proxy", "dial_escape_plus", 0) : 0; - cfg->privacy = lc ? lp_config_get_default_int(lc->config, "proxy", "privacy", LinphonePrivacyDefault) : LinphonePrivacyDefault; + cfg->privacy = lc ? (LinphonePrivacyMask)lp_config_get_default_int(lc->config, "proxy", "privacy", LinphonePrivacyDefault) : LinphonePrivacyDefault; cfg->identity_address = identity ? linphone_address_new(identity) : NULL; cfg->reg_identity = cfg->identity_address ? linphone_address_as_string(cfg->identity_address) : NULL; cfg->reg_proxy = proxy ? ms_strdup(proxy) : NULL; @@ -1146,7 +1146,7 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC lp_config_set_int(config, key, "avpf_rr_interval", cfg->avpf_rr_interval); lp_config_set_int(config,key,"dial_escape_plus",cfg->dial_escape_plus); lp_config_set_string(config,key,"dial_prefix",cfg->dial_prefix); - lp_config_set_int(config,key,"privacy",cfg->privacy); + lp_config_set_int(config,key,"privacy",(int)cfg->privacy); if (cfg->refkey) lp_config_set_string(config,key,"refkey",cfg->refkey); lp_config_set_int(config, key, "publish_expires", cfg->publish_expires); @@ -1167,8 +1167,8 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC #define CONFIGURE_BOOL_VALUE(cfg,config,key,param,param_name) \ linphone_proxy_config_enable_##param(cfg, !!lp_config_get_int(config,key,param_name,linphone_proxy_config_##param##_enabled(cfg))); -#define CONFIGURE_INT_VALUE(cfg,config,key,param,param_name) \ - linphone_proxy_config_set_##param(cfg, !!lp_config_get_int(config,key,param_name,linphone_proxy_config_get_##param(cfg))); +#define CONFIGURE_INT_VALUE(cfg,config,key,param,param_name, param_type) \ + linphone_proxy_config_set_##param(cfg, (param_type)lp_config_get_int(config,key,param_name,(int)linphone_proxy_config_get_##param(cfg))); LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore* lc, int index) { @@ -1194,26 +1194,26 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore* lc CONFIGURE_BOOL_VALUE(cfg,config,key,quality_reporting,"quality_reporting_enabled") CONFIGURE_STRING_VALUE(cfg,config,key,quality_reporting_collector,"quality_reporting_collector") - CONFIGURE_INT_VALUE(cfg,config,key,quality_reporting_interval,"quality_reporting_interval") + CONFIGURE_INT_VALUE(cfg,config,key,quality_reporting_interval,"quality_reporting_interval",int) CONFIGURE_STRING_VALUE(cfg,config,key,contact_parameters,"contact_parameters") CONFIGURE_STRING_VALUE(cfg,config,key,contact_uri_parameters,"contact_uri_parameters") - CONFIGURE_INT_VALUE(cfg,config,key,expires,"reg_expires") + CONFIGURE_INT_VALUE(cfg,config,key,expires,"reg_expires", int) CONFIGURE_BOOL_VALUE(cfg,config,key,register,"reg_sendregister") CONFIGURE_BOOL_VALUE(cfg,config,key,publish,"publish") linphone_proxy_config_set_avpf_mode(cfg,static_cast(lp_config_get_int(config,key,"avpf",linphone_proxy_config_get_avpf_mode(cfg)))); - CONFIGURE_INT_VALUE(cfg,config,key,avpf_rr_interval,"avpf_rr_interval") - CONFIGURE_INT_VALUE(cfg,config,key,dial_escape_plus,"dial_escape_plus") + CONFIGURE_INT_VALUE(cfg,config,key,avpf_rr_interval,"avpf_rr_interval",uint8_t) + CONFIGURE_INT_VALUE(cfg,config,key,dial_escape_plus,"dial_escape_plus",bool_t) CONFIGURE_STRING_VALUE(cfg,config,key,dial_prefix,"dial_prefix") tmp=lp_config_get_string(config,key,"type",NULL); if (tmp!=NULL && strlen(tmp)>0) linphone_proxy_config_set_sip_setup(cfg,tmp); - CONFIGURE_INT_VALUE(cfg,config,key,privacy,"privacy") + CONFIGURE_INT_VALUE(cfg,config,key,privacy,"privacy",LinphonePrivacyMask) CONFIGURE_STRING_VALUE(cfg,config,key,ref_key,"refkey") - CONFIGURE_INT_VALUE(cfg,config,key,publish_expires,"publish_expires") + CONFIGURE_INT_VALUE(cfg,config,key,publish_expires,"publish_expires",int) nat_policy_ref = lp_config_get_string(config, key, "nat_policy_ref", NULL); if (nat_policy_ref != NULL) { @@ -1235,7 +1235,7 @@ static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){ ms_error("Invalid identity for this proxy configuration."); return; } - caps=sip_setup_context_get_capabilities(ssc); + caps=(unsigned int)sip_setup_context_get_capabilities(ssc); if (caps & SIP_SETUP_CAP_ACCOUNT_MANAGER){ if (sip_setup_context_login_account(ssc,cfg->reg_identity,NULL,NULL)!=0){ { diff --git a/coreapi/sal/sal.c b/coreapi/sal/sal.c index 3870e59e3..28cc29f5f 100644 --- a/coreapi/sal/sal.c +++ b/coreapi/sal/sal.c @@ -896,7 +896,7 @@ static int line_get_value(const char *input, const char *key, char *value, size_ char *equal; size_t len; if (!end) len=strlen(input); - else len=end +1 -input; + else len=(size_t)(end + 1 - input); *read=len; strncpy(line,input,MIN(len,sizeof(line))); equal=strchr(line,'='); diff --git a/coreapi/sipsetup.c b/coreapi/sipsetup.c index a1f22f7d7..fbbbd5c59 100644 --- a/coreapi/sipsetup.c +++ b/coreapi/sipsetup.c @@ -121,7 +121,7 @@ unsigned int sip_setup_get_capabilities(SipSetup *s){ } int sip_setup_context_get_capabilities(SipSetupContext *ctx){ - return ctx->funcs->capabilities; + return (int)ctx->funcs->capabilities; } LinphoneStatus sip_setup_context_create_account(SipSetupContext * ctx, const char *uri, const char *passwd, const char *email, int suscribe){ diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index e43f961e8..d4f122ee6 100755 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -77,13 +77,13 @@ static int sqlite3bctbx_Read(sqlite3_file *p, void *buf, int count, sqlite_int64 int ret; sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*) p; if (pFile){ - ret = (int)bctbx_file_read(pFile->pbctbx_file, buf, count, (off_t)offset); + ret = (int)bctbx_file_read(pFile->pbctbx_file, buf, (size_t)count, (off_t)offset); if( ret==count ){ return SQLITE_OK; } else if( ret >= 0 ){ /*fill in unread portion of buffer, as requested by sqlite3 documentation*/ - memset(((uint8_t*)buf) + ret, 0, count-ret); + memset(((uint8_t*)buf) + ret, 0, (size_t)(count-ret)); return SQLITE_IOERR_SHORT_READ; }else { @@ -106,7 +106,7 @@ static int sqlite3bctbx_Write(sqlite3_file *p, const void *buf, int count, sqlit sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*) p; int ret; if (pFile ){ - ret = (int)bctbx_file_write(pFile->pbctbx_file, buf, count, (off_t)offset); + ret = (int)bctbx_file_write(pFile->pbctbx_file, buf, (size_t)count, (off_t)offset); if(ret > 0 ) return SQLITE_OK; else { return SQLITE_IOERR_WRITE; diff --git a/include/linphone/utils/utils.h b/include/linphone/utils/utils.h index bbdeccc68..eb2ae8336 100644 --- a/include/linphone/utils/utils.h +++ b/include/linphone/utils/utils.h @@ -53,6 +53,10 @@ namespace Utils { LINPHONE_PUBLIC float stof (const std::string &str, size_t *idx = 0); LINPHONE_PUBLIC bool stob (const std::string &str); + LINPHONE_PUBLIC int stoi (const char *str, size_t *idx = 0, int base = 10); + LINPHONE_PUBLIC double stod (const char *str, size_t *idx = 0); + LINPHONE_PUBLIC float stof (const char *str, size_t *idx = 0); + LINPHONE_PUBLIC std::string stringToLower (const std::string &str); // Return a buffer allocated with new. diff --git a/src/c-wrapper/api/c-call-params.cpp b/src/c-wrapper/api/c-call-params.cpp index 4d4c35a7f..9db253605 100644 --- a/src/c-wrapper/api/c-call-params.cpp +++ b/src/c-wrapper/api/c-call-params.cpp @@ -176,8 +176,8 @@ MSVideoSize linphone_call_params_get_received_video_size (const LinphoneCallPara MSVideoSize vsize; LinphoneVideoDefinition *vdef = GET_MEDIA_CPP_PTR(params)->getReceivedVideoDefinition(); if (vdef) { - vsize.width = linphone_video_definition_get_width(vdef); - vsize.height = linphone_video_definition_get_height(vdef); + vsize.width = static_cast(linphone_video_definition_get_width(vdef)); + vsize.height = static_cast(linphone_video_definition_get_height(vdef)); } else { vsize.width = MS_VIDEO_SIZE_UNKNOWN_W; vsize.height = MS_VIDEO_SIZE_UNKNOWN_H; @@ -206,8 +206,8 @@ MSVideoSize linphone_call_params_get_sent_video_size (const LinphoneCallParams * MSVideoSize vsize; LinphoneVideoDefinition *vdef = GET_MEDIA_CPP_PTR(params)->getSentVideoDefinition(); if (vdef) { - vsize.width = linphone_video_definition_get_width(vdef); - vsize.height = linphone_video_definition_get_height(vdef); + vsize.width = static_cast(linphone_video_definition_get_width(vdef)); + vsize.height = static_cast(linphone_video_definition_get_height(vdef)); } else { vsize.width = MS_VIDEO_SIZE_UNKNOWN_W; vsize.height = MS_VIDEO_SIZE_UNKNOWN_H; @@ -457,11 +457,11 @@ void linphone_call_params_set_update_call_when_ice_completed (LinphoneCallParams } void linphone_call_params_set_sent_vsize (LinphoneCallParams *params, MSVideoSize vsize) { - GET_MEDIA_CPP_PRIVATE_PTR(params)->setSentVideoDefinition(linphone_video_definition_new(vsize.width, vsize.height, nullptr)); + GET_MEDIA_CPP_PRIVATE_PTR(params)->setSentVideoDefinition(linphone_video_definition_new(static_cast(vsize.width), static_cast(vsize.height), nullptr)); } void linphone_call_params_set_recv_vsize (LinphoneCallParams *params, MSVideoSize vsize) { - GET_MEDIA_CPP_PRIVATE_PTR(params)->setReceivedVideoDefinition(linphone_video_definition_new(vsize.width, vsize.height, nullptr)); + GET_MEDIA_CPP_PRIVATE_PTR(params)->setReceivedVideoDefinition(linphone_video_definition_new(static_cast(vsize.width), static_cast(vsize.height), nullptr)); } void linphone_call_params_set_sent_video_definition (LinphoneCallParams *params, LinphoneVideoDefinition *vdef) { diff --git a/src/chat/is-composing.cpp b/src/chat/is-composing.cpp index 09bd1ba2a..7a4560aa5 100644 --- a/src/chat/is-composing.cpp +++ b/src/chat/is-composing.cpp @@ -105,7 +105,7 @@ void IsComposing::parse (const string &text) { } void IsComposing::startIdleTimer () { - int duration = getIdleTimerDuration(); + unsigned int duration = getIdleTimerDuration(); if (!idleTimer) { idleTimer = sal_create_timer(core->sal, idleTimerExpired, this, duration * 1000, "composing idle timeout"); @@ -115,7 +115,7 @@ void IsComposing::startIdleTimer () { } void IsComposing::startRefreshTimer () { - int duration = getRefreshTimerDuration(); + unsigned int duration = getRefreshTimerDuration(); if (!refreshTimer) { refreshTimer = sal_create_timer(core->sal, refreshTimerExpired, this, duration * 1000, "composing refresh timeout"); @@ -125,9 +125,9 @@ void IsComposing::startRefreshTimer () { } void IsComposing::startRemoteRefreshTimer (const char *refreshStr) { - int duration = getRemoteRefreshTimerDuration(); + unsigned int duration = getRemoteRefreshTimerDuration(); if (refreshStr) - duration = atoi(refreshStr); + duration = static_cast(stoi(refreshStr)); if (!remoteRefreshTimer) { remoteRefreshTimer = sal_create_timer(core->sal, remoteRefreshTimerExpired, this, duration * 1000, "composing remote refresh timeout"); @@ -180,16 +180,19 @@ void IsComposing::stopRemoteRefreshTimer () { // ----------------------------------------------------------------------------- -int IsComposing::getIdleTimerDuration () { - return lp_config_get_int(core->config, "sip", "composing_idle_timeout", defaultIdleTimeout); +unsigned int IsComposing::getIdleTimerDuration () { + int idleTimerDuration = lp_config_get_int(core->config, "sip", "composing_idle_timeout", defaultIdleTimeout); + return idleTimerDuration < 0 ? 0 : static_cast(idleTimerDuration); } -int IsComposing::getRefreshTimerDuration () { - return lp_config_get_int(core->config, "sip", "composing_refresh_timeout", defaultRefreshTimeout); +unsigned int IsComposing::getRefreshTimerDuration () { + int refreshTimerDuration = lp_config_get_int(core->config, "sip", "composing_refresh_timeout", defaultRefreshTimeout); + return refreshTimerDuration < 0 ? 0 : static_cast(refreshTimerDuration); } -int IsComposing::getRemoteRefreshTimerDuration () { - return lp_config_get_int(core->config, "sip", "composing_remote_refresh_timeout", defaultRemoteRefreshTimeout); +unsigned int IsComposing::getRemoteRefreshTimerDuration () { + int remoteRefreshTimerDuration = lp_config_get_int(core->config, "sip", "composing_remote_refresh_timeout", defaultRemoteRefreshTimeout); + return remoteRefreshTimerDuration < 0 ? 0 : static_cast(remoteRefreshTimerDuration); } void IsComposing::parse (xmlparsing_context_t *xmlCtx) { diff --git a/src/chat/is-composing.h b/src/chat/is-composing.h index f9cc44d7c..d2ea49ded 100644 --- a/src/chat/is-composing.h +++ b/src/chat/is-composing.h @@ -46,9 +46,9 @@ public: void stopTimers (); private: - int getIdleTimerDuration (); - int getRefreshTimerDuration (); - int getRemoteRefreshTimerDuration (); + unsigned int getIdleTimerDuration (); + unsigned int getRefreshTimerDuration (); + unsigned int getRemoteRefreshTimerDuration (); void parse (xmlparsing_context_t *xmlCtx); int idleTimerExpired (unsigned int revents); int refreshTimerExpired (unsigned int revents); diff --git a/src/conference/session/media-session-p.h b/src/conference/session/media-session-p.h index 8a65ea4ca..fa96cf675 100644 --- a/src/conference/session/media-session-p.h +++ b/src/conference/session/media-session-p.h @@ -193,7 +193,7 @@ private: void audioStreamAuthTokenReady (const std::string &authToken, bool verified); void audioStreamEncryptionChanged (bool encrypted); uint16_t getAvpfRrInterval () const; - int getNbActiveStreams () const; + unsigned int getNbActiveStreams () const; bool isEncryptionMandatory () const; int mediaParametersChanged (SalMediaDescription *oldMd, SalMediaDescription *newMd); void propagateEncryptionChanged (); diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index b079be8b1..a3f967873 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -942,7 +942,7 @@ int MediaSessionPrivate::selectFixedPort (int streamIndex, pair portRa int MediaSessionPrivate::selectRandomPort (int streamIndex, pair portRange) { for (int nbTries = 0; nbTries < 100; nbTries++) { bool alreadyUsed = false; - int triedPort = (ortp_random() % (portRange.second - portRange.first) + portRange.first) & ~0x1; + int triedPort = (static_cast(ortp_random()) % (portRange.second - portRange.first) + portRange.first) & ~0x1; if (triedPort < portRange.first) triedPort = portRange.first + 2; for (const bctbx_list_t *elem = linphone_core_get_calls(core); elem != nullptr; elem = bctbx_list_next(elem)) { LinphoneCall *lcall = reinterpret_cast(bctbx_list_get_data(elem)); @@ -1516,7 +1516,7 @@ void MediaSessionPrivate::setupEncryptionKeys (SalMediaDescription *md) { } else { const MSCryptoSuite *suites = linphone_core_get_srtp_crypto_suites(core); for (int j = 0; (suites != nullptr) && (suites[j] != MS_CRYPTO_SUITE_INVALID) && (j < SAL_CRYPTO_ALGO_MAX); j++) { - setupEncryptionKey(&md->streams[i].crypto[j], suites[j], j + 1); + setupEncryptionKey(&md->streams[i].crypto[j], suites[j], static_cast(j) + 1); } } } @@ -2850,8 +2850,8 @@ void MediaSessionPrivate::startVideoStream (LinphoneCallState targetState) { videoStream->staticimage_webcam_fps_optimization = false; const LinphoneVideoDefinition *vdef = linphone_core_get_preferred_video_definition(core); MSVideoSize vsize; - vsize.width = linphone_video_definition_get_width(vdef); - vsize.height = linphone_video_definition_get_height(vdef); + vsize.width = static_cast(linphone_video_definition_get_width(vdef)); + vsize.height = static_cast(linphone_video_definition_get_height(vdef)); video_stream_set_sent_video_size(videoStream, vsize); video_stream_enable_self_view(videoStream, core->video_conf.selfview); if (videoWindowId) @@ -3326,7 +3326,7 @@ uint16_t MediaSessionPrivate::getAvpfRrInterval () const { return rrInterval; } -int MediaSessionPrivate::getNbActiveStreams () const { +unsigned int MediaSessionPrivate::getNbActiveStreams () const { SalMediaDescription *md = nullptr; if (op) md = sal_call_get_remote_media_description(op); @@ -3776,11 +3776,11 @@ void MediaSessionPrivate::updateCurrentParams () const { #ifdef VIDEO_ENABLED if (videoStream) { MSVideoSize vsize = video_stream_get_sent_video_size(videoStream); - vdef = linphone_video_definition_new(vsize.width, vsize.height, nullptr); + vdef = linphone_video_definition_new(static_cast(vsize.width), static_cast(vsize.height), nullptr); currentParams->getPrivate()->setSentVideoDefinition(vdef); linphone_video_definition_unref(vdef); vsize = video_stream_get_received_video_size(videoStream); - vdef = linphone_video_definition_new(vsize.width, vsize.height, nullptr); + vdef = linphone_video_definition_new(static_cast(vsize.width), static_cast(vsize.height), nullptr); currentParams->getPrivate()->setReceivedVideoDefinition(vdef); linphone_video_definition_unref(vdef); currentParams->getPrivate()->setSentFps(video_stream_get_sent_framerate(videoStream)); @@ -4350,8 +4350,8 @@ LinphoneStatus MediaSession::update (const MediaSessionParams *msp) { if (d->videoStream && (d->state == LinphoneCallStreamsRunning)) { const LinphoneVideoDefinition *vdef = linphone_core_get_preferred_video_definition(d->core); MSVideoSize vsize; - vsize.width = linphone_video_definition_get_width(vdef); - vsize.height = linphone_video_definition_get_height(vdef); + vsize.width = static_cast(linphone_video_definition_get_width(vdef)); + vsize.height = static_cast(linphone_video_definition_get_height(vdef)); video_stream_set_sent_video_size(d->videoStream, vsize); video_stream_set_fps(d->videoStream, linphone_core_get_preferred_framerate(d->core)); if (d->cameraEnabled && (d->videoStream->cam != d->core->video_conf.device)) diff --git a/src/nat/ice-agent.cpp b/src/nat/ice-agent.cpp index 63605b3bd..46c686f31 100644 --- a/src/nat/ice-agent.cpp +++ b/src/nat/ice-agent.cpp @@ -152,7 +152,7 @@ void IceAgent::prepareIceForStream (MediaStream *ms, bool createChecklist) { IceCheckList *cl = ice_session_check_list(iceSession, streamIndex); if (!cl && createChecklist) { cl = ice_check_list_new(); - ice_session_add_check_list(iceSession, cl, streamIndex); + ice_session_add_check_list(iceSession, cl, static_cast(streamIndex)); lInfo() << "Created new ICE check list for stream [" << streamIndex << "]"; } if (cl) @@ -206,7 +206,7 @@ void IceAgent::updateFromRemoteMediaDescription (const SalMediaDescription *loca IceCheckList *cl = ice_session_check_list(iceSession, i); if (!cl) continue; if (!sal_stream_description_active(stream)) { - ice_session_remove_check_list_from_idx(iceSession, i); + ice_session_remove_check_list_from_idx(iceSession, static_cast(i)); mediaSession.getPrivate()->clearIceCheckList(cl); } } diff --git a/src/nat/stun-client.cpp b/src/nat/stun-client.cpp index 9f7003fb4..b9dc162af 100644 --- a/src/nat/stun-client.cpp +++ b/src/nat/stun-client.cpp @@ -182,7 +182,7 @@ ortp_socket_t StunClient::createStunSocket (int localPort) { laddr.sin_family = AF_INET; laddr.sin_addr.s_addr = INADDR_ANY; laddr.sin_port = htons(static_cast(localPort)); - if (bind(sock, (struct sockaddr *)&laddr, sizeof(laddr)) < 0) { + if (::bind(sock, (struct sockaddr *)&laddr, sizeof(laddr)) < 0) { lError() << "Bind socket to 0.0.0.0:" << localPort << " failed: " << getSocketError(); close_socket(sock); return -1; @@ -198,7 +198,7 @@ int StunClient::recvStunResponse(ortp_socket_t sock, Candidate &candidate, int & char buf[MS_STUN_MAX_MESSAGE_SIZE]; int len = MS_STUN_MAX_MESSAGE_SIZE; - len = static_cast(recv(sock, buf, len, 0)); + len = static_cast(recv(sock, buf, static_cast(len), 0)); if (len > 0) { struct in_addr ia; MSStunMessage *resp = ms_stun_message_create_from_buffer_parsing((uint8_t *)buf, (ssize_t)len); diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index dda5139b0..877206952 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -89,7 +89,7 @@ int Utils::stoi (const string &str, size_t *idx, int base) { int v = static_cast(strtol(str.c_str(), &p, base)); if (idx) - *idx = p - str.c_str(); + *idx = static_cast(p - str.c_str()); return v; } @@ -99,7 +99,7 @@ double Utils::stod (const string &str, size_t *idx) { double v = strtod(str.c_str(), &p); if (idx) - *idx = p - str.c_str(); + *idx = static_cast(p - str.c_str()); return v; } @@ -109,7 +109,7 @@ float Utils::stof (const string &str, size_t *idx) { float v = strtof(str.c_str(), &p); if (idx) - *idx = p - str.c_str(); + *idx = static_cast(p - str.c_str()); return v; } @@ -119,6 +119,36 @@ bool Utils::stob (const string &str) { return !lowerStr.empty() && (lowerStr == "true" || lowerStr == "1"); } +int Utils::stoi (const char *str, size_t *idx, int base) { + char *p; + int v = static_cast(strtol(str, &p, base)); + + if (idx) + *idx = static_cast(p - str); + + return v; +} + +double Utils::stod (const char *str, size_t *idx) { + char *p; + double v = strtod(str, &p); + + if (idx) + *idx = static_cast(p - str); + + return v; +} + +float Utils::stof (const char *str, size_t *idx) { + char *p; + float v = strtof(str, &p); + + if (idx) + *idx = static_cast(p - str); + + return v; +} + string Utils::stringToLower (const string &str) { string result(str.size(), ' '); transform(str.cbegin(), str.cend(), result.begin(), ::tolower);