From 77799c74da59900dd5881575f7510532ab77e81b Mon Sep 17 00:00:00 2001 From: Ghislain MARY <ghislain.mary@belledonne-communications.com> Date: Mon, 14 May 2018 16:06:07 +0200 Subject: [PATCH] Fix build with Clang 6.0. --- console/commands.c | 2 +- coreapi/lsd.c | 6 +++- coreapi/offeranswer.c | 2 +- coreapi/presence.c | 58 +++++++++++++++++++++---------- daemon/commands/register-info.cc | 6 ++-- tester/quality_reporting_tester.c | 26 ++++++++------ 6 files changed, 64 insertions(+), 36 deletions(-) diff --git a/console/commands.c b/console/commands.c index ed5462e185..3c3b502f09 100644 --- a/console/commands.c +++ b/console/commands.c @@ -2148,7 +2148,7 @@ static int lpc_cmd_speak(LinphoneCore *lc, char *args){ #ifndef _WIN32 char voice[64]; char *sentence; - char cl[128]; + char cl[256]; char wavfile[128]="/tmp/linphonec-espeak-XXXXXX"; int status; FILE *file; diff --git a/coreapi/lsd.c b/coreapi/lsd.c index f6a3b51043..b09caf4d32 100644 --- a/coreapi/lsd.c +++ b/coreapi/lsd.c @@ -222,6 +222,10 @@ void lsd_player_set_gain(LsdPlayer *p, float gain){ ms_filter_call_method(p->lsd->mixer,MS_AUDIO_MIXER_SET_INPUT_GAIN,&gainctl); } +static void lsd_player_configure_notify_func (void *userdata, MSFilter *, unsigned int, void *) { + lsd_player_configure((LsdPlayer *)userdata); +} + LinphoneSoundDaemon * linphone_sound_daemon_new(MSFactory* factory, const char *cardname, int rate, int nchannels){ int i; MSConnectionPoint mp; @@ -251,7 +255,7 @@ LinphoneSoundDaemon * linphone_sound_daemon_new(MSFactory* factory, const char * mp.pin=0; lsd_player_init(factory, &lsd->branches[0],mp,MS_ITC_SOURCE_ID,lsd); - ms_filter_add_notify_callback(lsd->branches[0].player,(MSFilterNotifyFunc)lsd_player_configure,&lsd->branches[0],FALSE); + ms_filter_add_notify_callback(lsd->branches[0].player,lsd_player_configure_notify_func,&lsd->branches[0],FALSE); for(i=1;i<MAX_BRANCHES;++i){ mp.pin=i; lsd_player_init(factory,&lsd->branches[i],mp,MS_FILE_PLAYER_ID,lsd); diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index 793f6539d7..d3e7b2ab1d 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -495,7 +495,7 @@ static void initiate_incoming(MSFactory *factory, const SalStreamDescription *lo if (remote_offer->haveZrtpHash == 1) { if (local_cap->zrtphash[0] != 0) { /* if ZRTP is available, set the zrtp hash even if it is not selected */ - strncpy((char *)(result->zrtphash), (char *)(local_cap->zrtphash), sizeof(local_cap->zrtphash)); + strncpy((char *)(result->zrtphash), (char *)(local_cap->zrtphash), sizeof(result->zrtphash)); result->haveZrtpHash = 1; } } diff --git a/coreapi/presence.c b/coreapi/presence.c index a49550991f..bf076fca54 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -124,6 +124,10 @@ static void presence_note_uninit(LinphonePresenceNote *note) { } } +static void presence_note_unref(void *note) { + linphone_presence_note_unref((LinphonePresenceNote *)note); +} + static LinphonePresenceService * presence_service_new(const char *id, LinphonePresenceBasicStatus status) { LinphonePresenceService *service = belle_sip_object_new(LinphonePresenceService); if (id != NULL) { @@ -141,10 +145,14 @@ static void presence_service_uninit(LinphonePresenceService *service) { if (service->contact != NULL) { ms_free(service->contact); } - bctbx_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(service->notes, presence_note_unref); bctbx_list_free(service->notes); }; +static void presence_service_unref(void *service) { + linphone_presence_service_unref((LinphonePresenceService *)service); +} + static void presence_service_set_timestamp(LinphonePresenceService *service, time_t timestamp) { service->timestamp = timestamp; } @@ -159,6 +167,10 @@ static void presence_activity_uninit(LinphonePresenceActivity *activity) { } } +static void presence_activity_unref(void *activity) { + linphone_presence_activity_unref((LinphonePresenceActivity *)activity); +} + static time_t parse_timestamp(const char *timestamp) { struct tm ret; time_t seconds; @@ -217,14 +229,18 @@ static void presence_person_uninit(LinphonePresencePerson *person) { if (person->id != NULL) { ms_free(person->id); } - bctbx_list_for_each(person->activities, (MSIterateFunc)linphone_presence_activity_unref); + bctbx_list_for_each(person->activities, presence_activity_unref); bctbx_list_free(person->activities); - bctbx_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(person->activities_notes, presence_note_unref); bctbx_list_free(person->activities_notes); - bctbx_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(person->notes, presence_note_unref); bctbx_list_free(person->notes); } +static void presence_person_unref(void *person) { + linphone_presence_person_unref((LinphonePresencePerson *)person); +} + static void presence_person_add_activities_note(LinphonePresencePerson *person, LinphonePresenceNote *note) { person->activities_notes = bctbx_list_append(person->activities_notes, note); } @@ -254,11 +270,11 @@ static void presence_model_find_open_basic_status(LinphonePresenceService *servi static void presence_model_uninit(LinphonePresenceModel *model) { if (model->presentity) linphone_address_unref(model->presentity); - bctbx_list_for_each(model->services, (MSIterateFunc)linphone_presence_service_unref); + bctbx_list_for_each(model->services, presence_service_unref); bctbx_list_free(model->services); - bctbx_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); + bctbx_list_for_each(model->persons, presence_person_unref); bctbx_list_free(model->persons); - bctbx_list_for_each(model->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(model->notes, presence_note_unref); bctbx_list_free(model->notes); } @@ -443,10 +459,14 @@ LinphoneStatus linphone_presence_model_add_activity(LinphonePresenceModel *model return 0; } +static void presence_person_clear_activities(void *person) { + linphone_presence_person_clear_activities((LinphonePresencePerson *)person); +} + LinphoneStatus linphone_presence_model_clear_activities(LinphonePresenceModel *model) { if (model == NULL) return -1; - bctbx_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_clear_activities); + bctbx_list_for_each(model->persons, presence_person_clear_activities); return 0; } @@ -577,16 +597,16 @@ LinphoneStatus linphone_presence_model_add_note(LinphonePresenceModel *model, co } static void clear_presence_person_notes(LinphonePresencePerson *person) { - bctbx_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(person->activities_notes, presence_note_unref); bctbx_list_free(person->activities_notes); person->activities_notes = NULL; - bctbx_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(person->notes, presence_note_unref); bctbx_list_free(person->notes); person->notes = NULL; } static void clear_presence_service_notes(LinphonePresenceService *service) { - bctbx_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(service->notes, presence_note_unref); bctbx_list_free(service->notes); service->notes = NULL; } @@ -597,7 +617,7 @@ LinphoneStatus linphone_presence_model_clear_notes(LinphonePresenceModel *model) bctbx_list_for_each(model->persons, (MSIterateFunc)clear_presence_person_notes); bctbx_list_for_each(model->services, (MSIterateFunc)clear_presence_service_notes); - bctbx_list_for_each(model->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(model->notes, presence_note_unref); bctbx_list_free(model->notes); model->notes = NULL; @@ -633,7 +653,7 @@ LinphoneStatus linphone_presence_model_add_service(LinphonePresenceModel *model, LinphoneStatus linphone_presence_model_clear_services(LinphonePresenceModel *model) { if (model == NULL) return -1; - bctbx_list_for_each(model->services, (MSIterateFunc)linphone_presence_service_unref); + bctbx_list_for_each(model->services, presence_service_unref); bctbx_list_free(model->services); model->services = NULL; return 0; @@ -659,7 +679,7 @@ LinphoneStatus linphone_presence_model_add_person(LinphonePresenceModel *model, LinphoneStatus linphone_presence_model_clear_persons(LinphonePresenceModel *model) { if (model == NULL) return -1; - bctbx_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); + bctbx_list_for_each(model->persons, presence_person_unref); bctbx_list_free(model->persons); model->persons = NULL; return 0; @@ -795,7 +815,7 @@ LinphoneStatus linphone_presence_service_add_note(LinphonePresenceService *servi LinphoneStatus linphone_presence_service_clear_notes(LinphonePresenceService *service) { if (service == NULL) return -1; - bctbx_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(service->notes, presence_note_unref); bctbx_list_free(service->notes); service->notes = NULL; return 0; @@ -856,7 +876,7 @@ LinphoneStatus linphone_presence_person_add_activity(LinphonePresencePerson *per LinphoneStatus linphone_presence_person_clear_activities(LinphonePresencePerson *person) { if (person == NULL) return -1; - bctbx_list_for_each(person->activities, (MSIterateFunc)linphone_presence_activity_unref); + bctbx_list_for_each(person->activities, presence_activity_unref); bctbx_list_free(person->activities); person->activities = NULL; return 0; @@ -881,7 +901,7 @@ LinphoneStatus linphone_presence_person_add_note(LinphonePresencePerson *person, LinphoneStatus linphone_presence_person_clear_notes(LinphonePresencePerson *person) { if (person == NULL) return -1; - bctbx_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(person->notes, presence_note_unref); bctbx_list_free(person->notes); person->notes = NULL; return 0; @@ -906,7 +926,7 @@ LinphoneStatus linphone_presence_person_add_activities_note(LinphonePresencePers LinphoneStatus linphone_presence_person_clear_activities_notes(LinphonePresencePerson *person) { if (person == NULL) return -1; - bctbx_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_for_each(person->activities_notes, presence_note_unref); bctbx_list_free(person->activities_notes); person->activities_notes = NULL; return 0; @@ -1435,7 +1455,7 @@ static int process_pidf_xml_presence_persons(xmlparsing_context_t *xml_ctx, Linp if (err < 0) { /* Remove all the persons added since there was an error. */ - bctbx_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); + bctbx_list_for_each(model->persons, presence_person_unref); } return err; } diff --git a/daemon/commands/register-info.cc b/daemon/commands/register-info.cc index 681d894e32..64ac567372 100644 --- a/daemon/commands/register-info.cc +++ b/daemon/commands/register-info.cc @@ -1,6 +1,6 @@ /* register-info.cc -Copyright (C) 2016 Belledonne Communications, Grenoble, France +Copyright (C) 2016 Belledonne Communications, Grenoble, France This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -34,12 +34,12 @@ public: ost << "Id: " << id << std::endl; ost << "Identity: " << linphone_proxy_config_get_identity(cfg) << std::endl; ost << "Proxy: " << linphone_proxy_config_get_server_addr(cfg) << std::endl; - + const char *route = linphone_proxy_config_get_route(cfg); if (route != NULL) { ost << "Route: " << route << std::endl; } - + ost << "State: " << linphone_registration_state_to_string(linphone_proxy_config_get_state(cfg)) << std::endl; setBody(ost.str()); } diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 5d3818e2ea..d466e84628 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -202,10 +202,14 @@ static void quality_reporting_not_sent_if_low_bandwidth(void) { linphone_core_manager_destroy(pauline); } -void on_report_send_remove_fields(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ - char *body = (char*)linphone_content_get_buffer(content); - /*corrupt start of the report*/ - strncpy(body, "corrupted report is corrupted", strlen("corrupted report is corrupted")); +static void on_report_send_remove_fields (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { + char *body = bctbx_strdup(linphone_content_get_string_buffer(content)); + /* Corrupt start of the report */ + const char *corrupted_str = "corrupted report is corrupted"; + size_t corrupted_len = strlen(corrupted_str); + strncpy(body, corrupted_str, corrupted_len); + linphone_content_set_string_buffer((LinphoneContent *)content, body); + bctbx_free(body); } static void quality_reporting_invalid_report(void) { @@ -324,7 +328,7 @@ static void quality_reporting_session_report_if_video_stopped(void) { BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,2,5000)); } linphone_call_params_unref(marie_params); - + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -415,7 +419,7 @@ static void quality_reporting_interval_report_video_and_rtt(void) { } linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); } - + end_call(marie, pauline); /*wait that all publish complete*/ BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,marie->stat.number_of_LinphonePublishProgress,60000)); @@ -434,30 +438,30 @@ static void video_bandwidth_estimation(void){ LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); LinphoneVideoPolicy pol = {0}; OrtpNetworkSimulatorParams simparams = { 0 }; - + linphone_core_set_video_device(marie->lc, "Mire: Mire (synthetic moving picture)"); linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, TRUE); linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, TRUE); - + pol.automatically_accept = TRUE; pol.automatically_initiate = TRUE; linphone_core_set_video_policy(marie->lc, &pol); linphone_core_set_video_policy(pauline->lc, &pol); - + linphone_core_set_preferred_video_size_by_name(marie->lc, "vga"); simparams.mode = OrtpNetworkSimulatorOutbound; simparams.enabled = TRUE; simparams.max_bandwidth = 300000; linphone_core_set_network_simulator_params(marie->lc, &simparams); - + if (BC_ASSERT_TRUE(call(marie, pauline))){ /*wait for the first TMMBR*/ BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_tmmbr_received, 1, 50000)); BC_ASSERT_GREATER((float)marie->stat.last_tmmbr_value_received, 270000.f, float, "%f"); BC_ASSERT_LOWER((float)marie->stat.last_tmmbr_value_received, 330000.f, float, "%f"); - + end_call(marie, pauline); } linphone_core_manager_destroy(marie); -- GitLab