diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cddd930e..1b2135c03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,21 +282,22 @@ if(MSVC) list(APPEND STRICT_OPTIONS_CPP "/WX") endif() else() - list(APPEND STRICT_OPTIONS_CPP "\ --Wall \ --Wcast-align \ --Wconversion \ --Werror=return-type \ --Wfloat-equal \ --Winit-self \ --Wno-error=deprecated-declarations \ --Woverloaded-virtual \ --Wpointer-arith \ --Wuninitialized \ --Wunused") + list(APPEND STRICT_OPTIONS_CPP + "-Wall" + "-Wcast-align" + "-Wconversion" + "-Werror=return-type" + "-Wfloat-equal" + "-Winit-self" + "-Wno-error=deprecated-declarations" + "-Woverloaded-virtual" + "-Wpointer-arith" + "-Wuninitialized" + "-Wunused" + ) CHECK_CXX_COMPILER_FLAG("-Wsuggest-override" SUGGEST_OVERRIDE) if (SUGGEST_OVERRIDE) - list(APPEND STRICT_OPTIONS_CPP "-Wsuggest-override -Werror=suggest-override") + list(APPEND STRICT_OPTIONS_CPP "-Wsuggest-override" "-Werror=suggest-override") endif () list(APPEND STRICT_OPTIONS_C "-Wstrict-prototypes" "-Werror=strict-prototypes") if(CMAKE_C_COMPILER_ID STREQUAL "GNU") diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 1b71c03db..32833ac16 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -210,6 +210,9 @@ if(APPLE) endif() endif() +# TODO: Remove me later! +list(REMOVE_ITEM STRICT_OPTIONS_CPP "-Wconversion" "-Werror=conversion") + bc_apply_compile_flags(SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C) bc_apply_compile_flags(SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX) bc_apply_compile_flags(SOURCE_FILES_OBJC STRICT_OPTIONS_CPP STRICT_OPTIONS_OBJC) diff --git a/tester/accountmanager.c b/tester/accountmanager.c index 26ebd3f75..3fc4e265a 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -259,8 +259,8 @@ static LinphoneAddress *account_manager_check_account(AccountManager *m, Linphon void linphone_core_manager_check_accounts(LinphoneCoreManager *m){ const bctbx_list_t *it; AccountManager *am=account_manager_get(); - int logmask = linphone_core_get_log_level_mask(); - + unsigned int logmask = linphone_core_get_log_level_mask(); + if (!liblinphonetester_show_account_manager_logs) linphone_core_set_log_level_mask(ORTP_ERROR|ORTP_FATAL); for(it=linphone_core_get_proxy_config_list(m->lc);it!=NULL;it=it->next){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)it->data; diff --git a/tester/audio_bypass_tester.c b/tester/audio_bypass_tester.c index c2315d813..1d85bdbef 100644 --- a/tester/audio_bypass_tester.c +++ b/tester/audio_bypass_tester.c @@ -68,9 +68,7 @@ int audio_bypass_read_wav_header_from_fd(wave_header_t *header,int fd){ format_t *format_chunk=&header->format_chunk; data_t *data_chunk=&header->data_chunk; - unsigned long len=0; - - len = read(fd, (char*)riff_chunk, sizeof(riff_t)) ; + ssize_t len = read(fd, (char*)riff_chunk, sizeof(riff_t)) ; if (len != sizeof(riff_t)){ goto not_a_wav; } @@ -85,7 +83,7 @@ int audio_bypass_read_wav_header_from_fd(wave_header_t *header,int fd){ goto not_a_wav; } - if ((skip=le_uint32(format_chunk->len)-0x10)>0) + if ((skip=(int)le_uint32(format_chunk->len)-0x10)>0) { lseek(fd,skip,SEEK_CUR); } @@ -491,7 +489,7 @@ static void audio_bypass(void) { call_ok = call(marie, pauline); BC_ASSERT_TRUE(call_ok); if (!call_ok) goto end; - + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_used_audio_codec(linphone_call_get_current_params(linphone_core_get_current_call(marie_lc)))->mime_type, "L16"); diff --git a/tester/audio_bypass_wav_header.h b/tester/audio_bypass_wav_header.h index e82df007b..f1d75905c 100644 --- a/tester/audio_bypass_wav_header.h +++ b/tester/audio_bypass_wav_header.h @@ -26,54 +26,51 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #ifdef _WIN32 -# include -# ifndef R_OK -# define R_OK 0x2 -# endif -# ifndef W_OK -# define W_OK 0x6 -# endif -# ifndef F_OK -# define F_OK 0x0 -# endif + #include + #ifndef R_OK + #define R_OK 0x2 + #endif + #ifndef W_OK + #define W_OK 0x6 + #endif + #ifndef F_OK + #define F_OK 0x0 + #endif -# ifndef S_IRUSR -# define S_IRUSR S_IREAD -# endif + #ifndef S_IRUSR + #define S_IRUSR S_IREAD + #endif -# ifndef S_IWUSR -# define S_IWUSR S_IWRITE -# endif + #ifndef S_IWUSR + #define S_IWUSR S_IWRITE + #endif -# define open _open -# define read _read -# define write _write -# define close _close -# define access _access -# define lseek _lseek -#else /*_WIN32*/ - -# ifndef O_BINARY -# define O_BINARY 0 -# endif - -#endif /*!_WIN32*/ + #define open _open + #define read _read + #define write _write + #define close _close + #define access _access + #define lseek _lseek +#else + #ifndef O_BINARY + #define O_BINARY 0 + #endif +#endif #ifdef swap16 #else /* all integer in wav header must be read in least endian order */ -static MS2_INLINE uint16_t swap16(uint16_t a) -{ - return ((a & 0xFF) << 8) | ((a & 0xFF00) >> 8); +static MS2_INLINE uint16_t swap16(uint16_t a) { + return (uint16_t)(((a & 0xFF) << 8) | ((a & 0xFF00) >> 8)); } #endif #ifdef swap32 #else -static MS2_INLINE uint32_t swap32(uint32_t a) -{ - return ((a & 0xFF) << 24) | ((a & 0xFF00) << 8) | - ((a & 0xFF0000) >> 8) | ((a & 0xFF000000) >> 24); +static MS2_INLINE uint32_t swap32(uint32_t a) { + return (uint32_t)( + ((a & 0xFF) << 24) | ((a & 0xFF00) << 8) | ((a & 0xFF0000) >> 8) | ((a & 0xFF000000) >> 24) + ); } #endif @@ -82,9 +79,9 @@ static MS2_INLINE uint32_t swap32(uint32_t a) #define le_uint16(a) (swap16((a))) #define le_int16(a) ( (int16_t) swap16((uint16_t)((a))) ) #else -#define le_uint32(a) (a) -#define le_uint16(a) (a) -#define le_int16(a) (a) +#define le_uint32(a) ((uint32_t)(a)) +#define le_uint16(a) ((uint16_t)(a)) +#define le_int16(a) ((int16_t)(a)) #endif typedef struct _riff_t { diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index 9de93e4bb..e70ba8843 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -425,11 +425,11 @@ public: ~ConferenceEventTester (); private: - void onConferenceCreated (const Address &addr); - void onConferenceTerminated (const Address &addr); - void onParticipantAdded (const Address &addr); - void onParticipantRemoved (const Address &addr); - void onParticipantSetAdmin (const Address &addr, bool isAdmin); + void onConferenceCreated (const Address &addr) override; + void onConferenceTerminated (const Address &addr) override; + void onParticipantAdded (const Address &addr) override; + void onParticipantRemoved (const Address &addr) override; + void onParticipantSetAdmin (const Address &addr, bool isAdmin) override; public: RemoteConferenceEventHandler *handler; diff --git a/tester/message_tester.c b/tester/message_tester.c index ddbf20023..444010ec3 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -51,7 +51,7 @@ void text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const Linph } void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage* msg) { - char* from=linphone_address_as_string(linphone_chat_message_get_from(msg)); + char* from=linphone_address_as_string(linphone_chat_message_get_from_address(msg)); stats* counters; const char *text=linphone_chat_message_get_text(msg); const char *external_body_url=linphone_chat_message_get_external_body_url(msg); @@ -80,10 +80,10 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* content, const LinphoneBuffer *buffer){ FILE* file=NULL; char *receive_file = NULL; - + // If a file path is set, we should NOT call the on_recv callback ! - BC_ASSERT_PTR_NULL(msg->file_transfer_filepath); - + BC_ASSERT_PTR_NULL(linphone_chat_message_get_file_transfer_filepath(msg)); + receive_file = bc_tester_file("receive_file.dump"); if (!linphone_chat_message_get_user_data(msg)) { /*first chunk, creating file*/ @@ -112,9 +112,9 @@ LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *msg, const Linph size_t size_to_send; uint8_t *buf; FILE *file_to_send = linphone_chat_message_get_user_data(msg); - + // If a file path is set, we should NOT call the on_send callback ! - BC_ASSERT_PTR_NULL(msg->file_transfer_filepath); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_file_transfer_filepath(msg)); BC_ASSERT_PTR_NOT_NULL(file_to_send); if (file_to_send == NULL){ @@ -141,8 +141,8 @@ LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *msg, const Linph void file_transfer_progress_indication(LinphoneChatMessage *msg, const LinphoneContent* content, size_t offset, size_t total) { LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(msg); LinphoneCore *lc = linphone_chat_room_get_core(cr); - const LinphoneAddress* from_address = linphone_chat_message_get_from(msg); - const LinphoneAddress* to_address = linphone_chat_message_get_to(msg); + const LinphoneAddress* from_address = linphone_chat_message_get_from_address(msg); + const LinphoneAddress* to_address = linphone_chat_message_get_to_address(msg); char *address = linphone_chat_message_is_outgoing(msg)?linphone_address_as_string(to_address):linphone_address_as_string(from_address); stats* counters = get_stats(lc); int progress = (int)((offset * 100)/total); @@ -219,7 +219,7 @@ void compare_files(const char *path1, const char *path2) { BC_ASSERT_EQUAL(memcmp(buf1, buf2, size1), 0, int, "%d"); } BC_ASSERT_EQUAL((uint8_t)size2, (uint8_t)size1, uint8_t, "%u"); - + if (buf1) ms_free(buf1); if (buf2) ms_free(buf2); } @@ -284,7 +284,7 @@ void text_message_base(LinphoneCoreManager* marie, LinphoneCoreManager* pauline) LinphoneChatMessage* msg = linphone_chat_room_create_message(linphone_core_get_chat_room(pauline->lc,marie->identity),"Bli bli bli \n blu"); LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(msg->chat_room,msg); + linphone_chat_room_send_chat_message(linphone_chat_message_get_chat_room(msg), msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); @@ -461,7 +461,7 @@ static void text_message_with_external_body(void) { linphone_core_manager_destroy(pauline); } -void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pauline, bool_t upload_error, bool_t download_error, +void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pauline, bool_t upload_error, bool_t download_error, bool_t use_file_body_handler_in_upload, bool_t use_file_body_handler_in_download, bool_t download_from_history) { char *send_filepath = bc_tester_res("sounds/sintel_trailer_opus_h264.mkv"); char *receive_filepath = bc_tester_file("receive_file.dump"); @@ -472,7 +472,7 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau /* Remove any previously downloaded file */ remove(receive_filepath); - + /* Globally configure an http file transfer server. */ linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php"); @@ -485,7 +485,7 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau } else { msg = create_message_from_sintel_trailer(chat_room); } - + linphone_chat_room_send_chat_message(chat_room,msg); if (upload_error) { @@ -570,7 +570,7 @@ end: bc_free(receive_filepath); } -void transfer_message_base(bool_t upload_error, bool_t download_error, bool_t use_file_body_handler_in_upload, +void transfer_message_base(bool_t upload_error, bool_t download_error, bool_t use_file_body_handler_in_upload, bool_t use_file_body_handler_in_download, bool_t download_from_history) { if (transport_supported(LinphoneTransportTls)) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); @@ -724,7 +724,7 @@ static void file_transfer_2_messages_simultaneously(void) { /* Remove any previously downloaded file */ remove(receive_filepath); - + /* Globally configure an http file transfer server. */ linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php"); @@ -1343,7 +1343,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st char *send_filepath = bc_tester_res("sounds/sintel_trailer_opus_h264.mkv"); char *receive_filepath = bc_tester_file("receive_file.dump"); MSList * msg_list = NULL; - + /* Remove any previously downloaded file */ remove(receive_filepath); @@ -1371,7 +1371,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st msg = create_message_from_sintel_trailer(linphone_core_get_chat_room(pauline->lc, marie->identity)); } - linphone_chat_room_send_chat_message(msg->chat_room, msg); + linphone_chat_room_send_chat_message(linphone_chat_message_get_chat_room(msg), msg); BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1, 60000)); if (marie->stat.last_received_chat_message ) { LinphoneChatMessage *recv_msg; @@ -1395,12 +1395,12 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st BC_ASSERT_PTR_NOT_NULL(linphone_content_get_key(content)); else BC_ASSERT_PTR_NULL(linphone_content_get_key(content)); - + if (use_file_body_handler_in_download) { linphone_chat_message_set_file_transfer_filepath(recv_msg, receive_filepath); } linphone_chat_message_download_file(recv_msg); - + if (BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1,55000))) { compare_files(send_filepath, receive_filepath); } @@ -1467,7 +1467,7 @@ static void lime_cache_migration(void) { linphone_proxy_config_edit(cfg); linphone_address_set_display_name(new_identity,"what about if we have a display name ?"); linphone_proxy_config_set_identity_address(cfg, new_identity); - + linphone_proxy_config_done(cfg); if (!linphone_core_lime_available(marie->lc)) { @@ -1485,7 +1485,7 @@ static void lime_cache_migration(void) { linphone_core_set_zrtp_secrets_file(marie->lc, xmlCache_filepath); /*short check*/ limeKey_t associatedKey={0}; - + char * selfURI = linphone_address_as_string_uri_only(new_identity); linphone_address_unref(new_identity); bctbx_str_to_uint8(associatedKey.peerZID, (const uint8_t *)"0987654321fedcba5a5a5a5a", (uint16_t)strlen("0987654321fedcba5a5a5a5a")); @@ -1849,7 +1849,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo BC_ASSERT_PTR_NOT_NULL(marie->lc->db); BC_ASSERT_PTR_NOT_NULL(pauline->lc->db); #endif - + if (do_not_store_rtt_messages_in_sql_storage) { lp_config_set_int(marie->lc->config, "misc", "store_rtt_messages", 0); lp_config_set_int(pauline->lc->config, "misc", "store_rtt_messages", 0); @@ -1942,8 +1942,8 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo } marie_msg = (LinphoneChatMessage *)marie_messages->data; pauline_msg = (LinphoneChatMessage *)pauline_messages->data; - BC_ASSERT_STRING_EQUAL(marie_msg->message, message); - BC_ASSERT_STRING_EQUAL(pauline_msg->message, message); + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(marie_msg), message); + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(pauline_msg), message); bctbx_list_free_with_data(marie_messages, (void (*)(void *))linphone_chat_message_unref); bctbx_list_free_with_data(pauline_messages, (void (*)(void *))linphone_chat_message_unref); } @@ -2194,7 +2194,7 @@ static void real_time_text_message_accented_chars(void) { linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); - BC_ASSERT_EQUAL(strcmp(marie->stat.last_received_chat_message->message, "ãæçéîøùÿ"), 0, int, "%i"); + BC_ASSERT_EQUAL(strcmp(linphone_chat_message_get_text(marie->stat.last_received_chat_message), "ãæçéîøùÿ"), 0, int, "%i"); } end_call(marie, pauline); } @@ -2283,13 +2283,13 @@ void chat_message_custom_headers(void) { BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1)); - + if (marie->stat.last_received_chat_message) { const char *header = linphone_chat_message_get_custom_header(marie->stat.last_received_chat_message, "Test2"); BC_ASSERT_STRING_EQUAL(header, "Value2"); header = linphone_chat_message_get_custom_header(marie->stat.last_received_chat_message, "Test1"); BC_ASSERT_PTR_NULL(header); - BC_ASSERT_STRING_EQUAL(marie->stat.last_received_chat_message->message, "Lorem Ipsum"); + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(marie->stat.last_received_chat_message), "Lorem Ipsum"); } linphone_core_manager_destroy(marie); @@ -2402,12 +2402,12 @@ void im_encryption_engine_b64(void) { LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneImEncryptionEngine *pauline_imee = linphone_im_encryption_engine_new(); LinphoneImEncryptionEngineCbs *pauline_cbs = linphone_im_encryption_engine_get_callbacks(pauline_imee); - + linphone_im_encryption_engine_cbs_set_process_incoming_message(marie_cbs, im_encryption_engine_process_incoming_message_cb); linphone_im_encryption_engine_cbs_set_process_outgoing_message(marie_cbs, im_encryption_engine_process_outgoing_message_cb); linphone_im_encryption_engine_cbs_set_process_incoming_message(pauline_cbs, im_encryption_engine_process_incoming_message_cb); linphone_im_encryption_engine_cbs_set_process_outgoing_message(pauline_cbs, im_encryption_engine_process_outgoing_message_cb); - + linphone_core_set_im_encryption_engine(marie->lc, marie_imee); linphone_core_set_im_encryption_engine(pauline->lc, pauline_imee); @@ -2420,7 +2420,7 @@ void im_encryption_engine_b64(void) { BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(marie->stat.last_received_chat_message), "Bla bla bla bla"); } BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); - + linphone_im_encryption_engine_unref(marie_imee); linphone_im_encryption_engine_unref(pauline_imee); linphone_core_manager_destroy(marie);