From 51d5589edf03ae07ca45f734c7a329cc1355c1ad Mon Sep 17 00:00:00 2001 From: Ghislain MARY 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 | 4 +-- tester/quality_reporting_tester.c | 4 ++- tester/tools/private-access.h | 4 +-- 7 files changed, 53 insertions(+), 27 deletions(-) diff --git a/console/commands.c b/console/commands.c index e7cd39bb4..f8334b79e 100644 --- a/console/commands.c +++ b/console/commands.c @@ -2150,7 +2150,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 f6a3b5104..b09caf4d3 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;ibranches[i],mp,MS_FILE_PLAYER_ID,lsd); diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index 3644d9bcc..d76f1c68e 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -498,7 +498,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 709d45a3f..bb4ffa087 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -126,6 +126,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) { @@ -143,10 +147,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; } @@ -161,6 +169,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; @@ -219,14 +231,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); } @@ -256,11 +272,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); } @@ -446,10 +462,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; } @@ -580,16 +600,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; } @@ -600,7 +620,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; @@ -636,7 +656,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; @@ -662,7 +682,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; @@ -798,7 +818,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; @@ -859,7 +879,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; @@ -884,7 +904,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; @@ -909,7 +929,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; @@ -1438,7 +1458,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 5b39259e5..da1cb58d7 100644 --- a/daemon/commands/register-info.cc +++ b/daemon/commands/register-info.cc @@ -95,10 +95,10 @@ void RegisterInfoCommand::exec(Daemon *app, const string& args) { int id; try { id = atoi(param.c_str()); - } catch (invalid_argument) { + } catch (invalid_argument&) { app->sendResponse(Response("Invalid ID.", Response::Error)); return; - } catch (out_of_range) { + } catch (out_of_range&) { app->sendResponse(Response("Out of range ID.", Response::Error)); return; } diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 6870791a8..1cd5ef8df 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -207,7 +207,9 @@ static void quality_reporting_not_sent_if_low_bandwidth (void) { 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 */ - strncpy(body, "corrupted report is corrupted", strlen("corrupted report is corrupted")); + 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); } diff --git a/tester/tools/private-access.h b/tester/tools/private-access.h index 79e0f9429..6f49adc09 100644 --- a/tester/tools/private-access.h +++ b/tester/tools/private-access.h @@ -38,7 +38,7 @@ #define L_ENABLE_ATTR_ACCESS(CLASS, ATTR_TYPE, ATTR_NAME) \ template \ struct L_INTERNAL_STRUCT_L_ATTR_GET(CLASS, ATTR_NAME) { \ - friend constexpr ATTR_TYPE (CLASS::*get(AttrSpy *)) { \ + friend constexpr ATTR_TYPE CLASS::*get(AttrSpy *) { \ return Attr; \ } \ }; \ @@ -46,7 +46,7 @@ struct L_INTERNAL_STRUCT_ATTR_SPY(ATTR_NAME); \ template<> \ struct L_INTERNAL_STRUCT_ATTR_SPY(ATTR_NAME) { \ - friend constexpr ATTR_TYPE (CLASS::*get(L_INTERNAL_STRUCT_ATTR_SPY(ATTR_NAME) *)); \ + friend constexpr ATTR_TYPE CLASS::*get(L_INTERNAL_STRUCT_ATTR_SPY(ATTR_NAME) *); \ }; \ template struct L_INTERNAL_STRUCT_L_ATTR_GET(CLASS, ATTR_NAME)< \ L_INTERNAL_STRUCT_ATTR_SPY(ATTR_NAME), \