From 82b3926b988c3e9f5957d62bc0a75d34ef0ccce8 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 26 Mar 2024 00:08:27 +0200 Subject: [PATCH] Replace NULL with nullptr --- include/call.hpp | 6 +- include/logger.hpp | 2 +- include/sipp.hpp | 24 ++-- include/socket.hpp | 2 +- src/actions.cpp | 90 ++++++------- src/auth.cpp | 38 +++--- src/call.cpp | 188 ++++++++++++++-------------- src/call_generation_task.cpp | 6 +- src/infile.cpp | 8 +- src/jlsrtp.cpp | 40 +++--- src/listener.cpp | 5 +- src/logger.cpp | 8 +- src/message.cpp | 12 +- src/ratetask.cpp | 4 +- src/reporttask.cpp | 8 +- src/rtpstream.cpp | 236 +++++++++++++++++------------------ src/scenario.cpp | 62 ++++----- src/screen.cpp | 6 +- src/sip_parser.cpp | 38 +++--- src/sipp.cpp | 156 +++++++++++------------ src/sipp_unittest.cpp | 2 +- src/socket.cpp | 78 ++++++------ src/socketowner.cpp | 4 +- src/sslsocket.cpp | 26 ++-- src/stat.cpp | 100 +++++++-------- src/strings.cpp | 14 +-- src/task.cpp | 2 +- src/variables.cpp | 26 ++-- src/xp_parser_ut.cpp | 6 +- 29 files changed, 598 insertions(+), 599 deletions(-) diff --git a/include/call.hpp b/include/call.hpp index 723d97ac9..f5fa0728e 100644 --- a/include/call.hpp +++ b/include/call.hpp @@ -84,7 +84,7 @@ class call : virtual public task, virtual public listener, public virtual socket virtual ~call(); - virtual bool process_incoming(const char* msg, const struct sockaddr_storage* src = NULL); + virtual bool process_incoming(const char* msg, const struct sockaddr_storage* src = nullptr); virtual bool process_twinSippCom(char* msg); virtual bool run(); @@ -273,9 +273,9 @@ class call : virtual public task, virtual public listener, public virtual socket double get_rhs(CAction *currentAction); // P_index use for message index in scenario - char* createSendingMessage(SendingMessage* src, int P_index=-1, int *msgLen=NULL); + char* createSendingMessage(SendingMessage* src, int P_index=-1, int *msgLen=nullptr); char* createSendingMessage(char* src, int P_index, bool skip_sanity=false); - char* createSendingMessage(SendingMessage*src, int P_index, char *msg_buffer, int buflen, int *msgLen=NULL); + char* createSendingMessage(SendingMessage*src, int P_index, char *msg_buffer, int buflen, int *msgLen=nullptr); // method for the management of unexpected messages bool checkInternalCmd(char* cmd); // check of specific internal command diff --git a/include/logger.hpp b/include/logger.hpp index 798c54da5..a0b687939 100644 --- a/include/logger.hpp +++ b/include/logger.hpp @@ -66,7 +66,7 @@ void log_off(struct logfile_info *lfi); #ifdef GLOBALS_FULL_DEFINITION #define LOGFILE(name, s, check) \ - struct logfile_info name = { s, check, NULL, 0, NULL, "", true, false, 0, 0 } + struct logfile_info name = { s, check, nullptr, 0, nullptr, "", true, false, 0, 0 } #else #define LOGFILE(name, s, check) \ extern struct logfile_info name diff --git a/include/sipp.hpp b/include/sipp.hpp index fb979760a..85543a0db 100644 --- a/include/sipp.hpp +++ b/include/sipp.hpp @@ -323,24 +323,24 @@ MAYBE_EXTERN double tls_version DEFVAL(0.0); #endif #ifdef SO_BINDTODEVICE -MAYBE_EXTERN const char * bind_to_device_name DEFVAL(NULL); +MAYBE_EXTERN const char * bind_to_device_name DEFVAL(nullptr); #endif -MAYBE_EXTERN char* scenario_file DEFVAL(NULL); -MAYBE_EXTERN char* scenario_path DEFVAL(NULL); +MAYBE_EXTERN char* scenario_file DEFVAL(nullptr); +MAYBE_EXTERN char* scenario_path DEFVAL(nullptr); // extern field file management typedef std::map file_map; MAYBE_EXTERN file_map inFiles; typedef std::map file_index; -MAYBE_EXTERN char *ip_file DEFVAL(NULL); -MAYBE_EXTERN char *default_file DEFVAL(NULL); +MAYBE_EXTERN char *ip_file DEFVAL(nullptr); +MAYBE_EXTERN char *default_file DEFVAL(nullptr); // free user id list MAYBE_EXTERN std::list freeUsers; MAYBE_EXTERN std::list retiredUsers; -MAYBE_EXTERN AllocVariableTable *globalVariables DEFVAL(NULL); -MAYBE_EXTERN AllocVariableTable *userVariables DEFVAL(NULL); +MAYBE_EXTERN AllocVariableTable *globalVariables DEFVAL(nullptr); +MAYBE_EXTERN AllocVariableTable *userVariables DEFVAL(nullptr); typedef std::map int_vt_map; MAYBE_EXTERN int_vt_map userVarMap; @@ -415,9 +415,9 @@ MAYBE_EXTERN int stepDynamicId DEFVAL(4); // step of increment for dynam /*********************** Global Sockets **********************/ -MAYBE_EXTERN SIPpSocket *main_socket DEFVAL(NULL); -MAYBE_EXTERN SIPpSocket *main_remote_socket DEFVAL(NULL); -MAYBE_EXTERN SIPpSocket *tcp_multiplex DEFVAL(NULL); +MAYBE_EXTERN SIPpSocket *main_socket DEFVAL(nullptr); +MAYBE_EXTERN SIPpSocket *main_remote_socket DEFVAL(nullptr); +MAYBE_EXTERN SIPpSocket *tcp_multiplex DEFVAL(nullptr); MAYBE_EXTERN int media_socket_audio DEFVAL(0); MAYBE_EXTERN int media_socket_video DEFVAL(0); @@ -435,8 +435,8 @@ MAYBE_EXTERN std::set sockets_pending_reset; MAYBE_EXTERN struct sockaddr_storage local_addr_storage; -MAYBE_EXTERN SIPpSocket *twinSippSocket DEFVAL(NULL); -MAYBE_EXTERN SIPpSocket *localTwinSippSocket DEFVAL(NULL); +MAYBE_EXTERN SIPpSocket *twinSippSocket DEFVAL(nullptr); +MAYBE_EXTERN SIPpSocket *localTwinSippSocket DEFVAL(nullptr); MAYBE_EXTERN struct sockaddr_storage twinSipp_sockaddr; /* 3pcc extended mode */ diff --git a/include/socket.hpp b/include/socket.hpp index d6df02dca..64d41c709 100644 --- a/include/socket.hpp +++ b/include/socket.hpp @@ -65,7 +65,7 @@ class SIPpSocket { static SIPpSocket* new_sipp_call_socket(bool use_ipv6, int transport, bool *existing); void set_bind_port(int bind_port); - int connect(struct sockaddr_storage* dest = NULL); + int connect(struct sockaddr_storage* dest = nullptr); int reconnect(); // Reset a failed connection diff --git a/src/actions.cpp b/src/actions.cpp index 758410394..34255ce5a 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -396,9 +396,9 @@ int* CAction::getSubVarId() void CAction::setNbSubVarId (int P_value) { M_maxNbSubVarId = P_value; - if (M_subVarId != NULL) { + if (M_subVarId != nullptr) { delete [] M_subVarId; - M_subVarId = NULL; + M_subVarId = nullptr; } M_subVarId = new int[M_maxNbSubVarId] ; M_nbSubVarId = 0 ; @@ -411,12 +411,12 @@ int CAction::getNbSubVarId () void CAction::setLookingChar(const char* P_value) { - if (M_lookingChar != NULL) { + if (M_lookingChar != nullptr) { delete [] M_lookingChar; - M_lookingChar = NULL; + M_lookingChar = nullptr; } - if (P_value != NULL) { + if (P_value != nullptr) { M_lookingChar = new char[strlen(P_value)+1]; strcpy(M_lookingChar, P_value); } @@ -424,14 +424,14 @@ void CAction::setLookingChar(const char* P_value) void CAction::setMessage(const char* P_value, int n) { - if (M_message[n] != NULL) { + if (M_message[n] != nullptr) { delete M_message[n]; - M_message[n] = NULL; + M_message[n] = nullptr; } free(M_message_str[n]); - M_message_str[n] = NULL; + M_message_str[n] = nullptr; - if (P_value != NULL) { + if (P_value != nullptr) { M_message_str[n] = strdup(P_value); M_message[n] = new SendingMessage(M_scenario, P_value, true /* skip sanity */); } @@ -466,7 +466,7 @@ int CAction::executeRegExp(const char* P_string, VariableTable *P_callVarTable) regmatch_t pmatch[10]; int error; int nbOfMatch = 0; - char* result = NULL ; + char* result = nullptr ; if (!M_regExpSet) { ERROR("Trying to perform regular expression match on action that does not have one!"); @@ -501,7 +501,7 @@ void CAction::setSubString(char** P_target, const char* P_source, int P_start, i { int sizeOf; - if (P_source != NULL) { + if (P_source != nullptr) { sizeOf = P_stop - P_start; (*P_target) = new char[sizeOf + 1]; @@ -511,7 +511,7 @@ void CAction::setSubString(char** P_target, const char* P_source, int P_start, i (*P_target)[sizeOf] = '\0'; } else { - *P_target = NULL ; + *P_target = nullptr ; } } @@ -519,12 +519,12 @@ void CAction::setSubString(char** P_target, const char* P_source, int P_start, i #ifdef PCAPPLAY void CAction::setPcapArgs (pcap_pkts * P_value) { - if (M_pcapArgs != NULL) { + if (M_pcapArgs != nullptr) { free(M_pcapArgs); - M_pcapArgs = NULL; + M_pcapArgs = nullptr; } - if (P_value != NULL) { + if (P_value != nullptr) { M_pcapArgs = (pcap_pkts *)malloc(sizeof(*M_pcapArgs)); memcpy(M_pcapArgs, P_value, sizeof(*M_pcapArgs)); } @@ -532,12 +532,12 @@ void CAction::setPcapArgs (pcap_pkts * P_value) void CAction::setPcapArgs(const char* P_value) { - if (M_pcapArgs != NULL) { + if (M_pcapArgs != nullptr) { free(M_pcapArgs); - M_pcapArgs = NULL; + M_pcapArgs = nullptr; } - if (P_value != NULL) { + if (P_value != nullptr) { M_pcapArgs = (pcap_pkts *) malloc(sizeof(*M_pcapArgs)); if (parse_play_args(P_value, M_pcapArgs) == -1) { ERROR("Play pcap error"); @@ -570,7 +570,7 @@ void CAction::setRTPEchoActInfo(const char* P_value) strcpy (actionstring,P_value); param_str = strchr(actionstring,','); - next_comma = NULL; + next_comma = nullptr; // Comma found for payload_type parameter if (param_str) { @@ -907,7 +907,7 @@ void CAction::setScenario(scenario * P_scenario) void CAction::setAction(CAction P_action) { if (P_action.getActionType() == CAction::E_AT_ASSIGN_FROM_SAMPLE) { - assert(P_action.getDistribution() != NULL); + assert(P_action.getDistribution() != nullptr); } int L_i; setActionType ( P_action.getActionType() ); @@ -950,25 +950,25 @@ CAction::CAction(scenario *scenario) M_nbSubVarId = 0; M_maxNbSubVarId = 0; - M_subVarId = NULL; + M_subVarId = nullptr; M_checkIt = false; M_checkItInverse = false; M_lookingPlace = E_LP_MSG; - M_lookingChar = NULL; + M_lookingChar = nullptr; M_caseIndep = false; M_occurrence = 1; M_headersOnly = true; for (int i = 0; i < MAX_ACTION_MESSAGE; i++) { - M_message[i] = NULL; - M_message_str[i] = NULL; + M_message[i] = nullptr; + M_message_str[i] = nullptr; } M_IntCmd = E_INTCMD_INVALID; M_doubleValue = 0; - M_stringValue = NULL; - M_distribution = NULL; + M_stringValue = nullptr; + M_distribution = nullptr; #ifdef PCAPPLAY - M_pcapArgs = NULL; + M_pcapArgs = nullptr; #endif memset(&M_rtpecho_actinfo, 0, sizeof(M_rtpecho_actinfo)); @@ -976,32 +976,32 @@ CAction::CAction(scenario *scenario) M_scenario = scenario; M_regExpSet = false; - M_regularExpression = NULL; + M_regularExpression = nullptr; } CAction::~CAction() { - if (M_lookingChar != NULL) { + if (M_lookingChar != nullptr) { delete [] M_lookingChar; - M_lookingChar = NULL; + M_lookingChar = nullptr; } for (int i = 0; i < MAX_ACTION_MESSAGE; i++) { - if (M_message[i] != NULL) { + if (M_message[i] != nullptr) { delete M_message[i]; - M_message[i] = NULL; + M_message[i] = nullptr; } free(M_message_str[i]); - M_message_str[i] = NULL; + M_message_str[i] = nullptr; } - if (M_subVarId != NULL) { + if (M_subVarId != nullptr) { delete [] M_subVarId; - M_subVarId = NULL; + M_subVarId = nullptr; } free(M_stringValue); #ifdef PCAPPLAY - if (M_pcapArgs != NULL) { + if (M_pcapArgs != nullptr) { free_pcaps(M_pcapArgs); - M_pcapArgs = NULL; + M_pcapArgs = nullptr; } #endif if (M_regExpSet) { @@ -1030,7 +1030,7 @@ void CActions::reset() { for (int i = 0; i < M_nbAction; i++) { delete M_actionList[i]; - M_actionList[i] = NULL; + M_actionList[i] = nullptr; } M_nbAction = 0; } @@ -1062,14 +1062,14 @@ CAction* CActions::getAction(int i) if (i < M_nbAction) { return(M_actionList[i]); } else - return(NULL); + return(nullptr); } CActions::CActions() { M_nbAction = 0; - M_actionList = NULL; + M_actionList = nullptr; } @@ -1079,20 +1079,20 @@ CActions::~CActions() delete M_actionList[i]; } delete [] M_actionList; - M_actionList = NULL; + M_actionList = nullptr; } #ifdef GTEST #include "gtest/gtest.h" TEST(actions, MatchingRegexp) { - AllocVariableTable vt(NULL); + AllocVariableTable vt(nullptr); int id = vt.find("1", true); int sub1_id = vt.find("2", true); int sub2_id = vt.find("3", true); int sub3_id = vt.find("4", true); int sub4_id = vt.find("5", true); - CAction re(NULL); + CAction re(nullptr); re.setVarId(id); re.setNbSubVarId(4); re.setSubVarId(sub1_id); @@ -1111,13 +1111,13 @@ TEST(actions, MatchingRegexp) { } TEST(actions, NonMatchingRegexp) { - AllocVariableTable vt(NULL); + AllocVariableTable vt(nullptr); int id = vt.find("1", true); int sub1_id = vt.find("2", true); int sub2_id = vt.find("3", true); int sub3_id = vt.find("4", true); int sub4_id = vt.find("5", true); - CAction re(NULL); + CAction re(nullptr); re.setVarId(id); re.setNbSubVarId(4); re.setSubVarId(sub1_id); diff --git a/src/auth.cpp b/src/auth.cpp index b06738457..a83af7999 100644 --- a/src/auth.cpp +++ b/src/auth.cpp @@ -169,7 +169,7 @@ int createAuthHeader( char algo[32] = "MD5"; char *start, *end; - if ((start = stristr(auth, "Digest")) == NULL) { + if ((start = stristr(auth, "Digest")) == nullptr) { snprintf(result, result_len, "createAuthHeader: authentication must be digest"); return 0; } @@ -179,7 +179,7 @@ int createAuthHeader( return 0; } - if ((start = stristr(auth, "algorithm=")) != NULL) { + if ((start = stristr(auth, "algorithm=")) != nullptr) { start = start + strlen("algorithm="); if (*start == '"') { start++; @@ -292,7 +292,7 @@ static int createAuthResponseMD5( strncpy(tmp, uri, sizeof(tmp) - 1); } // If using Auth-Int make a hash of the body - which is NULL for REG - if (stristr(authtype, "auth-int") != NULL) { + if (stristr(authtype, "auth-int") != nullptr) { md5_init(&Md5Ctx); md5_append(&Md5Ctx, (md5_byte_t *) msgbody, strlen(msgbody)); md5_finish(&Md5Ctx, body); @@ -304,7 +304,7 @@ static int createAuthResponseMD5( md5_append(&Md5Ctx, (md5_byte_t *) method, strlen(method)); md5_append(&Md5Ctx, (md5_byte_t *) ":", 1); md5_append(&Md5Ctx, (md5_byte_t *) tmp, strlen(tmp)); - if (stristr(authtype, "auth-int") != NULL) { + if (stristr(authtype, "auth-int") != nullptr) { md5_append(&Md5Ctx, (md5_byte_t *) ":", 1); md5_append(&Md5Ctx, (md5_byte_t *) &body_hex, HASH_HEX_SIZE); } @@ -349,7 +349,7 @@ static int createAuthResponseSHA256( // Load in A1 // ha1 = SHA256(username ":" realm ":" password) - EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL); + EVP_DigestInit_ex(mdctx, EVP_sha256(), nullptr); EVP_DigestUpdate(mdctx, (unsigned char *) user, strlen(user)); EVP_DigestUpdate(mdctx, ":", 1); EVP_DigestUpdate(mdctx, (unsigned char *) realm, strlen(realm)); @@ -364,26 +364,26 @@ static int createAuthResponseSHA256( strncpy(tmp, uri, sizeof(tmp) - 1); } // If using Auth-Int make a hash of the body - which is NULL for REG - if (stristr(authtype, "auth-int") != NULL) { - EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL); + if (stristr(authtype, "auth-int") != nullptr) { + EVP_DigestInit_ex(mdctx, EVP_sha256(), nullptr); EVP_DigestUpdate(mdctx, (unsigned char *) msgbody, strlen(msgbody)); EVP_DigestFinal_ex(mdctx, body, &digest_len); hashToHex(&body[0], &body_hex[0], SHA256_HASH_SIZE); } // Load in A2 - EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL); + EVP_DigestInit_ex(mdctx, EVP_sha256(), nullptr); EVP_DigestUpdate(mdctx, (unsigned char *) method, strlen(method)); EVP_DigestUpdate(mdctx, (unsigned char *) ":", 1); EVP_DigestUpdate(mdctx, (unsigned char *) tmp, strlen(tmp)); - if (stristr(authtype, "auth-int") != NULL) { + if (stristr(authtype, "auth-int") != nullptr) { EVP_DigestUpdate(mdctx, (unsigned char *) ":", 1); EVP_DigestUpdate(mdctx, (unsigned char *) &body_hex, SHA256_HASH_HEX_SIZE); } EVP_DigestFinal_ex(mdctx, ha2, &digest_len); hashToHex(&ha2[0], &ha2_hex[0], SHA256_HASH_SIZE); - EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL); + EVP_DigestInit_ex(mdctx, EVP_sha256(), nullptr); EVP_DigestUpdate(mdctx, (unsigned char *) &ha1_hex, SHA256_HASH_HEX_SIZE); EVP_DigestUpdate(mdctx, (unsigned char *) ":", 1); EVP_DigestUpdate(mdctx, (unsigned char *) nonce, strlen(nonce)); @@ -451,7 +451,7 @@ int createAuthHeaderMD5( "Digest username=\"%s\",realm=\"%s\"", user, realm); // Construct the URI - if (auth_uri == NULL) { + if (auth_uri == nullptr) { snprintf(sipuri, sizeof(sipuri), "sip:%s", uri); } else { snprintf(sipuri, sizeof(sipuri), "sip:%s", auth_uri); @@ -509,7 +509,7 @@ int verifyAuthHeader(const char *user, const char *password, const char *method, char uri[MAX_HEADER_LEN]; char *start; - if ((start = stristr(auth, "Digest")) == NULL) { + if ((start = stristr(auth, "Digest")) == nullptr) { WARNING("verifyAuthHeader: authentication must be digest is %s", auth); return 0; } @@ -789,7 +789,7 @@ static int createAuthHeaderAKAv1MD5( int i; // Extract the Nonce - if ((start = stristr(auth, "nonce=")) == NULL) { + if ((start = stristr(auth, "nonce=")) == nullptr) { snprintf(result, result_len, "createAuthHeaderAKAv1MD5: couldn't parse nonce"); return 0; } @@ -939,7 +939,7 @@ int createAuthHeaderSHA256( "Digest username=\"%s\",realm=\"%s\"", user, realm); // Construct the URI - if (auth_uri == NULL) { + if (auth_uri == nullptr) { snprintf(sipuri, sizeof(sipuri), "sip:%s", uri); } else { snprintf(sipuri, sizeof(sipuri), "sip:%s", auth_uri); @@ -1019,7 +1019,7 @@ TEST(DigestAuth, BasicVerification) { " nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\"\r\n," " opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"")); char result[255]; - createAuthHeader("testuser", "secret", "REGISTER", "sip:example.com", "hello world", header, NULL, NULL, NULL, 1, result, 255); + createAuthHeader("testuser", "secret", "REGISTER", "sip:example.com", "hello world", header, nullptr, nullptr, nullptr, 1, result, 255); EXPECT_STREQ("Digest username=\"testuser\",realm=\"testrealm@host.com\",uri=\"sip:sip:example.com\",nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\",response=\"db94e01e92f2b09a52a234eeca8b90f7\",algorithm=MD5,opaque=\"5ccc069c403ebaf9f0171e9517f40e41\"", result); EXPECT_EQ(1, verifyAuthHeader("testuser", "secret", "REGISTER", result, "hello world")); free(header); @@ -1032,7 +1032,7 @@ TEST(DigestAuth, BasicVerificationSHA256) { " nonce=\"ZaGxV2WhsCtREI2EsiD1LR0RYd\"\r\n," " algorithm=SHA-256")); char result[255]; - createAuthHeader("testuser", "secret", "REGISTER", "sip:example.com", "hello world", header, NULL, NULL, NULL, 1, result, 255); + createAuthHeader("testuser", "secret", "REGISTER", "sip:example.com", "hello world", header, nullptr, nullptr, nullptr, 1, result, 255); EXPECT_STREQ("Digest username=\"testuser\",realm=\"testrealm@host.com\",uri=\"sip:sip:example.com\",nonce=\"ZaGxV2WhsCtREI2EsiD1LR0RYd\",response=\"91b58523b983191b52d14455a2599631990110c974ed2e4b4b49bc6053af04ce\",algorithm=SHA-256", result); EXPECT_EQ(1, verifyAuthHeader("testuser", "secret", "REGISTER", result, "hello world")); free(header); @@ -1052,9 +1052,9 @@ TEST(DigestAuth, qop) { "sip:example.com", "hello world", header, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, 1, result, 1024); diff --git a/src/call.cpp b/src/call.cpp index 0ea192ed2..778fbcc34 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -406,8 +406,8 @@ int call::check_video_ciphersuite_match(SrtpVideoInfoParams &pV) #define SDP_VIDEOCRYPTO_PREFIX "\na=crypto:" int call::extract_srtp_remote_info(const char * msg, SrtpAudioInfoParams &pA, SrtpVideoInfoParams &pV) { - const char* ro_search = NULL; - const char* alt_search = NULL; + const char* ro_search = nullptr; + const char* alt_search = nullptr; pA.audio_found = false; pV.video_found = false; @@ -430,8 +430,8 @@ int call::extract_srtp_remote_info(const char * msg, SrtpAudioInfoParams &pA, Sr pA.secondary_unencrypted_audio_srtp = false; pV.secondary_unencrypted_video_srtp = false; - char* sdp_body = NULL; - char* sdp_body_remember = NULL; + char* sdp_body = nullptr; + char* sdp_body_remember = nullptr; std::size_t mline_sol = 0; /* Start of m-line line */ std::size_t mline_eol = 0; /* End of m-line line */ @@ -442,7 +442,7 @@ int call::extract_srtp_remote_info(const char * msg, SrtpAudioInfoParams &pA, Sr char crypto_audio_sessionparams[64]; char crypto_video_sessionparams[64]; - char* checkUESRTP = NULL; + char* checkUESRTP = nullptr; bool audioExists = false; bool videoExists = false; std::size_t cur_pos = 0; @@ -787,7 +787,7 @@ unsigned long call::hash(const char * msg) /******************* Call class implementation ****************/ call::call(const char *p_id, bool use_ipv6, int userId, struct sockaddr_storage *dest) : listener(p_id, true) { - init(main_scenario, NULL, dest, p_id, userId, use_ipv6, false, false); + init(main_scenario, nullptr, dest, p_id, userId, use_ipv6, false, false); } call::call(const char *p_id, SIPpSocket *socket, struct sockaddr_storage *dest) : listener(p_id, true) @@ -834,14 +834,14 @@ call *call::add_call(int userId, bool ipv6, struct sockaddr_storage *dest) } call_id[count] = 0; - return new call(main_scenario, NULL, dest, call_id, userId, ipv6, false /* Not Auto. */, false); + return new call(main_scenario, nullptr, dest, call_id, userId, ipv6, false /* Not Auto. */, false); } void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_storage *dest, const char * p_id, int userId, bool ipv6, bool isAutomatic, bool isInitCall) { #ifdef USE_TLS - _srtpctxdebugfile = NULL; + _srtpctxdebugfile = nullptr; if (srtpcheck_debug) { @@ -854,7 +854,7 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st _srtpctxdebugfile = fopen("srtpctxdebugfile_uas", "w"); } - if (_srtpctxdebugfile == NULL) + if (_srtpctxdebugfile == nullptr) { /* error encountered opening srtp ctx debug file */ WARNING("Error encountered opening srtp ctx debug file"); @@ -868,17 +868,17 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st this->call_scenario = call_scenario; zombie = false; - debugBuffer = NULL; + debugBuffer = nullptr; debugLength = 0; msg_index = 0; last_send_index = 0; - last_send_msg = NULL; + last_send_msg = nullptr; last_send_len = 0; last_recv_hash = 0; last_recv_index = -1; - last_recv_msg = NULL; + last_recv_msg = nullptr; last_recv_invite_cseq = 0; @@ -886,8 +886,8 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st recv_retrans_recv_index = -1; recv_retrans_send_index = -1; - dialog_route_set = NULL; - next_req_url = NULL; + dialog_route_set = nullptr; + next_req_url = nullptr; cseq = 0; @@ -898,18 +898,18 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st paused_until = 0; call_port = 0; - comp_state = NULL; + comp_state = nullptr; start_time = clock_tick; call_established=false ; ack_is_pending=false ; - last_recv_msg = NULL; + last_recv_msg = nullptr; cseq = base_cseq; nb_last_delay = 0; use_ipv6 = ipv6; - queued_msg = NULL; + queued_msg = nullptr; - dialog_authentication = NULL; + dialog_authentication = nullptr; dialog_challenge_type = 0; next_nonce_count = 1; @@ -963,12 +963,12 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st play_args_v.last_seq_no = 2400; #endif - call_remote_socket = NULL; + call_remote_socket = nullptr; if (socket) { associate_socket(socket); socket->ss_count++; } else { - call_socket = NULL; + call_socket = nullptr; } if (dest) { memcpy(&call_peer, dest, sizeof(call_peer)); @@ -978,7 +978,7 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st // initialising the CallVariable with the Scenario variable int i; - VariableTable *userVars = NULL; + VariableTable *userVars = nullptr; bool putUserVars = false; if (userId) { int_vt_map::iterator it = userVarMap.find(userId); @@ -998,7 +998,7 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st } else if (globalVariables->size > 0) { M_callVariableTable = globalVariables->getTable(); } else { - M_callVariableTable = NULL; + M_callVariableTable = nullptr; } if (putUserVars) { userVars->putTable(); @@ -1008,7 +1008,7 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st transactions = (struct txnInstanceInfo *)malloc(sizeof(txnInstanceInfo) * call_scenario->transactions.size()); memset(transactions, 0, sizeof(struct txnInstanceInfo) * call_scenario->transactions.size()); } else { - transactions = NULL; + transactions = nullptr; } // If not updated by a message we use the start time @@ -1043,7 +1043,7 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st (*m_lineNumber)[file_it->first] = file_it->second->nextLine(userId); } } else { - m_lineNumber = NULL; + m_lineNumber = nullptr; } this->initCall = isInitCall; @@ -1058,7 +1058,7 @@ void call::init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_st media_thread = 0; #endif - peer_tag = NULL; + peer_tag = nullptr; recv_timeout = 0; send_timeout = 0; timewait = false; @@ -1095,7 +1095,7 @@ bool call::checkAckCSeq(const char* msg) { static char request[65]; unsigned long int rcseq = 0; - const char* ptr = NULL; + const char* ptr = nullptr; rcseq = get_cseq_value(msg); memset(request, 0, sizeof(request)); @@ -1138,7 +1138,7 @@ int call::_callDebug(const char *fmt, ...) /* First we figure out how much to allocate. */ va_start(ap, fmt); - int ret = vsnprintf(NULL, 0, fmt, ap); + int ret = vsnprintf(nullptr, 0, fmt, ap); va_end(ap); debugBuffer = (char *)realloc(debugBuffer, debugLength + ret + TIME_LENGTH + 2); @@ -1147,7 +1147,7 @@ int call::_callDebug(const char *fmt, ...) } struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); debugLength += snprintf(debugBuffer + debugLength, TIME_LENGTH + 2, "%s ", CStat::formatTime(&now)); va_start(ap, fmt); @@ -1218,7 +1218,7 @@ call::~call() # ifdef PCAPPLAY if (media_thread != 0) { pthread_cancel(media_thread); - pthread_join(media_thread, NULL); + pthread_join(media_thread, nullptr); } #endif @@ -1230,7 +1230,7 @@ call::~call() if (srtpcheck_debug) { fclose(_srtpctxdebugfile); - _srtpctxdebugfile = NULL; + _srtpctxdebugfile = nullptr; } #endif // USE_TLS } @@ -1317,16 +1317,16 @@ bool call::connect_socket_if_needed() char peripaddr[256]; if (!peripsocket) { - if ((associate_socket(SIPpSocket::new_sipp_call_socket(use_ipv6, transport, &existing))) == NULL) { + if ((associate_socket(SIPpSocket::new_sipp_call_socket(use_ipv6, transport, &existing))) == nullptr) { ERROR_NO("Unable to get a UDP socket (1)"); } } else { char *tmp = peripaddr; - getFieldFromInputFile(ip_file, peripfield, NULL, tmp); + getFieldFromInputFile(ip_file, peripfield, nullptr, tmp); auto i = map_perip_fd.find(peripaddr); if (i == map_perip_fd.end()) { // Socket does not exist - if ((associate_socket(SIPpSocket::new_sipp_call_socket(use_ipv6, transport, &existing))) == NULL) { + if ((associate_socket(SIPpSocket::new_sipp_call_socket(use_ipv6, transport, &existing))) == nullptr) { ERROR_NO("Unable to get a UDP socket (2)"); } else { /* Ensure that it stays persistent, because it is recorded in the map. */ @@ -1361,7 +1361,7 @@ bool call::connect_socket_if_needed() } else { /* TCP, SCTP or TLS. */ struct sockaddr_storage *L_dest = &remote_sockaddr; - if ((associate_socket(SIPpSocket::new_sipp_call_socket(use_ipv6, transport, &existing))) == NULL) { + if ((associate_socket(SIPpSocket::new_sipp_call_socket(use_ipv6, transport, &existing))) == nullptr) { ERROR_NO("Unable to get a TCP/SCTP/TLS socket"); } call_socket->ss_count++; @@ -1427,7 +1427,7 @@ bool call::lost(int index) } if(!inited) { - srand((unsigned int) time(NULL)); + srand((unsigned int) time(nullptr)); inited = 1; } @@ -1461,7 +1461,7 @@ int call::send_raw(const char * msg, int index, int len) if (multisocket || !main_remote_socket) { struct sockaddr_storage *L_dest = &remote_sending_sockaddr; - if((call_remote_socket= new_sipp_socket(use_ipv6, transport)) == NULL) { + if((call_remote_socket= new_sipp_socket(use_ipv6, transport)) == nullptr) { ERROR_NO("Unable to get a socket for rsa option"); } @@ -1531,7 +1531,7 @@ char * call::get_header_field_code(const char *msg, const char * name) const char * last_header; int i; - last_header = NULL; + last_header = nullptr; i = 0; /* If we find the field in msg */ last_header = get_header_content(msg, name); @@ -1549,7 +1549,7 @@ char * call::get_last_header(const char * name) int len; if((!last_recv_msg) || (!strlen(last_recv_msg))) { - return NULL; + return nullptr; } len = strlen(name); @@ -1625,7 +1625,7 @@ char * call::send_scene(int index, int *send_status, int *len) /* Socket port must be known before string substitution */ if (!connect_socket_if_needed()) { *send_status = -2; - return NULL; + return nullptr; } assert(call_socket); @@ -1641,7 +1641,7 @@ char * call::send_scene(int index, int *send_status, int *len) if (!dest) { *send_status = -2; - return NULL; + return nullptr; } L_ptr1=msg_name ; @@ -1871,7 +1871,7 @@ bool call::executeMessage(message *curmsg) /* Increment the number of sessions in pause state */ curmsg->sessions++; do_bookkeeping(curmsg); - executeAction(NULL, curmsg); + executeAction(nullptr, curmsg); callDebug("Pausing call until %d (is now %ld).\n", paused_until, clock_tick); setPaused(); return true; @@ -1891,12 +1891,12 @@ bool call::executeMessage(message *curmsg) next_retrans = 0; do_bookkeeping(curmsg); - executeAction(NULL, curmsg); + executeAction(nullptr, curmsg); return(next()); } else if(curmsg -> M_type == MSG_TYPE_NOP) { callDebug("Executing NOP at index %d.\n", curmsg->index); do_bookkeeping(curmsg); - actionResult = executeAction(NULL, curmsg); + actionResult = executeAction(nullptr, curmsg); last_action_result = actionResult; if (actionResult == E_AR_RTPECHO_ERROR) { @@ -2037,7 +2037,7 @@ bool call::executeMessage(message *curmsg) ) { if (queued_msg) { char *msg = queued_msg; - queued_msg = NULL; + queued_msg = nullptr; bool ret = process_incoming(msg); free(msg); return ret; @@ -2419,11 +2419,11 @@ bool call::abortCall(bool writeLog) { int is_inv; - char * src_recv = NULL ; + char * src_recv = nullptr ; callDebug("Aborting call %s (index %d).\n", id, msg_index); - if (last_send_msg != NULL) { + if (last_send_msg != nullptr) { is_inv = !strncmp(last_send_msg, "INVITE", 6); } else { is_inv = false; @@ -2566,9 +2566,9 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, int *msgLen) char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buffer, int buf_len, int *msgLen) { - char * length_marker = NULL; - char * auth_marker = NULL; - MessageComponent *auth_comp = NULL; + char * length_marker = nullptr; + char * auth_marker = nullptr; + MessageComponent *auth_comp = nullptr; bool auth_comp_allocated = false; int len_offset = 0; char *dest = msg_buffer; @@ -2659,7 +2659,7 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buf char address[INET6_ADDRSTRLEN]; if (getnameinfo(_RCAST(sockaddr*, &server_sockaddr), len, address, sizeof(address), - NULL, 0, NI_NUMERICHOST) < 0) { + nullptr, 0, NI_NUMERICHOST) < 0) { ERROR_NO("Unable to get socket name information"); } @@ -2686,7 +2686,7 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buf if (begin == msg_buffer) { ERROR("Can not find beginning of a line for the media port!"); } - play_args_t* play_args = NULL; + play_args_t* play_args = nullptr; if (strstr(begin, "audio")) { play_args = &play_args_a; } else if (strstr(begin, "image")) { @@ -2697,7 +2697,7 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buf // This check will not do, as we use the media_port in other places too. //ERROR("media_port keyword with no audio or video on the current line (%s)", begin); } - if (play_args != NULL) { + if (play_args != nullptr) { if (media_ip_is_ipv6) { (_RCAST(struct sockaddr_in6 *, &(play_args->from)))->sin6_port = htons(port); } else { @@ -3820,7 +3820,7 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buf break; case E_Message_Timestamp: struct timeval currentTime; - gettimeofday(¤tTime, NULL); + gettimeofday(¤tTime, nullptr); dest += snprintf(dest, left, "%s", CStat::formatTime(¤tTime)); break; case E_Message_Date: @@ -3828,7 +3828,7 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buf time_t t; struct tm *tm; - t = time(NULL); + t = time(nullptr); tm = gmtime(&t); /* changed %Z to hardcoded GMT since in some OS like FreeBSD it could return UTC instead, see issue #535 */ strftime(buf, 256, "%a, %d %b %Y %T GMT", tm); @@ -3977,8 +3977,8 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buf } } /* Need the body for length and auth-int calculation */ - char *body = NULL; - const char *auth_body = NULL; + char *body = nullptr; + const char *auth_body = nullptr; if (length_marker || auth_marker) { body = strstr(msg_buffer, "\r\n\r\n"); if (body) { @@ -4433,7 +4433,7 @@ bool call::matches_scenario(unsigned int index, int reply_code, char * request, if ((curmsg->recv_request)) { if (curmsg->regexp_match) { - if (curmsg->regexp_compile == NULL) { + if (curmsg->regexp_compile == nullptr) { regex_t *re = new regex_t; /* No regex match position needed (NOSUB), we're simply * looking for the @@ -4443,7 +4443,7 @@ bool call::matches_scenario(unsigned int index, int reply_code, char * request, } curmsg->regexp_compile = re; } - return !regexec(curmsg->regexp_compile, request, (size_t)0, NULL, REGEXEC_PARAMS); + return !regexec(curmsg->regexp_compile, request, (size_t)0, nullptr, REGEXEC_PARAMS); } else { return !strcmp(curmsg->recv_request, request); } @@ -4549,7 +4549,7 @@ bool call::process_incoming(const char* msg, const struct sockaddr_storage* src) call_scenario->messages[recv_retrans_recv_index] -> nb_recv_retrans++; - send_scene(recv_retrans_send_index, &status, NULL); + send_scene(recv_retrans_send_index, &status, nullptr); if(status >= 0) { call_scenario->messages[recv_retrans_send_index] -> nb_sent_retrans++; @@ -5455,7 +5455,7 @@ bool call::process_incoming(const char* msg, const struct sockaddr_storage* src) /* store the route set only once. TODO: does not support target refreshes!! */ if (call_scenario->messages[search_index]->bShouldRecordRoutes && - dialog_route_set == NULL) { + dialog_route_set == nullptr) { realloc_ptr = (char*)realloc(next_req_url, MAX_HEADER_LEN); if (realloc_ptr) { next_req_url = realloc_ptr; @@ -5589,13 +5589,13 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) actions = curmsg->M_actions; // looking for action to do on this message - if (actions == NULL) { + if (actions == nullptr) { return(call::E_AR_NO_ERROR); } for (int i = 0; i < actions->getActionSize(); i++) { currentAction = actions->getAction(i); - if(currentAction == NULL) { + if(currentAction == nullptr) { continue; } @@ -5603,7 +5603,7 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) char msgPart[MAX_SUB_MESSAGE_LENGTH]; /* Where to look. */ - const char* haystack = NULL; + const char* haystack = nullptr; if(currentAction->getLookingPlace() == CAction::E_LP_HDR) { extractSubMessage (msg, @@ -5665,7 +5665,7 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) M_callVariableTable->getVar(currentAction->getVarId())->setDouble(msg_index); } else if (currentAction->getActionType() == CAction::E_AT_ASSIGN_FROM_GETTIMEOFDAY) { struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); M_callVariableTable->getVar(currentAction->getVarId())->setDouble((double)tv.tv_sec); M_callVariableTable->getVar(currentAction->getSubVarId(0))->setDouble((double)tv.tv_usec); } else if (currentAction->getActionType() == CAction::E_AT_LOOKUP) { @@ -5719,7 +5719,7 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) } else if (currentAction->getActionType() == CAction::E_AT_CLOSE_CON) { if (call_socket) { call_socket->close(); - call_socket = NULL; + call_socket = nullptr; } } else if (currentAction->getActionType() == CAction::E_AT_SET_DEST) { /* Change the destination for this call. */ @@ -5749,7 +5749,7 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) if (!call_socket && ((protocol == T_TCP && transport == T_TCP) || (protocol == T_SCTP && transport == T_SCTP))) { bool existing; - if ((associate_socket(SIPpSocket::new_sipp_call_socket(use_ipv6, transport, &existing))) == NULL) { + if ((associate_socket(SIPpSocket::new_sipp_call_socket(use_ipv6, transport, &existing))) == nullptr) { switch (protocol) { case T_SCTP: ERROR_NO("Unable to get a SCTP socket"); @@ -5853,7 +5853,7 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) char *password = strdup(tmp); /* Need the body for length and auth-int calculation */ const char *body; - const char *auth_body = NULL; + const char *auth_body = nullptr; body = strstr(msg, "\r\n\r\n"); if (body) { auth_body = body; @@ -6053,7 +6053,7 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) // parent process continue // reap first child immediately pid_t ret; - while ((ret=waitpid(l_pid, NULL, 0)) != l_pid) { + while ((ret=waitpid(l_pid, nullptr, 0)) != l_pid) { if (ret != -1) { ERROR("waitpid returns %1ld for child %1ld", (long) ret, (long) l_pid); } @@ -6094,7 +6094,7 @@ call::T_ActionResult call::executeAction(const char* msg, message* curmsg) if (media_thread != 0) { // If a media_thread is already active, kill it before starting a new one pthread_cancel(media_thread); - pthread_join(media_thread, NULL); + pthread_join(media_thread, nullptr); media_thread = 0; } @@ -6489,7 +6489,7 @@ void call::extractSubMessage(const char* msg, char* matchingString, char* result while (*ptr) { if (!case_indep) { ptr = strstr(ptr, matchingString); - if (ptr == NULL) break; + if (ptr == nullptr) break; if (headers == true && ptr != msg && *(ptr-1) != '\n') { ++ptr; continue; @@ -6498,18 +6498,18 @@ void call::extractSubMessage(const char* msg, char* matchingString, char* result if (headers) { if (ptr != msg) { ptr = strchr(ptr, '\n'); - if (ptr == NULL) break; + if (ptr == nullptr) break; ++ptr; if (*ptr == 0) break; } } else { ptr1 = strchr(ptr, mat1); ptr = strchr(ptr, mat2); - if (ptr == NULL) { - if (ptr1 == NULL) break; + if (ptr == nullptr) { + if (ptr1 == nullptr) break; ptr = ptr1; } else { - if (ptr1 != NULL && ptr1 < ptr) ptr = ptr1; + if (ptr1 != nullptr && ptr1 < ptr) ptr = ptr1; } } if (strncasecmp(ptr, matchingString, len) != 0) { @@ -6523,7 +6523,7 @@ void call::extractSubMessage(const char* msg, char* matchingString, char* result ++ptr; } - if(ptr != NULL && *ptr != 0) { + if(ptr != nullptr && *ptr != 0) { strncpy(result, ptr+len, MAX_SUB_MESSAGE_LENGTH); sizeOf = strlen(result); if(sizeOf >= MAX_SUB_MESSAGE_LENGTH) @@ -6538,7 +6538,7 @@ void call::extractSubMessage(const char* msg, char* matchingString, char* result void call::getFieldFromInputFile(const char *fileName, int field, SendingMessage *lineMsg, char*& dest) { - if (m_lineNumber == NULL) { + if (m_lineNumber == nullptr) { ERROR("Automatic calls (created by -aa, -oocsn or -oocsf) cannot use input files!"); } if (inFiles.find(fileName) == inFiles.end()) { @@ -6600,7 +6600,7 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) { int res ; - char * old_last_recv_msg = NULL; + char * old_last_recv_msg = nullptr; bool last_recv_msg_saved = false; switch (P_case) { @@ -6621,7 +6621,7 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) // The BYE is unexpected, count it call_scenario->messages[msg_index] -> nb_unexp++; if (default_behaviors & DEFAULT_BEHAVIOR_ABORTUNEXP) { - WARNING("Aborting call on an unexpected BYE for call: %s", (id==NULL)?"none":id); + WARNING("Aborting call on an unexpected BYE for call: %s", (id==nullptr)?"none":id); if (default_behaviors & DEFAULT_BEHAVIOR_BYE) { sendBuffer(createSendingMessage(get_default_message("200"))); } @@ -6638,7 +6638,7 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) computeStat(CStat::E_FAILED_UNEXPECTED_MSG); delete this; } else { - WARNING("Continuing call on an unexpected BYE for call: %s", (id==NULL)?"none":id); + WARNING("Continuing call on an unexpected BYE for call: %s", (id==nullptr)?"none":id); } break ; @@ -6659,7 +6659,7 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) // The CANCEL is unexpected, count it call_scenario->messages[msg_index] -> nb_unexp++; if (default_behaviors & DEFAULT_BEHAVIOR_ABORTUNEXP) { - WARNING("Aborting call on an unexpected CANCEL for call: %s", (id==NULL)?"none":id); + WARNING("Aborting call on an unexpected CANCEL for call: %s", (id==nullptr)?"none":id); if (default_behaviors & DEFAULT_BEHAVIOR_BYE) { sendBuffer(createSendingMessage(get_default_message("200"))); } @@ -6677,7 +6677,7 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) computeStat(CStat::E_FAILED_UNEXPECTED_MSG); delete this; } else { - WARNING("Continuing call on unexpected CANCEL for call: %s", (id==NULL)?"none":id); + WARNING("Continuing call on unexpected CANCEL for call: %s", (id==nullptr)?"none":id); } break ; @@ -6696,7 +6696,7 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) strcpy(last_recv_msg, P_recv); if (default_behaviors & DEFAULT_BEHAVIOR_PINGREPLY) { - WARNING("Automatic response mode for an unexpected PING for call: %s", (id==NULL)?"none":id); + WARNING("Automatic response mode for an unexpected PING for call: %s", (id==nullptr)?"none":id); sendBuffer(createSendingMessage(get_default_message("200"))); // Note: the call ends here but it is not marked as bad. PING is a // normal message. @@ -6712,7 +6712,7 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) CStat::globalStat(CStat::E_AUTO_ANSWERED); delete this; } else { - WARNING("Do not answer on an unexpected PING for call: %s", (id==NULL)?"none":id); + WARNING("Do not answer on an unexpected PING for call: %s", (id==nullptr)?"none":id); } break ; @@ -6720,8 +6720,8 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) // store previous last msg if msg is INFO, NOTIFY, OPTIONS or UPDATE // restore last_recv_msg to previous one // after sending ok - old_last_recv_msg = NULL; - if (last_recv_msg != NULL) { + old_last_recv_msg = nullptr; + if (last_recv_msg != nullptr) { last_recv_msg_saved = true; old_last_recv_msg = (char *) malloc(strlen(last_recv_msg)+1); strcpy(old_last_recv_msg, last_recv_msg); @@ -6741,7 +6741,7 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) strcpy(last_recv_msg, P_recv); TRACE_CALLDEBUG("Automatic response mode for an unexpected INFO, NOTIFY, OPTIONS or UPDATE for call: %s", - (id == NULL) ? "none" : id); + (id == nullptr) ? "none" : id); sendBuffer(createSendingMessage(get_default_message("200"))); // restore previous last msg @@ -6757,9 +6757,9 @@ bool call::automaticResponseMode(T_AutoMode P_case, const char* P_recv) strcpy(last_recv_msg, old_last_recv_msg); - if (old_last_recv_msg != NULL) { + if (old_last_recv_msg != nullptr) { free(old_last_recv_msg); - old_last_recv_msg = NULL; + old_last_recv_msg = nullptr; } } CStat::globalStat(CStat::E_AUTO_ANSWERED); @@ -6779,7 +6779,7 @@ int call::logSrtpInfo(const char *fmt, ...) { va_list args; - if (_srtpctxdebugfile != NULL) + if (_srtpctxdebugfile != nullptr) { va_start(args, fmt); vfprintf(_srtpctxdebugfile, fmt, args); @@ -6816,11 +6816,11 @@ void *send_wrapper(void *arg) //ret = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); //if(ret) // ERROR("Can't set RTP play thread realtime parameters"); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); - pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL); + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, nullptr); + pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, nullptr); send_packets(s); - pthread_exit(NULL); - return NULL; + pthread_exit(nullptr); + return nullptr; } #endif @@ -6830,7 +6830,7 @@ void *send_wrapper(void *arg) class mockcall : public call { public: - mockcall(bool is_ipv6) : listener("//testing", true), call("///testing", is_ipv6, 0, NULL) {} + mockcall(bool is_ipv6) : listener("//testing", true), call("///testing", is_ipv6, 0, nullptr) {} /* Helpers to poke at protected internals */ void parse_media_addr(std::string const& msg) { get_remote_media_addr(msg); } diff --git a/src/call_generation_task.cpp b/src/call_generation_task.cpp index 1b4d305b0..1aa3eab17 100644 --- a/src/call_generation_task.cpp +++ b/src/call_generation_task.cpp @@ -32,13 +32,13 @@ */ #include "sipp.hpp" -class CallGenerationTask *CallGenerationTask::instance = NULL; +class CallGenerationTask *CallGenerationTask::instance = nullptr; unsigned long CallGenerationTask::calls_since_last_rate_change = 0; unsigned long CallGenerationTask::last_rate_change_time = 0; void CallGenerationTask::initialize() { - assert(instance == NULL); + assert(!instance); instance = new CallGenerationTask(); } @@ -49,7 +49,7 @@ CallGenerationTask::CallGenerationTask() CallGenerationTask::~CallGenerationTask() { - instance = NULL; + instance = nullptr; } void CallGenerationTask::dump() diff --git a/src/infile.cpp b/src/infile.cpp index ffcd66c70..42ddc2de0 100644 --- a/src/infile.cpp +++ b/src/infile.cpp @@ -54,11 +54,11 @@ FileContents::FileContents(const char *fileName) } const char* line = lineStr.c_str(); - if (NULL != strstr(line, "RANDOM")) { + if (nullptr != strstr(line, "RANDOM")) { usage = InputFileRandomOrder; - } else if (NULL != strstr(line, "SEQUENTIAL")) { + } else if (nullptr != strstr(line, "SEQUENTIAL")) { usage = InputFileSequentialOrder; - } else if (NULL != strstr(line, "USER")) { + } else if (nullptr != strstr(line, "USER")) { usage = InputFileUser; } else { ERROR("Unknown file type (valid values are RANDOM, SEQUENTIAL, and USER) for %s:%s", fileName, line); @@ -133,7 +133,7 @@ FileContents::FileContents(const char *fileName) numLinesInFile = realLinesInFile; } - indexMap = NULL; + indexMap = nullptr; indexField = -1; } diff --git a/src/jlsrtp.cpp b/src/jlsrtp.cpp index 9788811be..7091e21f3 100644 --- a/src/jlsrtp.cpp +++ b/src/jlsrtp.cpp @@ -640,7 +640,7 @@ int JLSRTP::decryptVector(std::vector &ciphertext_input, std::vec int JLSRTP::issueAuthenticationTag(std::vector &data, std::vector &hash) { - unsigned char* digest = NULL; + unsigned char* digest = nullptr; int retVal = -1; std::vector auth_portion; std::vector rocVec; @@ -657,9 +657,9 @@ int JLSRTP::issueAuthenticationTag(std::vector &data, std::vector auth_portion.insert(auth_portion.end(), rocVec.begin(), rocVec.end()); hash.clear(); - digest = HMAC(EVP_sha1(), _session_auth_key.data(), _session_auth_key.size(), /*data.data()*/ auth_portion.data(), /*data.size()*/ auth_portion.size(), NULL, NULL); + digest = HMAC(EVP_sha1(), _session_auth_key.data(), _session_auth_key.size(), /*data.data()*/ auth_portion.data(), /*data.size()*/ auth_portion.size(), nullptr, nullptr); - if (digest != NULL) + if (digest != nullptr) { hash.assign(digest, digest+JLSRTP_SHA1_HASH_LENGTH); @@ -1046,7 +1046,7 @@ int JLSRTP::setAESPseudoRandomFunctionKey(ActiveCrypto crypto_attrib /*= ACTIVE_ int rc = 0; int retVal = 0; - if (_pseudorandomstate.cipher != NULL) + if (_pseudorandomstate.cipher != nullptr) { if (crypto_attrib == ACTIVE_CRYPTO) { @@ -1061,7 +1061,7 @@ int JLSRTP::setAESPseudoRandomFunctionKey(ActiveCrypto crypto_attrib /*= ACTIVE_ { case PRIMARY_CRYPTO: { - rc = EVP_EncryptInit_ex(_pseudorandomstate.cipher, NULL, NULL, _primary_crypto.master_key.data(), NULL); + rc = EVP_EncryptInit_ex(_pseudorandomstate.cipher, nullptr, nullptr, _primary_crypto.master_key.data(), nullptr); if (rc == 1) { retVal = 0; @@ -1075,7 +1075,7 @@ int JLSRTP::setAESPseudoRandomFunctionKey(ActiveCrypto crypto_attrib /*= ACTIVE_ case SECONDARY_CRYPTO: { - rc = EVP_EncryptInit_ex(_pseudorandomstate.cipher, NULL, NULL, _secondary_crypto.master_key.data(), NULL); + rc = EVP_EncryptInit_ex(_pseudorandomstate.cipher, nullptr, nullptr, _secondary_crypto.master_key.data(), nullptr); if (rc == 1) { retVal = 0; @@ -1107,9 +1107,9 @@ int JLSRTP::setAESSessionEncryptionKey() int rc = 0; int retVal = 0; - if (_cipherstate.cipher != NULL) + if (_cipherstate.cipher != nullptr) { - rc = EVP_EncryptInit_ex(_cipherstate.cipher, NULL, NULL, _session_enc_key.data(), NULL); + rc = EVP_EncryptInit_ex(_cipherstate.cipher, nullptr, nullptr, _session_enc_key.data(), nullptr); if (rc == 1) { retVal = 0; @@ -1129,7 +1129,7 @@ int JLSRTP::setAESSessionEncryptionKey() void JLSRTP::AES_ctr128_increment(unsigned char* counter) { - unsigned char* cur_pos = NULL; + unsigned char* cur_pos = nullptr; for (cur_pos = counter + 15; cur_pos >= counter; cur_pos--) { @@ -1165,7 +1165,7 @@ int JLSRTP::AES_ctr128_pseudorandom_EVPencrypt(const unsigned char* in, if (n == 0) { // IMPORTANT: Key MUST be set every single time EVP_EncryptUpdate() is to be called... - rc = EVP_EncryptInit_ex(_pseudorandomstate.cipher, NULL, NULL, _primary_crypto.master_key.data(), NULL); + rc = EVP_EncryptInit_ex(_pseudorandomstate.cipher, nullptr, nullptr, _primary_crypto.master_key.data(), nullptr); if (rc == 1) { rc = EVP_EncryptUpdate(_pseudorandomstate.cipher, ecount_buf, &nb, counter, AES_BLOCK_SIZE); @@ -1203,7 +1203,7 @@ int JLSRTP::AES_ctr128_pseudorandom_EVPencrypt(const unsigned char* in, if (n == 0) { // IMPORTANT: Key MUST be set every single time EVP_EncryptUpdate() is to be called... - rc = EVP_EncryptInit_ex(_pseudorandomstate.cipher, NULL, NULL, _secondary_crypto.master_key.data(), NULL); + rc = EVP_EncryptInit_ex(_pseudorandomstate.cipher, nullptr, nullptr, _secondary_crypto.master_key.data(), nullptr); if (rc == 1) { rc = EVP_EncryptUpdate(_pseudorandomstate.cipher, ecount_buf, &nb, counter, AES_BLOCK_SIZE); @@ -1262,7 +1262,7 @@ int JLSRTP::AES_ctr128_session_EVPencrypt(const unsigned char* in, if (n == 0) { // IMPORTANT: Key MUST be set every single time EVP_EncryptUpdate() is to be called... - rc = EVP_EncryptInit_ex(_cipherstate.cipher, NULL, NULL, _session_enc_key.data(), NULL); + rc = EVP_EncryptInit_ex(_cipherstate.cipher, nullptr, nullptr, _session_enc_key.data(), nullptr); if (rc == 1) { rc = EVP_EncryptUpdate(_cipherstate.cipher, ecount_buf, &nb, counter, AES_BLOCK_SIZE); @@ -3521,15 +3521,15 @@ JLSRTP::JLSRTP() resetCryptoContext(0xCA110000, "127.0.0.1", 0); _pseudorandomstate.cipher = EVP_CIPHER_CTX_new(); - if (_pseudorandomstate.cipher != NULL) + if (_pseudorandomstate.cipher != nullptr) { - EVP_EncryptInit_ex(_pseudorandomstate.cipher, EVP_aes_128_ecb(), NULL, NULL /* primary/secondary master key set later */, NULL); + EVP_EncryptInit_ex(_pseudorandomstate.cipher, EVP_aes_128_ecb(), nullptr, nullptr /* primary/secondary master key set later */, nullptr); } _cipherstate.cipher = EVP_CIPHER_CTX_new(); - if (_cipherstate.cipher != NULL) + if (_cipherstate.cipher != nullptr) { - EVP_EncryptInit_ex(_cipherstate.cipher, EVP_aes_128_ecb(), NULL, NULL /* _session_enc_key set later */, NULL); + EVP_EncryptInit_ex(_cipherstate.cipher, EVP_aes_128_ecb(), nullptr, nullptr /* _session_enc_key set later */, nullptr); } } @@ -3538,15 +3538,15 @@ JLSRTP::JLSRTP(unsigned int ssrc, std::string ipAddress, unsigned short port) resetCryptoContext(ssrc, ipAddress, port); _pseudorandomstate.cipher = EVP_CIPHER_CTX_new(); - if (_pseudorandomstate.cipher != NULL) + if (_pseudorandomstate.cipher != nullptr) { - EVP_EncryptInit_ex(_pseudorandomstate.cipher, EVP_aes_128_ecb(), NULL, NULL /* primary/secondary master key set later */, NULL); + EVP_EncryptInit_ex(_pseudorandomstate.cipher, EVP_aes_128_ecb(), nullptr, nullptr /* primary/secondary master key set later */, nullptr); } _cipherstate.cipher = EVP_CIPHER_CTX_new(); - if (_cipherstate.cipher != NULL) + if (_cipherstate.cipher != nullptr) { - EVP_EncryptInit_ex(_cipherstate.cipher, EVP_aes_128_ecb(), NULL, NULL /* _session_enc_key set later */, NULL); + EVP_EncryptInit_ex(_cipherstate.cipher, EVP_aes_128_ecb(), nullptr, nullptr /* _session_enc_key set later */, nullptr); } } diff --git a/src/listener.cpp b/src/listener.cpp index 9c1691f4d..5933d9a05 100644 --- a/src/listener.cpp +++ b/src/listener.cpp @@ -66,15 +66,14 @@ listener::~listener() stopListening(); } free(id); - id = NULL; - + id = nullptr; } listener *get_listener(const char *id) { listener_map::iterator listener_it = listeners.find(listener_map::key_type(id)); if (listener_it == listeners.end()) { - return NULL; + return nullptr; } return listener_it->second; } diff --git a/src/logger.cpp b/src/logger.cpp index c5fcd505c..5d57fce7e 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -52,7 +52,7 @@ void log_off(struct logfile_info* lfi) if (lfi->fptr) { fflush(lfi->fptr); fclose(lfi->fptr); - lfi->fptr = NULL; + lfi->fptr = nullptr; lfi->overwrite = false; } } @@ -297,7 +297,7 @@ static void rotatef(struct logfile_info* lfi) lfi->nfiles++; fflush(lfi->fptr); fclose(lfi->fptr); - lfi->fptr = NULL; + lfi->fptr = nullptr; rename(lfi->file_name, L_rotate_file_name); } } @@ -343,7 +343,7 @@ static int _trace(struct logfile_info* lfi, const char* fmt, va_list ap) if (max_log_size && lfi->count > max_log_size) { fclose(lfi->fptr); - lfi->fptr = NULL; + lfi->fptr = nullptr; } if (ringbuffer_size && lfi->count > ringbuffer_size) { @@ -475,7 +475,7 @@ static void _screen_error(int fatal, bool use_errno, int error, const char *fmt, if (error_lfi.fptr) { fflush(error_lfi.fptr); fclose(error_lfi.fptr); - error_lfi.fptr = NULL; + error_lfi.fptr = nullptr; error_lfi.overwrite = false; } } diff --git a/src/message.cpp b/src/message.cpp index fea079bee..319cb7d25 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -134,7 +134,7 @@ static char* quoted_strchr(const char* s, int c) } } - return *p == c ? const_cast(p) : NULL; + return *p == c ? const_cast(p) : nullptr; } SendingMessage::SendingMessage(scenario* msg_scenario, const char* const_src, bool skip_sanity) @@ -146,7 +146,7 @@ SendingMessage::SendingMessage(scenario* msg_scenario, const char* const_src, bo char * dest; char * key; char current_line[MAX_HEADER_LEN]; - char * line_mark = NULL; + char * line_mark = nullptr; char * tsrc; int num_cr = get_cr_number(src); @@ -250,7 +250,7 @@ SendingMessage::SendingMessage(scenario* msg_scenario, const char* const_src, bo } } - char *spc = NULL; + char *spc = nullptr; char ospc; if ((spc = strchr(keyword, ' '))) { ospc = *spc; @@ -387,7 +387,7 @@ SendingMessage::SendingMessage(scenario* msg_scenario, const char* const_src, bo if (skip_sanity) { cancel = response = ack = false; - method = NULL; + method = nullptr; free(osrc); return; } @@ -424,7 +424,7 @@ SendingMessage::SendingMessage(scenario* msg_scenario, const char* const_src, bo ack = false; cancel = false; free(method); - method = NULL; + method = nullptr; } else { if (p != method) { memmove(method, p, strlen(p) + 1); @@ -517,7 +517,7 @@ void SendingMessage::getKeywordParam(char * src, const char * param, char * outp int len; len = 0; - key = NULL; + key = nullptr; if ((tmp = strstr(src, param))) { tmp += strlen(param); key = tmp; diff --git a/src/ratetask.cpp b/src/ratetask.cpp index f03de92c2..b29cd6a92 100644 --- a/src/ratetask.cpp +++ b/src/ratetask.cpp @@ -32,11 +32,11 @@ */ #include "sipp.hpp" -class ratetask *ratetask::instance = NULL; +class ratetask *ratetask::instance = nullptr; void ratetask::initialize() { - assert(instance == NULL); + assert(!instance); if (rate_increase) { instance = new ratetask(); } diff --git a/src/reporttask.cpp b/src/reporttask.cpp index 6e41f12cd..35bc68392 100644 --- a/src/reporttask.cpp +++ b/src/reporttask.cpp @@ -32,12 +32,12 @@ */ #include "sipp.hpp" -class stattask *stattask::instance = NULL; -class screentask *screentask::instance = NULL; +class stattask *stattask::instance = nullptr; +class screentask *screentask::instance = nullptr; void stattask::initialize() { - assert(instance == NULL); + assert(!instance); if (dumpInFile || useCountf || useErrorCodesf) { instance = new stattask(); } @@ -45,7 +45,7 @@ void stattask::initialize() void screentask::initialize() { - assert(instance == NULL); + assert(!instance); if (report_freq) { instance = new screentask(); } diff --git a/src/rtpstream.cpp b/src/rtpstream.cpp index f7615240f..c5b0c0e6c 100644 --- a/src/rtpstream.cpp +++ b/src/rtpstream.cpp @@ -114,13 +114,13 @@ struct cached_pattern_t int filesize; }; -cached_file_t *cached_files = NULL; -cached_pattern_t *cached_patterns = NULL; +cached_file_t *cached_files = nullptr; +cached_pattern_t *cached_patterns = nullptr; int num_cached_files = 0; int next_rtp_port = 0; -threaddata_t **ready_threads = NULL; -threaddata_t **busy_threads = NULL; +threaddata_t **ready_threads = nullptr; +threaddata_t **busy_threads = nullptr; int num_busy_threads = 0; int num_ready_threads = 0; int busy_threads_max = 0; @@ -128,22 +128,22 @@ int ready_threads_max = 0; unsigned int global_ssrc_id = 0; -FILE* debugafile = NULL; -FILE* debugvfile = NULL; +FILE* debugafile = nullptr; +FILE* debugvfile = nullptr; pthread_mutex_t debugamutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t debugvmutex = PTHREAD_MUTEX_INITIALIZER; #ifdef USE_TLS -FILE* debuglsrtpafile = NULL; -FILE* debugrsrtpafile = NULL; +FILE* debuglsrtpafile = nullptr; +FILE* debugrsrtpafile = nullptr; pthread_mutex_t debuglsrtpamutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t debugrsrtpamutex = PTHREAD_MUTEX_INITIALIZER; -FILE* debuglsrtpvfile = NULL; -FILE* debugrsrtpvfile = NULL; +FILE* debuglsrtpvfile = nullptr; +FILE* debugrsrtpvfile = nullptr; pthread_mutex_t debuglsrtpvmutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t debugrsrtpvmutex = PTHREAD_MUTEX_INITIALIZER; #endif // USE_TLS -FILE* debugrefileaudio = NULL; -FILE* debugrefilevideo = NULL; +FILE* debugrefileaudio = nullptr; +FILE* debugrefilevideo = nullptr; pthread_mutex_t debugremutexaudio = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t debugremutexvideo = PTHREAD_MUTEX_INITIALIZER; @@ -200,9 +200,9 @@ static unsigned long long getThreadId(pthread_t p) void printAudioHexUS(char const* note, unsigned char const* string, unsigned int size, unsigned long long extrainfo, int moreinfo) { - if ((debugafile != NULL) && - (note != NULL) && - (string != NULL) && + if ((debugafile != nullptr) && + (note != nullptr) && + (string != nullptr) && rtpcheck_debug) { pthread_mutex_lock(&debugamutex); @@ -218,9 +218,9 @@ void printAudioHexUS(char const* note, unsigned char const* string, unsigned int void printVideoHexUS(char const* note, unsigned char const* string, unsigned int size, unsigned long long extrainfo, int moreinfo) { - if ((debugvfile != NULL) && - (note != NULL) && - (string != NULL) && + if ((debugvfile != nullptr) && + (note != nullptr) && + (string != nullptr) && rtpcheck_debug) { pthread_mutex_lock(&debugvmutex); @@ -236,9 +236,9 @@ void printVideoHexUS(char const* note, unsigned char const* string, unsigned int void printAudioHex(char const* note, char const* string, unsigned int size, unsigned long long extrainfo, int moreinfo) { - if ((debugafile != NULL) && - (note != NULL) && - (string != NULL) && + if ((debugafile != nullptr) && + (note != nullptr) && + (string != nullptr) && rtpcheck_debug) { pthread_mutex_lock(&debugamutex); @@ -254,8 +254,8 @@ void printAudioHex(char const* note, char const* string, unsigned int size, unsi void printAudioVector(char const* note, std::vector const &v) { - if ((debugafile != NULL) && - (note != NULL) && + if ((debugafile != nullptr) && + (note != nullptr) && rtpcheck_debug) { pthread_mutex_lock(&debugamutex); @@ -270,9 +270,9 @@ void printAudioVector(char const* note, std::vector const &v) void printVideoHex(char const* note, char const* string, unsigned int size, unsigned long long extrainfo, int moreinfo) { - if ((debugvfile != NULL) && - (note != NULL) && - (string != NULL) && + if ((debugvfile != nullptr) && + (note != nullptr) && + (string != nullptr) && rtpcheck_debug) { pthread_mutex_lock(&debugvmutex); @@ -288,8 +288,8 @@ void printVideoHex(char const* note, char const* string, unsigned int size, unsi void printVideoVector(char const* note, std::vector const &v) { - if ((debugvfile != NULL) && - (note != NULL) && + if ((debugvfile != nullptr) && + (note != nullptr) && rtpcheck_debug) { pthread_mutex_lock(&debugvmutex); @@ -305,7 +305,7 @@ void printVideoVector(char const* note, std::vector const &v) #ifdef USE_TLS void printLocalAudioSrtpStuff(SrtpAudioInfoParams &p) { - if (debuglsrtpafile != NULL) + if (debuglsrtpafile != nullptr) { pthread_mutex_lock(&debuglsrtpamutex); fprintf(debuglsrtpafile, "audio_found : %d\n", p.audio_found); @@ -323,7 +323,7 @@ void printLocalAudioSrtpStuff(SrtpAudioInfoParams &p) void printRemoteAudioSrtpStuff(SrtpAudioInfoParams &p) { - if (debugrsrtpafile != NULL) + if (debugrsrtpafile != nullptr) { pthread_mutex_lock(&debugrsrtpamutex); fprintf(debugrsrtpafile, "audio_found : %d\n", p.audio_found); @@ -341,7 +341,7 @@ void printRemoteAudioSrtpStuff(SrtpAudioInfoParams &p) void printLocalVideoSrtpStuff(SrtpVideoInfoParams &p) { - if (debuglsrtpvfile != NULL) + if (debuglsrtpvfile != nullptr) { pthread_mutex_lock(&debuglsrtpvmutex); fprintf(debuglsrtpvfile, "video_found : %d\n", p.video_found); @@ -359,7 +359,7 @@ void printLocalVideoSrtpStuff(SrtpVideoInfoParams &p) void printRemoteVideoSrtpStuff(SrtpVideoInfoParams &p) { - if (debugrsrtpvfile != NULL) + if (debugrsrtpvfile != nullptr) { pthread_mutex_lock(&debugrsrtpvmutex); fprintf(debugrsrtpvfile, "video_found : %d\n", p.video_found); @@ -380,7 +380,7 @@ int set_bit(unsigned long* context, int value) { int retVal = -1; - if (context != NULL) + if (context != nullptr) { if (value > 0) { @@ -404,7 +404,7 @@ int clear_bit(unsigned long* context, int value) { int retVal = -1; - if (context != NULL) + if (context != nullptr) { if (value > 0) { @@ -754,7 +754,7 @@ static unsigned long rtpstream_playrtptask(taskentry_t* taskinfo, FD_ZERO(&readfds); FD_SET(taskinfo->audio_rtp_socket, &readfds); - rc = select(taskinfo->audio_rtp_socket + 1, &readfds, NULL, NULL, &tv); + rc = select(taskinfo->audio_rtp_socket + 1, &readfds, nullptr, nullptr, &tv); if (FD_ISSET(taskinfo->audio_rtp_socket, &readfds)) { @@ -1004,7 +1004,7 @@ static unsigned long rtpstream_playrtptask(taskentry_t* taskinfo, FD_ZERO(&readfds); FD_SET(taskinfo->video_rtp_socket, &readfds); - rc = select(taskinfo->video_rtp_socket + 1, &readfds, NULL, NULL, &tv); + rc = select(taskinfo->video_rtp_socket + 1, &readfds, nullptr, nullptr, &tv); if (FD_ISSET(taskinfo->video_rtp_socket, &readfds)) { @@ -1389,7 +1389,7 @@ static void* rtpstream_playback_thread(void* params) if (taskinfo->flags & TI_KILLTASK) { rtpstream_free_taskinfo(taskinfo); } else { - taskinfo->parent_thread = NULL; /* no longer associated with a thread */ + taskinfo->parent_thread = nullptr; /* no longer associated with a thread */ } } pthread_mutex_destroy(&(threaddata->tasklist_mutex)); @@ -1401,7 +1401,7 @@ static void* rtpstream_playback_thread(void* params) printVideoHex("PLAYBACK THREAD EXITING...", "", 0, rtpresult, 0); pthread_exit((void*) rtpresult); - return NULL; + return nullptr; } /* code checked */ @@ -1451,9 +1451,9 @@ static int rtpstream_start_task(rtpstream_callinfo_t* callinfo) memset(threaddata, 0, allocsize); threaddata->max_tasks = rtp_tasks_per_thread; threaddata->busy_list_index = -1; - pthread_mutex_init(&(threaddata->tasklist_mutex), NULL); + pthread_mutex_init(&(threaddata->tasklist_mutex), nullptr); /* create the thread itself */ - if (pthread_create(&threadID, NULL, rtpstream_playback_thread, threaddata)) { + if (pthread_create(&threadID, nullptr, rtpstream_playback_thread, threaddata)) { /* error creating the thread */ free(threaddata); return 0; @@ -1563,7 +1563,7 @@ static void rtpstream_stop_task(rtpstream_callinfo_t* callinfo) /* no playback thread owner, just free it */ rtpstream_free_taskinfo(taskinfo); } - callinfo->taskinfo = NULL; + callinfo->taskinfo = nullptr; } } @@ -1612,7 +1612,7 @@ int rtpstream_new_call(rtpstream_callinfo_t* callinfo) taskinfo->video_ssrc_id = global_ssrc_id++; /* pthread mutexes */ - pthread_mutex_init(&(callinfo->taskinfo->mutex), NULL); + pthread_mutex_init(&(callinfo->taskinfo->mutex), nullptr); return 1; } @@ -1646,24 +1646,24 @@ int rtpstream_cache_file(char* filename, debugprint("rtpstream_cache_file filename = %s mode = %d id = %d bytes_per_packet = %d stream_type = %d\n", filename, mode, id, bytes_per_packet, stream_type); - if ((debugafile == NULL) && + if ((debugafile == nullptr) && rtpcheck_debug && (stream_type == 0)) { debugafile = fopen("debugafile", "w"); - if (debugafile == NULL) + if (debugafile == nullptr) { /* error encountered opening audio debug file */ return -1; } } - if ((debugvfile == NULL) && + if ((debugvfile == nullptr) && rtpcheck_debug && (stream_type == 1)) { debugvfile = fopen("debugvfile", "w"); - if (debugvfile == NULL) + if (debugvfile == nullptr) { /* error encountered opening video debug file */ return -1; @@ -1697,7 +1697,7 @@ int rtpstream_cache_file(char* filename, } cached_patterns[num_cached_files].bytes = (char*)malloc(bytes_per_packet); - if (cached_patterns[num_cached_files].bytes == NULL) + if (cached_patterns[num_cached_files].bytes == nullptr) { /* out of memory */ return -1; @@ -2089,7 +2089,7 @@ int rtpstream_set_srtp_audio_local(rtpstream_callinfo_t* callinfo, SrtpAudioInfo if (srtpcheck_debug) { - if (debuglsrtpafile == NULL) + if (debuglsrtpafile == nullptr) { if (sendMode == MODE_CLIENT) { @@ -2099,7 +2099,7 @@ int rtpstream_set_srtp_audio_local(rtpstream_callinfo_t* callinfo, SrtpAudioInfo { debuglsrtpafile = fopen("debuglsrtpafile_uas", "w"); } - if (debuglsrtpafile == NULL) + if (debuglsrtpafile == nullptr) { /* error encountered opening local srtp debug file */ return -1; @@ -2137,7 +2137,7 @@ int rtpstream_set_srtp_audio_local(rtpstream_callinfo_t* callinfo, SrtpAudioInfo if (debuglsrtpafile) { fclose(debuglsrtpafile); - debuglsrtpafile = NULL; + debuglsrtpafile = nullptr; } } @@ -2156,7 +2156,7 @@ int rtpstream_set_srtp_audio_remote(rtpstream_callinfo_t* callinfo, SrtpAudioInf if (srtpcheck_debug) { - if (debugrsrtpafile == NULL) + if (debugrsrtpafile == nullptr) { if (sendMode == MODE_CLIENT) { @@ -2166,7 +2166,7 @@ int rtpstream_set_srtp_audio_remote(rtpstream_callinfo_t* callinfo, SrtpAudioInf { debugrsrtpafile = fopen("debugrsrtpafile_uas", "w"); } - if (debugrsrtpafile == NULL) + if (debugrsrtpafile == nullptr) { /* error encountered opening local srtp debug file */ return -1; @@ -2204,7 +2204,7 @@ int rtpstream_set_srtp_audio_remote(rtpstream_callinfo_t* callinfo, SrtpAudioInf if (debugrsrtpafile) { fclose(debugrsrtpafile); - debugrsrtpafile = NULL; + debugrsrtpafile = nullptr; } } @@ -2223,7 +2223,7 @@ int rtpstream_set_srtp_video_local(rtpstream_callinfo_t* callinfo, SrtpVideoInfo if (srtpcheck_debug) { - if (debuglsrtpvfile == NULL) + if (debuglsrtpvfile == nullptr) { if (sendMode == MODE_CLIENT) { @@ -2233,7 +2233,7 @@ int rtpstream_set_srtp_video_local(rtpstream_callinfo_t* callinfo, SrtpVideoInfo { debuglsrtpvfile = fopen("debuglsrtpvfile_uas", "w"); } - if (debuglsrtpvfile == NULL) + if (debuglsrtpvfile == nullptr) { /* error encountered opening local srtp debug file */ return -1; @@ -2271,7 +2271,7 @@ int rtpstream_set_srtp_video_local(rtpstream_callinfo_t* callinfo, SrtpVideoInfo if (debuglsrtpvfile) { fclose(debuglsrtpvfile); - debuglsrtpvfile = NULL; + debuglsrtpvfile = nullptr; } } @@ -2290,7 +2290,7 @@ int rtpstream_set_srtp_video_remote(rtpstream_callinfo_t* callinfo, SrtpVideoInf if (srtpcheck_debug) { - if (debugrsrtpvfile == NULL) + if (debugrsrtpvfile == nullptr) { if (sendMode == MODE_CLIENT) { @@ -2300,7 +2300,7 @@ int rtpstream_set_srtp_video_remote(rtpstream_callinfo_t* callinfo, SrtpVideoInf { debugrsrtpvfile = fopen("debugrsrtpvfile_uas", "w"); } - if (debugrsrtpvfile == NULL) + if (debugrsrtpvfile == nullptr) { /* error encountered opening local srtp debug file */ return -1; @@ -2338,7 +2338,7 @@ int rtpstream_set_srtp_video_remote(rtpstream_callinfo_t* callinfo, SrtpVideoInf if (debugrsrtpvfile) { fclose(debugrsrtpvfile); - debugrsrtpvfile = NULL; + debugrsrtpvfile = nullptr; } } @@ -2640,7 +2640,7 @@ void rtpstream_audioecho_thread(void* param) p.p = param; - if (param != NULL) + if (param != nullptr) { sock = p.i; } @@ -2648,7 +2648,7 @@ void rtpstream_audioecho_thread(void* param) if ((flags = fcntl(sock, F_GETFL, 0)) < 0) { pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "rtp_audioecho_thread(): fcntl() GETFL UNBLOCK failed...\n"); } @@ -2659,7 +2659,7 @@ void rtpstream_audioecho_thread(void* param) if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) { pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "rtp_audioecho_thread(): fcntl() SETFL UNBLOCK failed...\n"); } @@ -2668,11 +2668,11 @@ void rtpstream_audioecho_thread(void* param) } sigfillset(&mask); /* Mask all allowed signals */ - rc = pthread_sigmask(SIG_BLOCK, &mask, NULL); + rc = pthread_sigmask(SIG_BLOCK, &mask, nullptr); if (rc) { //WARNING("pthread_sigmask returned %d in rtpstream_echo_thread", rc); pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "pthread_sigmask returned %d in rtpstream_audioecho_thread", rc); } @@ -2700,18 +2700,18 @@ void rtpstream_audioecho_thread(void* param) seq_num = (audio_packet_in[2] << 8) | audio_packet_in[3]; pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "DATA SUCCESSFULLY RECEIVED [AUDIO] nr = %ld...", nr); } for (int i = 0; i < 12; i++) { - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "%02X", 0xFFFFFFFF & audio_packet_in[i]); } } - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "\n"); } @@ -2725,7 +2725,7 @@ void rtpstream_audioecho_thread(void* param) // DECRYPT rc = g_rxUASAudio.processIncomingPacket(seq_num, audio_packet_in, rtp_header, payload_data); pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "RXUASAUDIO -- processIncomingPacket() rc == %d\n", rc); } @@ -2767,7 +2767,7 @@ void rtpstream_audioecho_thread(void* param) // ENCRYPT rc = g_txUASAudio.processOutgoingPacket(seq_num, rtp_header, payload_data, audio_packet_out); pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "TXUASAUDIO -- processOutgoingPacket() rc == %d\n", rc); } @@ -2778,14 +2778,14 @@ void rtpstream_audioecho_thread(void* param) if (ns != nr) { pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "DATA SUCCESSFULLY SENT [AUDIO] seq_num = [%u] -- MISMATCHED RECV/SENT BYTE COUNT -- errno = %d nr = %ld ns = %ld\n", seq_num, errno, nr, ns); } pthread_mutex_unlock(&debugremutexaudio); } else { pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "DATA SUCCESSFULLY SENT [AUDIO] seq_num = [%u]...\n", seq_num); } @@ -2799,7 +2799,7 @@ void rtpstream_audioecho_thread(void* param) (errno == EAGAIN)) { // No data to be read (no activity on socket) //pthread_mutex_lock(&debugremutexaudio); - //if (debugrefileaudio != NULL) + //if (debugrefileaudio != nullptr) //{ // fprintf(debugrefileaudio, "No activity on audioecho socket (EAGAIN)...\n"); //} @@ -2809,7 +2809,7 @@ void rtpstream_audioecho_thread(void* param) // Other error occurred during read //WARNING("%s %i", "Error on RTP echo reception - stopping rtpstream echo - errno = ", errno); pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "Error on RTP echo reception - unable to perform rtpstream audioecho - errno = %d\n", errno); } @@ -2821,7 +2821,7 @@ void rtpstream_audioecho_thread(void* param) else { pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "rtp_audioecho_thread(): pthread_cond_timedwait() non-timeout: rc: %d quit_audioecho_thread: %d\n", rc, quit_audioecho_thread); } @@ -2833,7 +2833,7 @@ void rtpstream_audioecho_thread(void* param) if ((flags = fcntl(sock, F_GETFL, 0)) < 0) { pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "rtp_audioecho_thread(): fcntl() GETFL BLOCK failed...\n"); } @@ -2844,7 +2844,7 @@ void rtpstream_audioecho_thread(void* param) if (fcntl(sock, F_SETFL, flags & (~O_NONBLOCK)) < 0) { pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "rtp_audioecho_thread(): fcntl() SETFL BLOCK failed...\n"); } @@ -2899,7 +2899,7 @@ void rtpstream_videoecho_thread(void* param) p.p = param; - if (param != NULL) + if (param != nullptr) { sock = p.i; } @@ -2907,7 +2907,7 @@ void rtpstream_videoecho_thread(void* param) if ((flags = fcntl(sock, F_GETFL, 0)) < 0) { pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "rtp_videoecho_thread(): fcntl() GETFL UNBLOCK failed...\n"); } @@ -2918,7 +2918,7 @@ void rtpstream_videoecho_thread(void* param) if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) { pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "rtp_videoecho_thread(): fcntl() SETFL UNBLOCK failed...\n"); } @@ -2927,11 +2927,11 @@ void rtpstream_videoecho_thread(void* param) } sigfillset(&mask); /* Mask all allowed signals */ - rc = pthread_sigmask(SIG_BLOCK, &mask, NULL); + rc = pthread_sigmask(SIG_BLOCK, &mask, nullptr); if (rc) { //WARNING("pthread_sigmask returned %d in rtpstream_echo_thread", rc); pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "pthread_sigmask returned %d in rtpstream_videoecho_thread", rc); } @@ -2959,18 +2959,18 @@ void rtpstream_videoecho_thread(void* param) seq_num = (video_packet_in[2] << 8) | video_packet_in[3]; pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "DATA SUCCESSFULLY RECEIVED [VIDEO] nr = %ld...", nr); } for (int i = 0; i < 12; i++) { - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "%02X", 0xFFFFFFFF & video_packet_in[i]); } } - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "\n"); } @@ -2983,7 +2983,7 @@ void rtpstream_videoecho_thread(void* param) // DECRYPT rc = g_rxUASVideo.processIncomingPacket(seq_num, video_packet_in, rtp_header, payload_data); pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "RXUASVIDEO -- processIncomingPacket() rc == %d\n", rc); } @@ -3025,7 +3025,7 @@ void rtpstream_videoecho_thread(void* param) // ENCRYPT rc = g_txUASVideo.processOutgoingPacket(seq_num, rtp_header, payload_data, video_packet_out); pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "TXUASVIDEO -- processOutgoingPacket() rc == %d\n", rc); } @@ -3036,14 +3036,14 @@ void rtpstream_videoecho_thread(void* param) if (ns != nr) { pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "DATA SUCCESSFULLY SENT [VIDEO] seq_num = [%u] -- MISMATCHED RECV/SENT BYTE COUNT -- errno = %d nr = %ld ns = %ld\n", seq_num, errno, nr, ns); } pthread_mutex_unlock(&debugremutexvideo); } else { pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "DATA SUCCESSFULLY SENT [VIDEO] seq_num[%u]...\n", seq_num); } @@ -3057,7 +3057,7 @@ void rtpstream_videoecho_thread(void* param) (errno == EAGAIN)) { // No data to be read (no activity on socket) //pthread_mutex_lock(&debugremutexvideo); - //if (debugrefilevideo != NULL) + //if (debugrefilevideo != nullptr) //{ //fprintf(debugrefilevideo, "No activity on videoecho socket (EAGAIN)...\n"); //} @@ -3067,7 +3067,7 @@ void rtpstream_videoecho_thread(void* param) // Other error occurred during read //WARNING("%s %i", "Error on RTP echo reception - stopping rtpstream echo - errno = ", errno); pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "Error on RTP echo reception - unable to perform rtpstream videoecho - errno = %d\n", errno); } @@ -3079,7 +3079,7 @@ void rtpstream_videoecho_thread(void* param) else { pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "rtp_videoecho_thread(): pthread_cond_timedwait() non-timeout: rc: %d quit_videoecho_thread: %d\n", rc, quit_videoecho_thread); } @@ -3091,7 +3091,7 @@ void rtpstream_videoecho_thread(void* param) if ((flags = fcntl(sock, F_GETFL, 0)) < 0) { pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "rtp_videoecho_thread(): fcntl() GETFL BLOCK failed...\n"); } @@ -3102,7 +3102,7 @@ void rtpstream_videoecho_thread(void* param) if (fcntl(sock, F_SETFL, flags & (~O_NONBLOCK)) < 0) { pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "rtp_videoecho_thread(): fcntl() SETFL BLOCK failed...\n"); } @@ -3144,10 +3144,10 @@ int rtpstream_rtpecho_startaudio(rtpstream_callinfo_t* callinfo, JLSRTP& rxUASAu pthread_mutex_lock(&debugremutexaudio); if (srtpcheck_debug) { - if (debugrefileaudio == NULL) + if (debugrefileaudio == nullptr) { debugrefileaudio = fopen("debugrefileaudio", "w"); - if (debugrefileaudio == NULL) + if (debugrefileaudio == nullptr) { /* error encountered opening audio debug file */ pthread_mutex_lock(&debugremutexaudio); @@ -3158,7 +3158,7 @@ int rtpstream_rtpecho_startaudio(rtpstream_callinfo_t* callinfo, JLSRTP& rxUASAu pthread_mutex_unlock(&debugremutexaudio); pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "rtpstream_rtpecho_startaudio reached...\n"); } @@ -3175,7 +3175,7 @@ int rtpstream_rtpecho_startaudio(rtpstream_callinfo_t* callinfo, JLSRTP& rxUASAu p.i = taskinfo->audio_rtp_socket; if (taskinfo->audio_rtp_socket > 0) { - if (pthread_create(&pthread_audioecho_id, NULL, (void *(*) (void *)) rtpstream_audioecho_thread, p.p) == -1) { + if (pthread_create(&pthread_audioecho_id, nullptr, (void *(*) (void *)) rtpstream_audioecho_thread, p.p) == -1) { ERROR_NO("Unable to create RTP audio echo thread"); return -7; } @@ -3200,7 +3200,7 @@ int rtpstream_rtpecho_updateaudio(rtpstream_callinfo_t* callinfo, JLSRTP& rxUASA taskinfo->audio_srtp_echo_active = 1; pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "rtpstream_rtpecho_updateaudio reached...\n"); } @@ -3235,14 +3235,14 @@ int rtpstream_rtpecho_stopaudio(rtpstream_callinfo_t* callinfo) pthread_mutex_lock(&quit_mutexaudio); pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "MAIN: Setting quit_audioecho_thread flag to TRUE...\n"); } pthread_mutex_unlock(&debugremutexaudio); quit_audioecho_thread = true; pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "MAIN: Sending QUIT signal...\n"); } @@ -3252,7 +3252,7 @@ int rtpstream_rtpecho_stopaudio(rtpstream_callinfo_t* callinfo) pthread_mutex_unlock(&quit_mutexaudio); pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "rtpstream_rtpecho_stopaudio reached...\n"); } @@ -3264,7 +3264,7 @@ int rtpstream_rtpecho_stopaudio(rtpstream_callinfo_t* callinfo) { // successfully joined audio thread pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "successfully joined audio thread: %d\n", r.i); } @@ -3274,7 +3274,7 @@ int rtpstream_rtpecho_stopaudio(rtpstream_callinfo_t* callinfo) { // error joining audio thread pthread_mutex_lock(&debugremutexaudio); - if (debugrefileaudio != NULL) + if (debugrefileaudio != nullptr) { fprintf(debugrefileaudio, "error joining audio thread: %d\n", r.i); } @@ -3316,10 +3316,10 @@ int rtpstream_rtpecho_startvideo(rtpstream_callinfo_t* callinfo, JLSRTP& rxUASVi pthread_mutex_lock(&debugremutexvideo); if (srtpcheck_debug) { - if (debugrefilevideo == NULL) + if (debugrefilevideo == nullptr) { debugrefilevideo = fopen("debugrefilevideo", "w"); - if (debugrefilevideo == NULL) + if (debugrefilevideo == nullptr) { /* error encountered opening audio debug file */ pthread_mutex_unlock(&debugremutexvideo); @@ -3330,7 +3330,7 @@ int rtpstream_rtpecho_startvideo(rtpstream_callinfo_t* callinfo, JLSRTP& rxUASVi pthread_mutex_unlock(&debugremutexvideo); pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "rtpstream_rtpecho_startvideo reached...\n"); } @@ -3347,7 +3347,7 @@ int rtpstream_rtpecho_startvideo(rtpstream_callinfo_t* callinfo, JLSRTP& rxUASVi p.i = taskinfo->video_rtp_socket; if (taskinfo->video_rtp_socket > 0) { - if (pthread_create(&pthread_videoecho_id, NULL, (void *(*) (void *)) rtpstream_videoecho_thread, p.p) == -1) { + if (pthread_create(&pthread_videoecho_id, nullptr, (void *(*) (void *)) rtpstream_videoecho_thread, p.p) == -1) { ERROR_NO("Unable to create RTP video echo thread"); return -8; } @@ -3372,7 +3372,7 @@ int rtpstream_rtpecho_updatevideo(rtpstream_callinfo_t* callinfo, JLSRTP& rxUASV taskinfo->video_srtp_echo_active = 1; pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "rtpstream_rtpecho_updatevideo reached...\n"); } @@ -3407,14 +3407,14 @@ int rtpstream_rtpecho_stopvideo(rtpstream_callinfo_t* callinfo) pthread_mutex_lock(&quit_mutexvideo); pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "MAIN: Setting quit_videoecho_thread flags to TRUE...\n"); } pthread_mutex_unlock(&debugremutexvideo); quit_videoecho_thread = true; pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "MAIN: Sending QUIT signal...\n"); } @@ -3424,7 +3424,7 @@ int rtpstream_rtpecho_stopvideo(rtpstream_callinfo_t* callinfo) pthread_mutex_unlock(&quit_mutexvideo); pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "rtpstream_rtpecho_stopvideo reached...\n"); } @@ -3436,7 +3436,7 @@ int rtpstream_rtpecho_stopvideo(rtpstream_callinfo_t* callinfo) { // successfully joined video thread pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "successfully joined video thread: %d\n", r.i); } @@ -3446,7 +3446,7 @@ int rtpstream_rtpecho_stopvideo(rtpstream_callinfo_t* callinfo) { // error joining video thread pthread_mutex_lock(&debugremutexvideo); - if (debugrefilevideo != NULL) + if (debugrefilevideo != nullptr) { fprintf(debugrefilevideo, "error joining video thread: %d\n", r.i); } @@ -3476,7 +3476,7 @@ int rtpstream_shutdown(std::unordered_map& threadIDs) void* rtpresult; int total_rtpresults; - rtpresult = NULL; + rtpresult = nullptr; total_rtpresults = 0; debugprint("rtpstream_shutdown\n"); @@ -3487,7 +3487,7 @@ int rtpstream_shutdown(std::unordered_map& threadIDs) ready_threads[count]->exit_flag = 1; } free(ready_threads); - ready_threads = NULL; + ready_threads = nullptr; } if (busy_threads) { @@ -3495,7 +3495,7 @@ int rtpstream_shutdown(std::unordered_map& threadIDs) busy_threads[count]->exit_flag = 1; } free(busy_threads); - busy_threads = NULL; + busy_threads = nullptr; } /* first make sure no playback threads are accessing the file buffers */ @@ -3529,7 +3529,7 @@ int rtpstream_shutdown(std::unordered_map& threadIDs) free(cached_files[count].bytes); } free(cached_files); - cached_files = NULL; + cached_files = nullptr; } /* now free cached patterns bytes and structure */ @@ -3539,7 +3539,7 @@ int rtpstream_shutdown(std::unordered_map& threadIDs) free(cached_patterns[count].bytes); } free(cached_patterns); - cached_patterns = NULL; + cached_patterns = nullptr; } if (debugvfile && diff --git a/src/scenario.cpp b/src/scenario.cpp index b3900803e..780a8e435 100644 --- a/src/scenario.cpp +++ b/src/scenario.cpp @@ -42,23 +42,23 @@ message::message(int index, const char *desc) { this->index = index; this->desc = desc; - pause_distribution = NULL; // delete on exit + pause_distribution = nullptr; // delete on exit pause_variable = -1; - pause_desc = NULL; // free on exit + pause_desc = nullptr; // free on exit sessions = 0; bShouldRecordRoutes = 0; bShouldAuthenticate = 0; - send_scheme = NULL; // delete on exit + send_scheme = nullptr; // delete on exit retrans_delay = 0; timeout = 0; recv_response = 0; - recv_request = NULL; // free on exit + recv_request = nullptr; // free on exit optional = 0; advance_state = true; regexp_match = 0; - regexp_compile = NULL; // regfree (if not NULL) and free on exit + regexp_compile = nullptr; // regfree (if not nullptr) and free on exit /* Anyway */ start_rtd = 0; @@ -68,20 +68,20 @@ message::message(int index, const char *desc) crlf = 0; ignoresdp = false; hide = 0; - display_str = NULL; // free on exit + display_str = nullptr; // free on exit test = -1; condexec = -1; condexec_inverse = false; chance = 0;/* meaning always */ next = -1; - nextLabel = NULL; // free on exit + nextLabel = nullptr; // free on exit on_timeout = -1; - onTimeoutLabel = NULL; // free on exit + onTimeoutLabel = nullptr; // free on exit timewait = false; /* 3pcc extended mode */ - peer_dest = NULL; // free on exit - peer_src = NULL; // free on exit + peer_dest = nullptr; // free on exit + peer_src = nullptr; // free on exit /* Statistics */ nb_sent = 0; @@ -93,11 +93,11 @@ message::message(int index, const char *desc) nb_lost = 0; counter = 0; - M_actions = NULL; // delete on exit + M_actions = nullptr; // delete on exit M_type = 0; - M_sendCmdData = NULL; // delete on exit + M_sendCmdData = nullptr; // delete on exit M_nbCmdSent = 0; M_nbCmdRecv = 0; @@ -107,7 +107,7 @@ message::message(int index, const char *desc) start_txn = 0; response_txn = 0; ack_txn = 0; - recv_response_for_cseq_method_list = NULL; // free on exit + recv_response_for_cseq_method_list = nullptr; // free on exit } message::~message() @@ -116,7 +116,7 @@ message::~message() free(pause_desc); delete(send_scheme); free(recv_request); - if (regexp_compile != NULL) { + if (regexp_compile != nullptr) { regfree(regexp_compile); } free(regexp_compile); @@ -256,7 +256,7 @@ static char* xp_get_keyword_value(const char *name) ERROR("%s \"%s\" looks like a keyword value, but keyword not supplied!", name, ptr); } - return ptr ? strdup(ptr) : NULL; + return ptr ? strdup(ptr) : nullptr; } #endif @@ -612,7 +612,7 @@ int get_cr_number(const char *src) return res; } -static char* clean_cdata(char *ptr, int *removed_crlf = NULL) +static char* clean_cdata(char *ptr, int *removed_crlf = nullptr) { char * msg; @@ -675,7 +675,7 @@ void scenario::checkOptionalRecv(char *elem, unsigned int scenario_file_cursor) scenario::scenario(char * filename, int deflt) { char * elem; - char *method_list = NULL; + char *method_list = nullptr; unsigned int scenario_file_cursor = 0; int L_content_length = 0 ; char * peer; @@ -732,7 +732,7 @@ scenario::scenario(char * filename, int deflt) } else if(!strcmp(elem, "Global")) { ptr = xp_get_string("variables", "Global"); - char ** currentTabVarName = NULL; + char ** currentTabVarName = nullptr; int currentNbVarNames; createStringTable(ptr, ¤tTabVarName, ¤tNbVarNames); @@ -744,7 +744,7 @@ scenario::scenario(char * filename, int deflt) } else if(!strcmp(elem, "User")) { ptr = xp_get_string("variables", "User"); - char ** currentTabVarName = NULL; + char ** currentTabVarName = nullptr; int currentNbVarNames; createStringTable(ptr, ¤tTabVarName, ¤tNbVarNames); @@ -756,7 +756,7 @@ scenario::scenario(char * filename, int deflt) } else if(!strcmp(elem, "Reference")) { ptr = xp_get_string("variables", "Reference"); - char ** currentTabVarName = NULL; + char ** currentTabVarName = nullptr; int currentNbVarNames; createStringTable(ptr, ¤tTabVarName, ¤tNbVarNames); @@ -1060,7 +1060,7 @@ void scenario::runInit() { call *initcall; if (initmessages.size() > 0) { - initcall = new call(main_scenario, NULL, NULL, "///main-init", 0, false, false, true); + initcall = new call(main_scenario, nullptr, nullptr, "///main-init", 0, false, false, true); initcall->run(); } } @@ -1111,7 +1111,7 @@ scenario::~scenario() CSample *parse_distribution(bool oldstyle = false) { - CSample *distribution = NULL; + CSample *distribution = nullptr; const char *distname; const char *ptr = 0; @@ -1217,12 +1217,12 @@ void parse_slave_cfg() f = fopen(slave_cfg_file, "r"); if(f) { - while (fgets(line, MAX_PEER_SIZE, f) != NULL) { + while (fgets(line, MAX_PEER_SIZE, f) != nullptr) { temp_peer = strtok(line, ";"); if (!temp_peer) continue; - temp_host = strtok(NULL, ";"); + temp_host = strtok(nullptr, ";"); if (!temp_host) continue; @@ -1366,7 +1366,7 @@ void scenario::parseAction(CActions *actions) { char * actionElem; unsigned int recvScenarioLen = 0; - char ** currentTabVarName = NULL; + char ** currentTabVarName = nullptr; int currentNbVarNames; int sub_currentNbVarId; char* ptr; @@ -1390,10 +1390,10 @@ void scenario::parseAction(CActions *actions) if (strcmp(cptr, "msg") == 0) { tmpAction->setLookingPlace(CAction::E_LP_MSG); - tmpAction->setLookingChar (NULL); + tmpAction->setLookingChar (nullptr); } else if (strcmp(cptr, "body") == 0) { tmpAction->setLookingPlace(CAction::E_LP_BODY); - tmpAction->setLookingChar (NULL); + tmpAction->setLookingChar (nullptr); } else if (strcmp(cptr, "var") == 0) { tmpAction->setVarInId(xp_get_var("variable", "ereg")); tmpAction->setLookingPlace(CAction::E_LP_VAR); @@ -1415,7 +1415,7 @@ void scenario::parseAction(CActions *actions) } } else { tmpAction->setLookingPlace(CAction::E_LP_MSG); - tmpAction->setLookingChar(NULL); + tmpAction->setLookingChar(nullptr); } // end if-else search_in if (xp_get_value("check_it")) { @@ -1576,7 +1576,7 @@ void scenario::parseAction(CActions *actions) tmpAction->setActionType(CAction::E_AT_VERIFY_AUTH); free(username_ptr); free(password_ptr); - username_ptr = password_ptr = NULL; + username_ptr = password_ptr = nullptr; } else if(!strcmp(actionElem, "lookup")) { tmpAction->setVarId(xp_get_var("assign_to", "lookup")); tmpAction->setMessage(xp_get_string("file", "lookup"), 0); @@ -1791,7 +1791,7 @@ void scenario::getActionForThisMessage(message *message) } /* We actually have an action element. */ - if (message->M_actions != NULL) { + if (message->M_actions != nullptr) { ERROR("Duplicate action for %s index %d", message->desc, message->index); } message->M_actions = new CActions(); @@ -1977,7 +1977,7 @@ int createStringTable(const char* inputString, char*** stringList, int* sizeOfLi return 0; } - *stringList = NULL; + *stringList = nullptr; *sizeOfList = 0; /* FIXME: temporary workaround: needs rewrite */ diff --git a/src/screen.cpp b/src/screen.cpp index 43cc9581b..7e53eece0 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -801,7 +801,7 @@ void ScreenPrinter::draw_repartition_detailed(CStat::T_dynamicalRepartition * ta { unsigned const bufsiz = 80; char buf[bufsiz]; - if(tabRepartition != NULL) { + if(tabRepartition != nullptr) { for(int i=0; i<(sizeOfTab-1); i++) { if(i==0) { DISPLAY_REPART(0, tabRepartition[i].borderMax, @@ -832,7 +832,7 @@ void ScreenPrinter::draw_vars_screen() for (unsigned int i = 0; i < display_scenario->messages.size(); i++) { message* curmsg = display_scenario->messages[i]; actions = curmsg->M_actions; - if (actions != NULL) { + if (actions != nullptr) { switch (curmsg->M_type) { case MSG_TYPE_RECV: snprintf(buf, bufsiz, "=> Message[%u] (Receive Message) - " @@ -853,7 +853,7 @@ void ScreenPrinter::draw_vars_screen() for (int j = 0; j < actions->getActionSize(); j++) { action = actions->getAction(j); - if (action != NULL) { + if (action != nullptr) { int printed = snprintf(buf, bufsiz, " --> action[%d] = ", j); action->printInfo(buf + printed, bufsiz - printed); lines.push_back(buf); diff --git a/src/sip_parser.cpp b/src/sip_parser.cpp index 507c98456..0015be64f 100644 --- a/src/sip_parser.cpp +++ b/src/sip_parser.cpp @@ -58,7 +58,7 @@ static const char* internal_find_header(const char* msg, const char* name, const char* shortname, bool content); static const char* internal_skip_lws(const char* ptr); -/* Search for a character, but only inside this header. Returns NULL if +/* Search for a character, but only inside this header. Returns nullptr if * not found. */ static const char* internal_hdrchr(const char* ptr, const char needle); @@ -84,7 +84,7 @@ char* get_peer_tag(const char* msg) to_hdr = internal_find_header(msg, "To", "t", true); if (!to_hdr) { WARNING("No valid To: header in reply"); - return NULL; + return nullptr; } /* Skip past display-name */ @@ -100,7 +100,7 @@ char* get_peer_tag(const char* msg) /* Find tag in this header */ ptr = internal_find_param(ptr, "tag"); if (!ptr) { - return NULL; + return nullptr; } while (*ptr && *ptr != ' ' && *ptr != ';' && *ptr != '\t' && @@ -243,18 +243,18 @@ char* get_header(const char* message, const char* name, bool content) /* remove enclosed CRs in multilines */ /* don't remove enclosed CRs for multiple headers (e.g. Via) (Rhys) */ - while ((ptr = strstr(last_header, "\r\n")) != NULL && + while ((ptr = strstr(last_header, "\r\n")) != nullptr && (*(ptr + 2) == ' ' || *(ptr + 2) == '\r' || *(ptr + 2) == '\t')) { /* Use strlen(ptr) to include trailing zero */ memmove(ptr, ptr+1, strlen(ptr)); } /* Remove illegal double CR characters */ - while ((ptr = strstr(last_header, "\r\r")) != NULL) { + while ((ptr = strstr(last_header, "\r\r")) != nullptr) { memmove(ptr, ptr+1, strlen(ptr)); } /* Remove illegal double Newline characters */ - while ((ptr = strstr(last_header, "\n\n")) != NULL) { + while ((ptr = strstr(last_header, "\n\n")) != nullptr) { memmove(ptr, ptr+1, strlen(ptr)); } @@ -307,7 +307,7 @@ const char* internal_compact_header_name(const char* name) } else if (!strcasecmp(name, "via:")) { return "\nv:"; } - return NULL; + return nullptr; } char* get_first_line(const char* message) @@ -396,7 +396,7 @@ unsigned long int get_cseq_value(const char* msg) return 0; } - return strtoul(ptr1, NULL, 10); + return strtoul(ptr1, nullptr, 10); } unsigned long get_reply_code(const char* msg) @@ -458,7 +458,7 @@ static const char* internal_find_header(const char* msg, const char* name, const WARNING("Missing CR during header scan at pos %ld", ptr - msg); /* continue? */ } - return NULL; + return nullptr; } ++ptr; } @@ -469,23 +469,23 @@ static const char* internal_find_header(const char* msg, const char* name, const static const char* internal_hdrchr(const char* ptr, const char needle) { if (*ptr == '\n') { - return NULL; /* stray LF */ + return nullptr; /* stray LF */ } while (1) { if (*ptr == '\0') { - return NULL; + return nullptr; } else if (*ptr == needle) { return ptr; } else if (*ptr == '\n') { if (ptr[-1] == '\r' && ptr[1] != ' ' && ptr[1] != '\t') { - return NULL; /* end of header */ + return nullptr; /* end of header */ } } ++ptr; } - return NULL; /* never gets here */ + return nullptr; /* never gets here */ } static const char* internal_hdrend(const char* ptr) @@ -507,13 +507,13 @@ static const char* internal_find_param(const char* ptr, const char* name) while (1) { ptr = internal_hdrchr(ptr, ';'); if (!ptr) { - return NULL; + return nullptr; } ++ptr; ptr = internal_skip_lws(ptr); if (!ptr || !*ptr) { - return NULL; + return nullptr; } /* Case insensitive, see RFC 3261 7.3.1 notes above. */ @@ -523,7 +523,7 @@ static const char* internal_find_param(const char* ptr, const char* name) } } - return NULL; /* never gets here */ + return nullptr; /* never gets here */ } static const char* internal_skip_lws(const char* ptr) @@ -537,11 +537,11 @@ static const char* internal_skip_lws(const char* ptr) ptr += 3; continue; } - return NULL; /* end of this header */ + return nullptr; /* end of this header */ } return ptr; } - return NULL; /* never gets here */ + return nullptr; /* never gets here */ } @@ -679,7 +679,7 @@ From: SIP/2.0/UDP 85.55.55.12:6090;branch=z9hG4bK831a.2bb3de85.0\r\n\ } TEST(Parser, get_peer_tag__notag) { - EXPECT_STREQ(NULL, get_peer_tag("...\r\nTo: \r\n;tag=notag\r\n\r\n")); + EXPECT_STREQ(nullptr, get_peer_tag("...\r\nTo: \r\n;tag=notag\r\n\r\n")); } TEST(Parser, get_peer_tag__normal) { diff --git a/src/sipp.cpp b/src/sipp.cpp index d42eb4577..be13d48a4 100644 --- a/src/sipp.cpp +++ b/src/sipp.cpp @@ -121,14 +121,14 @@ struct sipp_option { /* Put each option, its help text, and type in this table. */ struct sipp_option options_table[] = { - {"h", NULL, SIPP_OPTION_HELP, NULL, 0}, - {"help", NULL, SIPP_OPTION_HELP, NULL, 0}, - - {"", "Scenario file options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, - {"sd", "Dumps a default scenario (embedded in the SIPp executable)", SIPP_OPTION_SCENARIO, NULL, 0}, - {"sf", "Loads an alternate XML scenario file. To learn more about XML scenario syntax, use the -sd option to dump embedded scenarios. They contain all the necessary help.", SIPP_OPTION_SCENARIO, NULL, 2}, - {"oocsf", "Load out-of-call scenario.", SIPP_OPTION_OOC_SCENARIO, NULL, 2}, - {"oocsn", "Load out-of-call scenario.", SIPP_OPTION_OOC_SCENARIO, NULL, 2}, + {"h", nullptr, SIPP_OPTION_HELP, nullptr, 0}, + {"help", nullptr, SIPP_OPTION_HELP, nullptr, 0}, + + {"", "Scenario file options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, + {"sd", "Dumps a default scenario (embedded in the SIPp executable)", SIPP_OPTION_SCENARIO, nullptr, 0}, + {"sf", "Loads an alternate XML scenario file. To learn more about XML scenario syntax, use the -sd option to dump embedded scenarios. They contain all the necessary help.", SIPP_OPTION_SCENARIO, nullptr, 2}, + {"oocsf", "Load out-of-call scenario.", SIPP_OPTION_OOC_SCENARIO, nullptr, 2}, + {"oocsn", "Load out-of-call scenario.", SIPP_OPTION_OOC_SCENARIO, nullptr, 2}, { "sn", "Use a default scenario (embedded in the SIPp executable). If this option is omitted, the Standard SipStone UAC scenario is loaded.\n" "Available values in this version:\n\n" @@ -141,10 +141,10 @@ struct sipp_option options_table[] = { "- '3pcc-C-A' : Controller A side (must be started after all other 3pcc scenarios)\n" "- '3pcc-C-B' : Controller B side.\n" "- '3pcc-A' : A side.\n" - "- '3pcc-B' : B side.\n", SIPP_OPTION_SCENARIO, NULL, 2 + "- '3pcc-B' : B side.\n", SIPP_OPTION_SCENARIO, nullptr, 2 }, - {"", "IP, port and protocol options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "IP, port and protocol options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, { "t", "Set the transport mode:\n" "- u1: UDP with one socket (default),\n" @@ -162,7 +162,7 @@ struct sipp_option options_table[] = { #endif "- c1: u1 + compression (only if compression plugin loaded),\n" "- cn: un + compression (only if compression plugin loaded). This plugin is not provided with SIPp.\n" - , SIPP_OPTION_TRANSPORT, NULL, 1 + , SIPP_OPTION_TRANSPORT, nullptr, 1 }, {"i", "Set the local IP address for 'Contact:','Via:', and 'From:' headers. Default is primary host IP address.\n", SIPP_OPTION_IP, local_ip, 1}, {"p", "Set the local port number. Default is a random free port chosen by the system.", SIPP_OPTION_INT, &user_port, 1}, @@ -172,11 +172,11 @@ struct sipp_option options_table[] = { #endif {"ci", "Set the local control IP address", SIPP_OPTION_IP, control_ip, 1}, {"cp", "Set the local control port number. Default is 8888.", SIPP_OPTION_INT, &control_port, 1}, - {"max_socket", "Set the max number of sockets to open simultaneously. This option is significant if you use one socket per call. Once this limit is reached, traffic is distributed over the sockets already opened. Default value is 50000", SIPP_OPTION_MAX_SOCKET, NULL, 1}, + {"max_socket", "Set the max number of sockets to open simultaneously. This option is significant if you use one socket per call. Once this limit is reached, traffic is distributed over the sockets already opened. Default value is 50000", SIPP_OPTION_MAX_SOCKET, nullptr, 1}, {"max_reconnect", "Set the the maximum number of reconnection.", SIPP_OPTION_INT, &reset_number, 1}, {"reconnect_close", "Should calls be closed on reconnect?", SIPP_OPTION_BOOL, &reset_close, 1}, {"reconnect_sleep", "How long (in milliseconds) to sleep between the close and reconnect?", SIPP_OPTION_TIME_MS, &reset_sleep, 1}, - {"rsa", "Set the remote sending address to host:port for sending the messages.", SIPP_OPTION_RSA, NULL, 1}, + {"rsa", "Set the remote sending address to host:port for sending the messages.", SIPP_OPTION_RSA, nullptr, 1}, #ifdef USE_TLS {"tls_cert", "Set the name for TLS Certificate file. Default is 'cacert.pem'", SIPP_OPTION_STRING, &tls_cert_name, 1}, @@ -185,11 +185,11 @@ struct sipp_option options_table[] = { {"tls_crl", "Set the name for Certificate Revocation List file. If not specified, X509 CRL is not activated.", SIPP_OPTION_STRING, &tls_crl_name, 1}, {"tls_version", "Set the TLS protocol version to use (1.0, 1.1, 1.2, 1.3) -- default is autonegotiate", SIPP_OPTION_FLOAT, &tls_version, 1}, #else - {"tls_cert", NULL, SIPP_OPTION_NEED_SSL, NULL, 1}, - {"tls_key", NULL, SIPP_OPTION_NEED_SSL, NULL, 1}, - {"tls_ca", NULL, SIPP_OPTION_NEED_SSL, NULL, 1}, - {"tls_crl", NULL, SIPP_OPTION_NEED_SSL, NULL, 1}, - {"tls_version", NULL, SIPP_OPTION_NEED_SSL, NULL, 1}, + {"tls_cert", nullptr, SIPP_OPTION_NEED_SSL, nullptr, 1}, + {"tls_key", nullptr, SIPP_OPTION_NEED_SSL, nullptr, 1}, + {"tls_ca", nullptr, SIPP_OPTION_NEED_SSL, nullptr, 1}, + {"tls_crl", nullptr, SIPP_OPTION_NEED_SSL, nullptr, 1}, + {"tls_version", nullptr, SIPP_OPTION_NEED_SSL, nullptr, 1}, #endif #ifdef USE_SCTP @@ -200,38 +200,38 @@ struct sipp_option options_table[] = { {"pmtu", "Set path MTU for SCTP", SIPP_OPTION_INT, &pmtu, 1}, {"gracefulclose", "If true, SCTP association will be closed with SHUTDOWN (default).\n If false, SCTP association will be closed by ABORT.\n", SIPP_OPTION_BOOL, &gracefulclose, 1}, #else - {"multihome", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1}, - {"heartbeat", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1}, - {"assocmaxret", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1}, - {"pathmaxret", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1}, - {"pmtu", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1}, - {"gracefulclose", NULL, SIPP_OPTION_NEED_SCTP, NULL, 1}, + {"multihome", nullptr, SIPP_OPTION_NEED_SCTP, nullptr, 1}, + {"heartbeat", nullptr, SIPP_OPTION_NEED_SCTP, nullptr, 1}, + {"assocmaxret", nullptr, SIPP_OPTION_NEED_SCTP, nullptr, 1}, + {"pathmaxret", nullptr, SIPP_OPTION_NEED_SCTP, nullptr, 1}, + {"pmtu", nullptr, SIPP_OPTION_NEED_SCTP, nullptr, 1}, + {"gracefulclose", nullptr, SIPP_OPTION_NEED_SCTP, nullptr, 1}, #endif - {"", "SIPp overall behavior options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, - {"v", "Display version and copyright information.", SIPP_OPTION_VERSION, NULL, 0}, + {"", "SIPp overall behavior options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, + {"v", "Display version and copyright information.", SIPP_OPTION_VERSION, nullptr, 0}, {"bg", "Launch SIPp in background mode.", SIPP_OPTION_SETFLAG, &backgroundMode, 1}, {"nostdin", "Disable stdin.\n", SIPP_OPTION_SETFLAG, &nostdin, 1}, - {"plugin", "Load a plugin.", SIPP_OPTION_PLUGIN, NULL, 1}, + {"plugin", "Load a plugin.", SIPP_OPTION_PLUGIN, nullptr, 1}, {"sleep", "How long to sleep for at startup. Default unit is seconds.", SIPP_OPTION_TIME_SEC, &sleeptime, 1}, {"skip_rlimit", "Do not perform rlimit tuning of file descriptor limits. Default: false.", SIPP_OPTION_SETFLAG, &skip_rlimit, 1}, {"buff_size", "Set the send and receive buffer size.", SIPP_OPTION_INT, &buff_size, 1}, {"sendbuffer_warn", "Produce warnings instead of errors on SendBuffer failures.", SIPP_OPTION_BOOL, &sendbuffer_warn, 1}, {"lost", "Set the number of packets to lose by default (scenario specifications override this value).", SIPP_OPTION_FLOAT, &global_lost, 1}, - {"key", "keyword value\nSet the generic parameter named \"keyword\" to \"value\".", SIPP_OPTION_KEY, NULL, 1}, - {"set", "variable value\nSet the global variable parameter named \"variable\" to \"value\".", SIPP_OPTION_VAR, NULL, 3}, + {"key", "keyword value\nSet the generic parameter named \"keyword\" to \"value\".", SIPP_OPTION_KEY, nullptr, 1}, + {"set", "variable value\nSet the global variable parameter named \"variable\" to \"value\".", SIPP_OPTION_VAR, nullptr, 3}, {"tdmmap", "Generate and handle a table of TDM circuits.\n" "A circuit must be available for the call to be placed.\n" - "Format: -tdmmap {0-3}{99}{5-8}{1-31}", SIPP_OPTION_TDMMAP, NULL, 1}, + "Format: -tdmmap {0-3}{99}{5-8}{1-31}", SIPP_OPTION_TDMMAP, nullptr, 1}, {"dynamicStart", "variable value\nSet the start offset of dynamic_id variable", SIPP_OPTION_INT, &startDynamicId, 1}, {"dynamicMax", "variable value\nSet the maximum of dynamic_id variable ", SIPP_OPTION_INT, &maxDynamicId, 1}, {"dynamicStep", "variable value\nSet the increment of dynamic_id variable", SIPP_OPTION_INT, &stepDynamicId, 1}, - {"", "Call behavior options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "Call behavior options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, {"aa", "Enable automatic 200 OK answer for INFO, NOTIFY, OPTIONS and UPDATE.", SIPP_OPTION_SETFLAG, &auto_answer, 1}, - {"base_cseq", "Start value of [cseq] for each call.", SIPP_OPTION_CSEQ, NULL, 1}, + {"base_cseq", "Start value of [cseq] for each call.", SIPP_OPTION_CSEQ, nullptr, 1}, {"cid_str", "Call ID string (default %u-%p@%s). %u=call_number, %s=ip_address, %p=process_number, %%=% (in any order).", SIPP_OPTION_STRING, &call_id_string, 1}, {"d", "Controls the length of calls. More precisely, this controls the duration of 'pause' instructions in the scenario, if they do not have a 'milliseconds' section. Default value is 0 and default unit is milliseconds.", SIPP_OPTION_TIME_MS, &duration, 1}, {"deadcall_wait", "How long the Call-ID and final status of calls should be kept to improve message and error logs (default unit is ms).", SIPP_OPTION_TIME_MS, &deadcall_wait, 1}, @@ -262,17 +262,17 @@ struct sipp_option options_table[] = { {"callid_slash_ign", "Don't treat a triple-slash in Call-IDs as indicating an extra SIPp prefix.", SIPP_OPTION_SETFLAG, &callidSlash, 1}, - {"", "Injection file options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "Injection file options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, {"inf", "Inject values from an external CSV file during calls into the scenarios.\n" "First line of this file say whether the data is to be read in sequence (SEQUENTIAL), random (RANDOM), or user (USER) order.\n" - "Each line corresponds to one call and has one or more ';' delimited data fields. Those fields can be referred as [field0], [field1], ... in the xml scenario file. Several CSV files can be used simultaneously (syntax: -inf f1.csv -inf f2.csv ...)", SIPP_OPTION_INPUT_FILE, NULL, 1}, - {"infindex", "file field\nCreate an index of file using field. For example -inf ../path/to/users.csv -infindex users.csv 0 creates an index on the first key.", SIPP_OPTION_INDEX_FILE, NULL, 1 }, + "Each line corresponds to one call and has one or more ';' delimited data fields. Those fields can be referred as [field0], [field1], ... in the xml scenario file. Several CSV files can be used simultaneously (syntax: -inf f1.csv -inf f2.csv ...)", SIPP_OPTION_INPUT_FILE, nullptr, 1}, + {"infindex", "file field\nCreate an index of file using field. For example -inf ../path/to/users.csv -infindex users.csv 0 creates an index on the first key.", SIPP_OPTION_INDEX_FILE, nullptr, 1 }, {"ip_field", "Set which field from the injection file contains the IP address from which the client will send its messages.\n" "If this option is omitted and the '-t ui' option is present, then field 0 is assumed.\n" "Use this option together with '-t ui'", SIPP_OPTION_INT, &peripfield, 1}, - {"", "RTP behaviour options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "RTP behaviour options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, {"mi", "Set the local media IP address (default: local primary host IP address)", SIPP_OPTION_IP, media_ip, 1}, {"rtp_echo", "Enable RTP echo. RTP/UDP packets received on media port are echoed to their sender.\n" "RTP/UDP packets coming on this port + 2 are also echoed to their sender (used for sound and video echo).", @@ -280,7 +280,7 @@ struct sipp_option options_table[] = { {"mb", "Set the RTP echo buffer size (default: 2048).", SIPP_OPTION_INT, &media_bufsize, 1}, {"min_rtp_port", "Minimum port number for RTP socket range.", SIPP_OPTION_INT, &min_rtp_port, 1}, {"max_rtp_port", "Maximum port number for RTP socket range.", SIPP_OPTION_INT, &max_rtp_port, 1}, - {"mp", NULL, SIPP_OPTION_INT, &min_rtp_port, 1}, + {"mp", nullptr, SIPP_OPTION_INT, &min_rtp_port, 1}, {"rtp_payload", "RTP default payload type.", SIPP_OPTION_INT, &rtp_default_payload, 1}, {"rtp_threadtasks", "RTP number of playback tasks per thread.", SIPP_OPTION_INT, &rtp_tasks_per_thread, 1}, {"rtp_buffsize", "Set the rtp socket send/receive buffer size.", SIPP_OPTION_INT, &rtp_buffsize, 1}, @@ -291,7 +291,7 @@ struct sipp_option options_table[] = { {"audiotolerance", "Audio error tolerance for RTP checks (0.0-1.0) -- default: 1.0", SIPP_OPTION_FLOAT, &audiotolerance, 1}, {"videotolerance", "Video error tolerance for RTP checks (0.0-1.0) -- default: 1.0", SIPP_OPTION_FLOAT, &videotolerance, 1}, - {"", "Call rate options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "Call rate options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, {"r", "Set the call rate (in calls per seconds). This value can be" "changed during test by pressing '+', '_', '*' or '/'. Default is 10.\n" "pressing '+' key to increase call rate by 1 * rate_scale,\n" @@ -313,12 +313,12 @@ struct sipp_option options_table[] = { {"no_rate_quit", "If -rate_increase is set, do not quit after the rate reaches -rate_max.", SIPP_OPTION_UNSETFLAG, &rate_quit, 1}, {"l", "Set the maximum number of simultaneous calls. Once this limit is reached, traffic is decreased until the number of open calls goes down. Default:\n" - " (3 * call_duration (s) * rate).", SIPP_OPTION_LIMIT, NULL, 1}, + " (3 * call_duration (s) * rate).", SIPP_OPTION_LIMIT, nullptr, 1}, {"m", "Stop the test and exit when 'calls' calls are processed", SIPP_OPTION_LONG, &stop_after, 1}, - {"users", "Instead of starting calls at a fixed rate, begin 'users' calls at startup, and keep the number of calls constant.", SIPP_OPTION_USERS, NULL, 1}, + {"users", "Instead of starting calls at a fixed rate, begin 'users' calls at startup, and keep the number of calls constant.", SIPP_OPTION_USERS, nullptr, 1}, - {"", "Retransmission and timeout options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "Retransmission and timeout options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, {"recv_timeout", "Global receive timeout. Default unit is milliseconds. If the expected message is not received, the call times out and is aborted.", SIPP_OPTION_TIME_MS_LONG, &defl_recv_timeout, 1}, {"send_timeout", "Global send timeout. Default unit is milliseconds. If a message is not sent (due to congestion), the call times out and is aborted.", SIPP_OPTION_TIME_MS_LONG, &defl_send_timeout, 1}, {"timeout", "Global timeout. Default unit is seconds. If this option is set, SIPp quits after nb units (-timeout 20s quits after 20 seconds).", SIPP_OPTION_TIME_SEC, &global_timeout, 1}, @@ -331,17 +331,17 @@ struct sipp_option options_table[] = { {"T2", "Global T2-timer in milli seconds", SIPP_OPTION_TIME_MS, &global_t2, 1}, - {"", "Third-party call control options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "Third-party call control options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, {"3pcc", "Launch the tool in 3pcc mode (\"Third Party call control\"). The passed IP address depends on the 3PCC role.\n" "- When the first twin command is 'sendCmd' then this is the address of the remote twin socket. SIPp will try to connect to this address:port to send the twin command (This instance must be started after all other 3PCC scenarios).\n" " Example: 3PCC-C-A scenario.\n" "- When the first twin command is 'recvCmd' then this is the address of the local twin socket. SIPp will open this address:port to listen for twin command.\n" - " Example: 3PCC-C-B scenario.", SIPP_OPTION_3PCC, NULL, 1}, + " Example: 3PCC-C-B scenario.", SIPP_OPTION_3PCC, nullptr, 1}, {"master","3pcc extended mode: indicates the master number", SIPP_OPTION_3PCC_EXTENDED, &master_name, 1}, {"slave", "3pcc extended mode: indicates the slave number", SIPP_OPTION_3PCC_EXTENDED, &slave_number, 1}, - {"slave_cfg", "3pcc extended mode: indicates the file where the master and slave addresses are stored", SIPP_OPTION_SLAVE_CFG, NULL, 1}, + {"slave_cfg", "3pcc extended mode: indicates the file where the master and slave addresses are stored", SIPP_OPTION_SLAVE_CFG, nullptr, 1}, - {"", "Performance and watchdog options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "Performance and watchdog options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, {"timer_resol", "Set the timer resolution. Default unit is milliseconds. This option has an impact on timers precision." "Small values allow more precise scheduling but impacts CPU usage." "If the compression is on, the value is set to 50ms. The default value is 10ms.", SIPP_OPTION_TIME_MS, &timer_resolution, 1}, @@ -356,7 +356,7 @@ struct sipp_option options_table[] = { {"watchdog_minor_maxtriggers", "How many times the minor watchdog timer can be tripped before the test is terminated. Default is 120.", SIPP_OPTION_INT, &watchdog_minor_maxtriggers, 1}, - {"", "Tracing, logging and statistics options:", SIPP_HELP_TEXT_HEADER, NULL, 0}, + {"", "Tracing, logging and statistics options:", SIPP_HELP_TEXT_HEADER, nullptr, 0}, {"f", "Set the statistics report frequency on screen. Default is 1 and default unit is seconds.", SIPP_OPTION_TIME_SEC, &report_freq, 1}, {"trace_stat", "Dumps all statistics in _.csv file. Use the '-h stat' option for a detailed description of the statistics file content.", SIPP_OPTION_SETFLAG, &dumpInFile, 1}, @@ -411,7 +411,7 @@ static struct sipp_option *find_option(const char* option) { /* Allow options to start with '-' or '--' */ if (option[0] != '-') { - return NULL; + return nullptr; } option++; if (option[0] == '-') { @@ -424,7 +424,7 @@ static struct sipp_option *find_option(const char* option) { } } - return NULL; + return nullptr; } /******************** Recv Poll Processing *********************/ @@ -529,9 +529,9 @@ static void traffic_thread(int &rtp_errors, int &echo_errors) for (int i = pollnfds - 1; i >= 0; --i) { sockets[i]->close(); if (sockets[i] == ctrl_socket) { - ctrl_socket = NULL; + ctrl_socket = nullptr; } else if (sockets[i] == stdin_socket) { - stdin_socket = NULL; + stdin_socket = nullptr; } } @@ -573,14 +573,14 @@ static void traffic_thread(int &rtp_errors, int &echo_errors) * leads to iterate again on the destroyed (deleted) * object. Thus, we have to wait ont step befere actual * deletion of the object*/ - task * last = NULL; + task * last = nullptr; task_list::iterator iter; for (iter = running_tasks->begin(); iter != running_tasks->end(); iter++) { if (last) { last->run(); if (sockets_pending_reset.begin() != sockets_pending_reset.end()) { - last = NULL; + last = nullptr; break; } } @@ -620,7 +620,7 @@ static void rtp_echo_thread(void* param) int rc; sigset_t mask; sigfillset(&mask); /* Mask all allowed signals */ - rc = pthread_sigmask(SIG_BLOCK, &mask, NULL); + rc = pthread_sigmask(SIG_BLOCK, &mask, nullptr); if (rc) { WARNING("pthread_sigmask returned %d", rc); return; @@ -757,7 +757,7 @@ static char* wrap(const char* in, int offset, int size) * Returns a pid_t you'll have to pass to end_pager(). */ static pid_t begin_pager() { char pager[15] = "/usr/bin/pager"; - char *argv[2] = {NULL, NULL}; + char *argv[2] = {nullptr, nullptr}; int stdout_fd = fileno(stdout); int read_write[2]; @@ -1023,8 +1023,8 @@ static void print_last_stats() static void stop_all_traces() { - message_lfi.fptr = NULL; - log_lfi.fptr = NULL; + message_lfi.fptr = nullptr; + log_lfi.fptr = nullptr; dumpInRtt = 0; dumpInFile = 0; } @@ -1040,7 +1040,7 @@ static void freeUserVarMap() { for (int_vt_map::iterator vt_it = userVarMap.begin(); vt_it != userVarMap.end(); vt_it++) { vt_it->second->putTable(); - userVarMap[vt_it->first] = NULL; + userVarMap[vt_it->first] = nullptr; } } @@ -1072,7 +1072,7 @@ static void manage_oversized_file(int signum) fflush(f); stop_all_traces(); print_all_responses = 0; - error_lfi.fptr = NULL; + error_lfi.fptr = nullptr; } static void releaseGlobalAllocations() @@ -1108,17 +1108,17 @@ void sipp_exit(int rc, int rtp_errors, int echo_errors) print_errors(); if (sp) { delete sp; - sp = NULL; + sp = nullptr; } /* Close open files. */ struct logfile_info** logfile_ptr; struct logfile_info* logfiles[] = { - &screen_lfi, &calldebug_lfi, &message_lfi, &shortmessage_lfi, &log_lfi, &error_lfi, NULL}; + &screen_lfi, &calldebug_lfi, &message_lfi, &shortmessage_lfi, &log_lfi, &error_lfi, nullptr}; for (logfile_ptr = logfiles; *logfile_ptr; ++logfile_ptr) { if ((*logfile_ptr)->fptr) { fclose((*logfile_ptr)->fptr); - (*logfile_ptr)->fptr = NULL; + (*logfile_ptr)->fptr = nullptr; } } @@ -1172,9 +1172,9 @@ static void sighandle_set() action_quit.sa_handler = sipp_sighandler; action_file_size_exceeded.sa_handler = manage_oversized_file; - sigaction(SIGTERM, &action_quit, NULL); - sigaction(SIGINT, &action_quit, NULL); - sigaction(SIGXFSZ, &action_file_size_exceeded, NULL); // avoid core dump if the max file size is exceeded + sigaction(SIGTERM, &action_quit, nullptr); + sigaction(SIGINT, &action_quit, nullptr); + sigaction(SIGXFSZ, &action_file_size_exceeded, nullptr); // avoid core dump if the max file size is exceeded } static void set_scenario(const char* name) @@ -1284,7 +1284,7 @@ static void setup_media_sockets() /* Resolving local IP */ if (getaddrinfo(media_ip, - NULL, + nullptr, &hints, &local_addr) != 0) { ERROR("Unknown RTP address '%s'.\n" @@ -1329,7 +1329,7 @@ int main(int argc, char *argv[]) rtp_errors = 0; echo_errors = 0; - srand(time(NULL)); + srand(time(nullptr)); /* At least one argument is needed */ if (argc < 2) { @@ -1341,24 +1341,24 @@ int main(int argc, char *argv[]) struct sigaction action_pipe; memset(&action_pipe, 0, sizeof(action_pipe)); action_pipe.sa_handler=SIG_IGN; - sigaction(SIGPIPE, &action_pipe, NULL); + sigaction(SIGPIPE, &action_pipe, nullptr); /* The Window Size change Signal is also useless, and causes failures. */ #ifdef SIGWINCH - sigaction(SIGWINCH, &action_pipe, NULL); + sigaction(SIGWINCH, &action_pipe, nullptr); #endif /* sig usr1 management */ struct sigaction action_usr1; memset(&action_usr1, 0, sizeof(action_usr1)); action_usr1.sa_handler = sipp_sigusr1; - sigaction(SIGUSR1, &action_usr1, NULL); + sigaction(SIGUSR1, &action_usr1, nullptr); /* sig usr2 management */ struct sigaction action_usr2; memset(&action_usr2, 0, sizeof(action_usr2)); action_usr2.sa_handler = sipp_sigusr2; - sigaction(SIGUSR2, &action_usr2, NULL); + sigaction(SIGUSR2, &action_usr2, nullptr); } pid = getpid(); @@ -1370,7 +1370,7 @@ int main(int argc, char *argv[]) memset(control_ip, 0, sizeof(control_ip)); /* Initialize our global variable structure. */ - globalVariables = new AllocVariableTable(NULL); + globalVariables = new AllocVariableTable(nullptr); userVariables = new AllocVariableTable(globalVariables); /* Command line parsing */ @@ -1843,7 +1843,7 @@ int main(int argc, char *argv[]) assert(0); } } - token = NULL; + token = nullptr; } break; } @@ -1917,8 +1917,8 @@ int main(int argc, char *argv[]) } /* If no scenario was selected, choose the uac one */ - if (scenario_file == NULL) { - assert(main_scenario == NULL); + if (scenario_file == nullptr) { + assert(main_scenario == nullptr); int i = find_scenario("uac"); set_scenario("uac"); main_scenario = new scenario(0, i); @@ -2132,7 +2132,7 @@ int main(int argc, char *argv[]) } if (rtp_echo_enabled && media_socket_audio > 0) { - if (pthread_create(&pthread2_id, NULL, + if (pthread_create(&pthread2_id, nullptr, (void *(*)(void *))rtp_echo_thread, &media_socket_audio) == -1) { ERROR_NO("Unable to create RTP echo thread"); } @@ -2140,7 +2140,7 @@ int main(int argc, char *argv[]) /* Creating second RTP echo thread for video. */ if (rtp_echo_enabled && media_socket_video > 0) { - if (pthread_create(&pthread3_id, NULL, + if (pthread_create(&pthread3_id, nullptr, (void *(*)(void *)) rtp_echo_thread, &media_socket_video) == -1) { ERROR_NO("Unable to create video RTP echo thread"); } @@ -2151,10 +2151,10 @@ int main(int argc, char *argv[]) /* Cancel and join other threads. */ run_echo_thread.store(false, std::memory_order_relaxed); if (pthread2_id) { - pthread_join(pthread2_id, NULL); + pthread_join(pthread2_id, nullptr); } if (pthread3_id) { - pthread_join(pthread3_id, NULL); + pthread_join(pthread3_id, nullptr); } #ifdef HAVE_EPOLL diff --git a/src/sipp_unittest.cpp b/src/sipp_unittest.cpp index a62cb0f64..aa599315e 100644 --- a/src/sipp_unittest.cpp +++ b/src/sipp_unittest.cpp @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) { - globalVariables = new AllocVariableTable(NULL); + globalVariables = new AllocVariableTable(nullptr); userVariables = new AllocVariableTable(globalVariables); main_scenario = new scenario(0, 0); diff --git a/src/socket.cpp b/src/socket.cpp index 79ab392dd..f5dff4e33 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -47,8 +47,8 @@ extern bool do_hide; -SIPpSocket *ctrl_socket = NULL; -SIPpSocket *stdin_socket = NULL; +SIPpSocket *ctrl_socket = nullptr; +SIPpSocket *stdin_socket = nullptr; static int stdin_fileno = -1; static int stdin_mode; @@ -313,7 +313,7 @@ static bool process_command(char* command) } int command_mode = 0; -char *command_buffer = NULL; +char *command_buffer = nullptr; extern bool sipMsgCheck (const char *P_msg, SIPpSocket *socket); @@ -341,7 +341,7 @@ static const char* get_trimmed_call_id(const char* msg) static char* get_inet_address(const struct sockaddr_storage* addr, char* dst, int len) { if (getnameinfo(_RCAST(struct sockaddr*, addr), socklen_from_addr(addr), - dst, len, NULL, 0, NI_NUMERICHOST) != 0) { + dst, len, nullptr, 0, NI_NUMERICHOST) != 0) { snprintf(dst, len, "addr not supported"); } return dst; @@ -565,7 +565,7 @@ void handle_stdin_socket() if (feof(stdin)) { stdin_socket->close(); - stdin_socket = NULL; + stdin_socket = nullptr; return; } @@ -623,7 +623,7 @@ void handle_stdin_socket() if (chars == 0) { /* We did not read any characters, even though we should have. */ stdin_socket->close(); - stdin_socket = NULL; + stdin_socket = nullptr; } } @@ -781,7 +781,7 @@ int SIPpSocket::check_for_message() if (socketbuf->offset + len + content_length < socketbuf->len) { return len + content_length + 1; } - if (socketbuf->next == NULL) { + if (socketbuf->next == nullptr) { /* There is no buffer to merge, so we fail. */ return 0; } @@ -863,7 +863,7 @@ int SIPpSocket::empty() if (!buffer) { ERROR("Could not allocate memory for read!"); } - socketbuf = alloc_socketbuf(buffer, readsize, NO_COPY, NULL); + socketbuf = alloc_socketbuf(buffer, readsize, NO_COPY, nullptr); switch(ss_transport) { case T_TCP: @@ -935,7 +935,7 @@ void SIPpSocket::invalidate() /* In some error conditions, the socket FD has already been closed - if it hasn't, do so now. */ if (ss_fd != -1) { #ifdef HAVE_EPOLL - int rc = epoll_ctl(epollfd, EPOLL_CTL_DEL, ss_fd, NULL); + int rc = epoll_ctl(epollfd, EPOLL_CTL_DEL, ss_fd, nullptr); if (rc == -1) { WARNING_NO("Failed to delete FD from epoll"); } @@ -996,7 +996,7 @@ void SIPpSocket::invalidate() sockets[pollidx] = sockets[pollnfds]; sockets[pollidx]->ss_pollidx = pollidx; } - sockets[pollnfds] = NULL; + sockets[pollnfds] = nullptr; if (ss_msglen) { pending_messages--; @@ -1248,26 +1248,26 @@ SIPpSocket::SIPpSocket(bool use_ipv6, int transport, int fd, int accepting): ss_control(false), ss_fd(fd), ss_bind_port(0), - ss_comp_state(NULL), + ss_comp_state(nullptr), ss_changed_dest(false), ss_congested(false), ss_invalid(false), - ss_in(NULL), - ss_out(NULL), - ss_out_tail(NULL), + ss_in(nullptr), + ss_out(nullptr), + ss_out_tail(nullptr), ss_msglen(0) { /* Initialize all sockets with our destination address. */ memcpy(&ss_dest, &remote_sockaddr, sizeof(ss_dest)); #if defined(USE_OPENSSL) || defined(USE_WOLFSSL) - ss_ssl = NULL; + ss_ssl = nullptr; if (transport == T_TLS) { int flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags | O_NONBLOCK); - if ((ss_bio = BIO_new_socket(fd, BIO_NOCLOSE)) == NULL) { + if ((ss_bio = BIO_new_socket(fd, BIO_NOCLOSE)) == nullptr) { ERROR("Unable to create BIO object:Problem with BIO_new_socket()"); } @@ -1354,7 +1354,7 @@ SIPpSocket *new_sipp_socket(bool use_ipv6, int transport) { } SIPpSocket* SIPpSocket::new_sipp_call_socket(bool use_ipv6, int transport, bool *existing) { - SIPpSocket *sock = NULL; + SIPpSocket *sock = nullptr; static int next_socket; if (pollnfds >= max_multi_socket) { // we must take the main socket into account /* Find an existing socket that matches transport and ipv6 parameters. */ @@ -1609,10 +1609,10 @@ int SIPpSocket::reconnect() if (ss_invalid) { #if defined(USE_OPENSSL) || defined(USE_WOLFSSL) - ss_ssl = NULL; + ss_ssl = nullptr; if (transport == T_TLS) { - if ((ss_bio = BIO_new_socket(ss_fd, BIO_NOCLOSE)) == NULL) { + if ((ss_bio = BIO_new_socket(ss_fd, BIO_NOCLOSE)) == nullptr) { ERROR("Unable to create BIO object:Problem with BIO_new_socket()"); } @@ -1685,7 +1685,7 @@ struct socketbuf *alloc_socketbuf(char *buffer, size_t size, int copy, struct so if (dest) { memcpy(&socketbuf->addr, dest, sizeof(*dest)); } - socketbuf->next = NULL; + socketbuf->next = nullptr; return socketbuf; } @@ -2027,7 +2027,7 @@ static int send_nowait_tls(SSL* ssl, const void* msg, int len, int /*flags*/) if ((fd = SSL_get_fd(ssl)) == -1) { return -1; } - fd_flags = fcntl(fd, F_GETFL, NULL); + fd_flags = fcntl(fd, F_GETFL, nullptr); initial_fd_flags = fd_flags; fd_flags |= O_NONBLOCK; fcntl(fd, F_SETFL, fd_flags); @@ -2057,7 +2057,7 @@ static int send_nowait(int s, const void* msg, int len, int flags) #if defined(MSG_DONTWAIT) && !defined(__SUNOS) return send(s, msg, len, flags | MSG_DONTWAIT); #else - int fd_flags = fcntl(s, F_GETFL , NULL); + int fd_flags = fcntl(s, F_GETFL , nullptr); int initial_fd_flags; int rc; @@ -2085,7 +2085,7 @@ int send_sctp_nowait(int s, const void *msg, int len, int flags) #if defined(MSG_DONTWAIT) && !defined(__SUNOS) return sctp_send(s, msg, len, &sinfo, flags | MSG_DONTWAIT); #else - int fd_flags = fcntl(s, F_GETFL, NULL); + int fd_flags = fcntl(s, F_GETFL, nullptr); int initial_fd_flags; int rc; @@ -2314,7 +2314,7 @@ void SIPpSocket::close_calls() { owner_list *owners = get_owners_for_socket(this); owner_list::iterator owner_it; - socketowner *owner_ptr = NULL; + socketowner *owner_ptr = nullptr; for (owner_it = owners->begin(); owner_it != owners->end(); owner_it++) { owner_ptr = *owner_it; @@ -2356,7 +2356,7 @@ int open_connections() struct addrinfo * local_addr; int ret; if (strlen(local_ip)) { - if ((ret = getaddrinfo(local_ip, NULL, &hints, &local_addr)) != 0) { + if ((ret = getaddrinfo(local_ip, nullptr, &hints, &local_addr)) != 0) { ERROR("Can't get local IP address in getaddrinfo, " "local_ip='%s', ret=%d", local_ip, ret); } @@ -2419,7 +2419,7 @@ int open_connections() } /* Resolving local IP */ - if ((ret = getaddrinfo(local_ip, NULL, &hints, &local_addr)) != 0) { + if ((ret = getaddrinfo(local_ip, nullptr, &hints, &local_addr)) != 0) { switch (ret) { #ifdef EAI_ADDRFAMILY case EAI_ADDRFAMILY: @@ -2472,7 +2472,7 @@ int open_connections() } /* Creating and binding the local socket */ - if ((main_socket = new_sipp_socket(local_ip_is_ipv6, transport)) == NULL) { + if ((main_socket = new_sipp_socket(local_ip_is_ipv6, transport)) == nullptr) { ERROR_NO("Unable to get the local socket"); } @@ -2578,12 +2578,12 @@ int open_connections() bool is_ipv6 = (server_sockaddr.ss_family == AF_INET6); - if ((sock = new_sipp_socket(is_ipv6, transport)) == NULL) { + if ((sock = new_sipp_socket(is_ipv6, transport)) == nullptr) { ERROR_NO("Unable to get server socket"); } sipp_customize_socket(sock); - if (sipp_bind_socket(sock, &server_sockaddr, NULL)) { + if (sipp_bind_socket(sock, &server_sockaddr, nullptr)) { ERROR_NO("Unable to bind server socket"); } @@ -2594,7 +2594,7 @@ int open_connections() if ((!multisocket) && (transport == T_TCP || transport == T_TLS || transport == T_SCTP) && (sendMode != MODE_SERVER)) { - if ((tcp_multiplex = new_sipp_socket(local_ip_is_ipv6, transport)) == NULL) { + if ((tcp_multiplex = new_sipp_socket(local_ip_is_ipv6, transport)) == nullptr) { ERROR_NO("Unable to get a TCP socket"); } @@ -2611,7 +2611,7 @@ int open_connections() sipp_customize_socket(tcp_multiplex); /* This fixes local_port keyword value when transport are TCP|TLS and it's defined by user with "-p" */ - if (sipp_bind_socket(tcp_multiplex, &local_sockaddr, NULL)) { + if (sipp_bind_socket(tcp_multiplex, &local_sockaddr, nullptr)) { ERROR_NO("Unable to bind TCP socket"); } @@ -2619,7 +2619,7 @@ int open_connections() if (reset_number > 0) { WARNING("Failed to reconnect"); main_socket->close(); - main_socket = NULL; + main_socket = nullptr; reset_number--; return 1; } else { @@ -2694,7 +2694,7 @@ static void connect_to_peer( get_inet_address(peer_sockaddr, peer_ip, peer_ip_size); - if ((*peer_socket = new_sipp_socket(is_ipv6, T_TCP)) == NULL) { + if ((*peer_socket = new_sipp_socket(is_ipv6, T_TCP)) == nullptr) { ERROR_NO("Unable to get a twin sipp TCP socket"); } @@ -2725,7 +2725,7 @@ SIPpSocket **get_peer_socket(char * peer) { } else { ERROR("get_peer_socket: Peer %s not found", peer); } - return NULL; + return nullptr; } char * get_peer_addr(char * peer) @@ -2739,7 +2739,7 @@ char * get_peer_addr(char * peer) } else { ERROR("get_peer_addr: Peer %s not found", peer); } - return NULL; + return nullptr; } bool is_a_peer_socket(SIPpSocket *peer_socket) @@ -2772,7 +2772,7 @@ void connect_local_twin_socket(char * twinSippHost) get_inet_address(&twinSipp_sockaddr, twinSippIp, sizeof(twinSippIp)); - if ((localTwinSippSocket = new_sipp_socket(is_ipv6, T_TCP)) == NULL) { + if ((localTwinSippSocket = new_sipp_socket(is_ipv6, T_TCP)) == nullptr) { ERROR_NO("Unable to get a listener TCP socket "); } @@ -2798,7 +2798,7 @@ void close_peer_sockets() ++peer_it) { T_peer_infos infos = peer_it->second; infos.peer_socket->close(); - infos.peer_socket = NULL; + infos.peer_socket = nullptr; peers[std::string(peer_it->first)] = infos; } @@ -2809,7 +2809,7 @@ void close_local_sockets() { for (int i = 0; i< local_nb; i++) { local_sockets[i]->close(); - local_sockets[i] = NULL; + local_sockets[i] = nullptr; } } @@ -3094,7 +3094,7 @@ bool sipMsgCheck (const char *P_msg, SIPpSocket *socket) is_a_peer_socket(socket) || is_a_local_socket(socket)) return true; - if (strstr(P_msg, C_sipHeader) != NULL) { + if (strstr(P_msg, C_sipHeader) != nullptr) { return true; } diff --git a/src/socketowner.cpp b/src/socketowner.cpp index 288301d24..5b72b66dc 100644 --- a/src/socketowner.cpp +++ b/src/socketowner.cpp @@ -59,7 +59,7 @@ SIPpSocket *socketowner::dissociate_socket() { SIPpSocket *ret = this->call_socket; remove_owner_from_socket(this->call_socket); - this->call_socket = NULL; + this->call_socket = nullptr; return ret; } @@ -68,7 +68,7 @@ unsigned long socketowner::nextownerid = 1; socketowner::socketowner() { - this->call_socket = NULL; + this->call_socket = nullptr; this->ownerid = socketowner::nextownerid++; } diff --git a/src/sslsocket.cpp b/src/sslsocket.cpp index 567061803..8c411808c 100644 --- a/src/sslsocket.cpp +++ b/src/sslsocket.cpp @@ -27,18 +27,18 @@ #define CALL_BACK_USER_DATA "ksgr" -static SSL_CTX* sip_trp_ssl_ctx = NULL; /* For SSL cserver context */ -static SSL_CTX* sip_trp_ssl_ctx_client = NULL; /* For SSL cserver context */ +static SSL_CTX* sip_trp_ssl_ctx = nullptr; /* For SSL cserver context */ +static SSL_CTX* sip_trp_ssl_ctx_client = nullptr; /* For SSL cserver context */ #if defined(USE_OPENSSL) && OPENSSL_VERSION_NUMBER < 0x10100000 #define MUTEX_TYPE pthread_mutex_t -#define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL) +#define MUTEX_SETUP(x) pthread_mutex_init(&(x), nullptr) #define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x)) #define MUTEX_LOCK(x) pthread_mutex_lock(&(x)) #define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x)) #define THREAD_ID pthread_self() -static MUTEX_TYPE *mutex_buf = NULL; +static MUTEX_TYPE *mutex_buf = nullptr; static void locking_function(int mode, int n, const char *file, int line) { @@ -196,7 +196,7 @@ static int sip_tls_load_crls(SSL_CTX* ctx , const char* crlfile) static SSL_CTX* instantiate_ssl_context(const char* context_name) { - SSL_CTX* ssl_ctx = NULL; + SSL_CTX* ssl_ctx = nullptr; #if OPENSSL_VERSION_NUMBER >= 0x10100000 /* >= 1.1 */ @@ -214,7 +214,7 @@ static SSL_CTX* instantiate_ssl_context(const char* context_name) max_tls_version = min_tls_version = TLS1_VERSION; #else ERROR("Old TLS version 1.0 is no longer supported for [%s] context.", context_name); - return NULL; + return nullptr; #endif } else if (tls_version == 1.1) { max_tls_version = min_tls_version = TLS1_1_VERSION; @@ -224,7 +224,7 @@ static SSL_CTX* instantiate_ssl_context(const char* context_name) max_tls_version = min_tls_version = TLS1_3_VERSION; } else { ERROR("Unrecognized TLS version for [%s] context: %1.1f", context_name, tls_version); - return NULL; + return nullptr; } if (!strncmp(context_name, "client", 6)) { @@ -256,7 +256,7 @@ static SSL_CTX* instantiate_ssl_context(const char* context_name) } #else ERROR("Old TLS version 1.0 is no longer supported for [%s] context.", context_name); - ssl_ctx = NULL; + ssl_ctx = nullptr; #endif } else if (tls_version == 1.1) { if (!strncmp(context_name, "client", 6)) { @@ -278,7 +278,7 @@ static SSL_CTX* instantiate_ssl_context(const char* context_name) } } else { ERROR("Unrecognized TLS version for [%s] context: %1.1f", context_name, tls_version); - ssl_ctx = NULL; + ssl_ctx = nullptr; } #endif @@ -292,14 +292,14 @@ enum tls_init_status TLS_init_context(void) { sip_trp_ssl_ctx = instantiate_ssl_context("generic"); - if (sip_trp_ssl_ctx == NULL) { + if (sip_trp_ssl_ctx == nullptr) { ERROR("TLS_init_context: SSL_CTX_new with TLS_method failed for generic context"); return TLS_INIT_ERROR; } sip_trp_ssl_ctx_client = instantiate_ssl_context("client"); - if (sip_trp_ssl_ctx_client == NULL) { + if (sip_trp_ssl_ctx_client == nullptr) { ERROR("TLS_init_context: SSL_CTX_new with TLS_method failed for client context"); return TLS_INIT_ERROR; } @@ -309,8 +309,8 @@ enum tls_init_status TLS_init_context(void) /* Load the trusted CA's */ if (got_ca_file) { - SSL_CTX_load_verify_locations(sip_trp_ssl_ctx, tls_ca_name, NULL); - SSL_CTX_load_verify_locations(sip_trp_ssl_ctx_client, tls_ca_name, NULL); + SSL_CTX_load_verify_locations(sip_trp_ssl_ctx, tls_ca_name, nullptr); + SSL_CTX_load_verify_locations(sip_trp_ssl_ctx_client, tls_ca_name, nullptr); } /* TLS Verification only makes sense if an CA is specified or diff --git a/src/stat.cpp b/src/stat.cpp index b0cee478e..95150acf2 100644 --- a/src/stat.cpp +++ b/src/stat.cpp @@ -124,32 +124,32 @@ CStat::~CStat() dumpDataRtt(); for (i = 0; i < nRtds(); i++) { - if (M_ResponseTimeRepartition[i] != NULL) { + if (M_ResponseTimeRepartition[i] != nullptr) { delete [] M_ResponseTimeRepartition[i]; } } free(M_ResponseTimeRepartition); - if (M_CallLengthRepartition != NULL) + if (M_CallLengthRepartition != nullptr) delete [] M_CallLengthRepartition; - if(M_outputStream != NULL) { + if(M_outputStream != nullptr) { M_outputStream->close(); delete M_outputStream; } - if(M_fileName != NULL) + if(M_fileName != nullptr) delete [] M_fileName; - if(M_outputStreamRtt != NULL) { + if(M_outputStreamRtt != nullptr) { M_outputStreamRtt->close(); delete M_outputStreamRtt; } - if(M_fileNameRtt != NULL) + if(M_fileNameRtt != nullptr) delete [] M_fileNameRtt; - if(M_dumpRespTime != NULL) + if(M_dumpRespTime != nullptr) delete [] M_dumpRespTime; free(M_rtdInfo); @@ -159,13 +159,13 @@ CStat::~CStat() M_SizeOfResponseTimeRepartition = 0; M_SizeOfCallLengthRepartition = 0; - M_CallLengthRepartition = NULL; - M_fileName = NULL; - M_outputStream = NULL; + M_CallLengthRepartition = nullptr; + M_fileName = nullptr; + M_outputStream = nullptr; - M_outputStreamRtt = NULL; - M_fileNameRtt = NULL; - M_dumpRespTime = NULL; + M_outputStreamRtt = nullptr; + M_fileNameRtt = nullptr; + M_dumpRespTime = nullptr; } @@ -176,10 +176,10 @@ int CStat::init () GET_TIME (&M_startTime); memcpy (&M_pdStartTime, &M_startTime, sizeof (struct timeval)); memcpy (&M_plStartTime, &M_startTime, sizeof (struct timeval)); - M_outputStream = NULL; + M_outputStream = nullptr; M_headerAlreadyDisplayed = false; - M_outputStreamRtt = NULL; + M_outputStreamRtt = nullptr; M_headerAlreadyDisplayedRtt = false; std::vector error_codes(0); @@ -278,27 +278,27 @@ void CStat::setFileName(const char* P_name, const char* P_extension) { int sizeOf, sizeOfExtension; - if(P_name != NULL) { + if(P_name != nullptr) { // +6 for PID sizeOf = strlen(P_name) + 6; if(sizeOf > 0) { - if(P_extension != NULL) { + if(P_extension != nullptr) { sizeOfExtension = strlen(P_extension); if(sizeOfExtension > 0) { - if(M_fileName != NULL) + if(M_fileName != nullptr) delete [] M_fileName; M_fileName = new char[MAX_PATH]; sprintf(M_fileName, "%s_%ld_", P_name, (long) getpid()); strcat(M_fileName, P_extension); } else { - if(M_fileName != NULL) + if(M_fileName != nullptr) delete [] M_fileName; M_fileName = new char[MAX_PATH]; sprintf(M_fileName, "%s_%ld_", P_name, (long) getpid()); strcat(M_fileName, DEFAULT_EXTENSION); } } else { - if(M_fileName != NULL) + if(M_fileName != nullptr) delete [] M_fileName; M_fileName = new char[MAX_PATH]; sprintf(M_fileName, "%s_%ld_", P_name, (long) getpid()); @@ -320,10 +320,10 @@ void CStat::setFileName(const char* P_name) { int sizeOf; - if(P_name != NULL) { + if(P_name != nullptr) { sizeOf = strlen(P_name); if(sizeOf > 0) { - if(M_fileName != NULL) + if(M_fileName != nullptr) delete [] M_fileName; M_fileName = new char[sizeOf+1]; strcpy(M_fileName, P_name); @@ -344,13 +344,13 @@ void CStat::initRtt(const char* P_name, const char* P_extension, { int sizeOf, sizeOfExtension; - if(P_name != NULL) { + if(P_name != nullptr) { sizeOf = strlen(P_name) ; if(sizeOf > 0) { // 4 for '_rtt' and 6 for pid sizeOf += 10 ; sizeOfExtension = strlen(P_extension); - if(M_fileNameRtt != NULL) + if(M_fileNameRtt != nullptr) delete [] M_fileNameRtt; sizeOf += sizeOfExtension; M_fileNameRtt = new char[sizeOf+1]; @@ -370,7 +370,7 @@ void CStat::initRtt(const char* P_name, const char* P_extension, M_dumpRespTime = new T_value_rtt [P_report_freq_dumpRtt] ; - if ( M_dumpRespTime == NULL ) { + if ( M_dumpRespTime == nullptr ) { std::cerr << "Memory allocation failure" << std::endl; exit(EXIT_FATAL_ERROR); } @@ -396,7 +396,7 @@ void CStat::setRepartitionCallLength(char * P_listeStr) ERROR("Could not create table for call length repartition '%s'", P_listeStr); } delete [] listeInteger; - listeInteger = NULL; + listeInteger = nullptr; } void CStat::setRepartitionResponseTime (char * P_listeStr) @@ -415,7 +415,7 @@ void CStat::setRepartitionResponseTime (char * P_listeStr) ERROR("Could not create table for response time repartition '%s'", P_listeStr); } delete [] listeInteger; - listeInteger = NULL; + listeInteger = nullptr; } } @@ -450,9 +450,9 @@ void CStat::initRepartition(unsigned int* repartition, int i; unsigned int swap; - if((nombre <= 0) || (repartition == NULL) ) { + if((nombre <= 0) || (repartition == nullptr) ) { (*tabNb) = 0; - (*tabRepartition) = NULL; + (*tabRepartition) = nullptr; return; } @@ -924,7 +924,7 @@ int CStat::findRtd(const char *name, bool start) if (!M_ResponseTimeRepartition) { ERROR("Could not allocate RTD info!"); } - M_ResponseTimeRepartition[ret - 1] = NULL; + M_ResponseTimeRepartition[ret - 1] = nullptr; if (start) { rtd_started[name] = true; @@ -1009,7 +1009,7 @@ void CStat::updateRepartition(T_dynamicalRepartition* P_tabReport, int P_sizeOfTab, unsigned long P_value) { - if(P_tabReport == NULL) { + if(P_tabReport == nullptr) { return; } @@ -1028,7 +1028,7 @@ void CStat::updateRepartition(T_dynamicalRepartition* P_tabReport, void CStat::resetRepartition(T_dynamicalRepartition* P_tabReport, int P_sizeOfTab) { - if(P_tabReport == NULL) { + if(P_tabReport == nullptr) { return; } @@ -1047,18 +1047,18 @@ CStat::CStat () M_fileName = new char[L_size]; strcpy(M_fileName, DEFAULT_FILE_NAME); strcat(M_fileName, DEFAULT_EXTENSION); - M_ResponseTimeRepartition = NULL; - M_CallLengthRepartition = NULL; + M_ResponseTimeRepartition = nullptr; + M_CallLengthRepartition = nullptr; M_SizeOfResponseTimeRepartition = 0; M_SizeOfCallLengthRepartition = 0; - M_fileNameRtt = NULL; - M_genericCounters = NULL; + M_fileNameRtt = nullptr; + M_genericCounters = nullptr; M_time_ref = 0.0 ; - M_dumpRespTime = NULL ; + M_dumpRespTime = nullptr ; M_counterDumpRespTime = 0 ; - M_dumpRespTime = NULL; - M_fileNameRtt = NULL; - M_rtdInfo = NULL; + M_dumpRespTime = nullptr; + M_fileNameRtt = nullptr; + M_rtdInfo = nullptr; M_rtpEchoErrors = 0; init(); @@ -1068,11 +1068,11 @@ char* CStat::sRepartitionHeader(T_dynamicalRepartition * tabRepartition, int sizeOfTab, const char * P_repartitionName) { - static char *repartitionHeader = NULL; + static char *repartitionHeader = nullptr; char buffer[MAX_CHAR_BUFFER_SIZE]; int dlen = strlen(stat_delimiter); - if(tabRepartition != NULL) { + if(tabRepartition != nullptr) { repartitionHeader = (char *)realloc(repartitionHeader, strlen(P_repartitionName) + dlen + 1); sprintf(repartitionHeader, "%s%s", P_repartitionName, stat_delimiter); for(int i=0; i<(sizeOfTab-1); i++) { @@ -1098,7 +1098,7 @@ char* CStat::sRepartitionInfo(T_dynamicalRepartition * tabRepartition, char buffer[MAX_CHAR_BUFFER_SIZE]; int dlen = strlen(stat_delimiter); - if(tabRepartition != NULL) { + if(tabRepartition != nullptr) { // if a repartition is present, this field match the repartition name repartitionInfo = (char *)realloc(repartitionInfo, dlen + 1); sprintf(repartitionInfo, "%s", stat_delimiter); @@ -1143,12 +1143,12 @@ void CStat::dumpData () 1000*(float)numberOfCall / (float)localElapsedTime : 0.0); - if(M_outputStream == NULL) { + if(M_outputStream == nullptr) { // if the file is still not opened, we opened it now M_outputStream = new std::ofstream(M_fileName); M_headerAlreadyDisplayed = false; - if(M_outputStream == NULL) { + if(M_outputStream == nullptr) { std::cerr << "Unable to open stat file '" << M_fileName << "' !" << std::endl; exit(EXIT_FATAL_ERROR); } @@ -1391,12 +1391,12 @@ void CStat::dumpDataRtt () if (M_counterDumpRespTime == 0) { return; } - if(M_outputStreamRtt == NULL) { + if(M_outputStreamRtt == nullptr) { // if the file is still not opened, we opened it now M_outputStreamRtt = new std::ofstream(M_fileNameRtt); M_headerAlreadyDisplayedRtt = false; - if(M_outputStreamRtt == NULL) { + if(M_outputStreamRtt == nullptr) { std::cerr << "Unable to open rtt file '" << M_fileNameRtt << "' !" << std::endl; exit(EXIT_FATAL_ERROR); } @@ -1470,7 +1470,7 @@ char* CStat::formatTime (struct timeval* P_tv, bool with_epoch) L_currentDate = localtime ((const time_t *)&P_tv->tv_sec); // Format the time - if (L_currentDate == NULL) { + if (L_currentDate == nullptr) { memset (L_time, 0, TIME_LENGTH); } else { if (with_epoch) { @@ -1562,7 +1562,7 @@ CUniform::CUniform(double min, double max) { if (!uniform_init) { uniform_init = true; - srand(time(NULL)); + srand(time(nullptr)); } this->min = min; this->max = max; @@ -1591,7 +1591,7 @@ double CUniform::cdfInv(double percentile) #ifdef HAVE_GSL gsl_rng *gsl_init() { - static gsl_rng *rng = NULL; + static gsl_rng *rng = nullptr; if (rng) { return rng; diff --git a/src/strings.cpp b/src/strings.cpp index fe63834d9..a71905c6e 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -54,10 +54,10 @@ void get_host_and_port(const char * addr, char * host, int * port) int port_result = 0; has_brackets = strchr(addr, '['); - if (has_brackets != NULL) { + if (has_brackets != nullptr) { has_brackets = strchr(has_brackets, ']'); } - if (has_brackets == NULL) { + if (has_brackets == nullptr) { /* addr is not a []-enclosed IPv6 address, but might still be IPv6 (without * a port), or IPv4 or a hostname (with or without a port) */ char *first_colon_location; @@ -67,12 +67,12 @@ void get_host_and_port(const char * addr, char * host, int * port) memmove(host, addr, len); first_colon_location = strchr(host, ':'); - if (first_colon_location == NULL) { + if (first_colon_location == nullptr) { /* No colon - just set the port to 0 */ port_result = 0; } else { second_colon_location = strchr(first_colon_location + 1, ':'); - if (second_colon_location != NULL) { + if (second_colon_location != nullptr) { /* Found a second colon in addr - so this is an IPv6 address * without a port. Set the port to 0 */ port_result = 0; @@ -99,7 +99,7 @@ void get_host_and_port(const char * addr, char * host, int * port) /* Check for a port specified after the ] */ colon_before_port = strchr(second_bracket + 1, ':'); - if (colon_before_port != NULL) { + if (colon_before_port != nullptr) { port_result = atol(colon_before_port + 1); } else { port_result = 0; @@ -107,7 +107,7 @@ void get_host_and_port(const char * addr, char * host, int * port) } // Set the port argument if it wasn't NULL - if (port != NULL) { + if (port != nullptr) { *port = port_result; } } @@ -179,7 +179,7 @@ TEST(GetHostAndPort, IPv4AndPort) { TEST(GetHostAndPort, IgnorePort) { char host_result[255]; - get_host_and_port("127.0.0.1", host_result, NULL); + get_host_and_port("127.0.0.1", host_result, nullptr); EXPECT_STREQ("127.0.0.1", host_result); } diff --git a/src/task.cpp b/src/task.cpp index 44d5714c6..08da42a30 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -192,7 +192,7 @@ task_list *timewheel::task2list(task *task) return &wheel_three[slot_in_third_wheel]; } else{ ERROR("Attempted to schedule a task too far in the future"); - return NULL; + return nullptr; } } diff --git a/src/variables.cpp b/src/variables.cpp index 572f7c804..515d030d9 100644 --- a/src/variables.cpp +++ b/src/variables.cpp @@ -70,7 +70,7 @@ bool CCallVariable::isString() void CCallVariable::setMatchingValue(char* P_matchingVal) { M_type = E_VT_REGEXP; - if(M_matchingValue != NULL) { + if(M_matchingValue != nullptr) { delete [] M_matchingValue; } M_matchingValue = P_matchingVal; @@ -80,7 +80,7 @@ void CCallVariable::setMatchingValue(char* P_matchingVal) char* CCallVariable::getMatchingValue() { if (M_type != E_VT_REGEXP) { - return NULL; + return nullptr; } return(M_matchingValue); } @@ -167,18 +167,18 @@ bool CCallVariable::getBool() // Constructor and destructor CCallVariable::CCallVariable() { - M_matchingValue = NULL; - M_stringValue = NULL; + M_matchingValue = nullptr; + M_stringValue = nullptr; M_nbOfMatchingValue = 0; M_type = E_VT_UNDEFINED; } CCallVariable::~CCallVariable() { - if(M_matchingValue != NULL) { + if(M_matchingValue != nullptr) { delete [] M_matchingValue; } - M_matchingValue = NULL; + M_matchingValue = nullptr; free(M_stringValue); } @@ -192,13 +192,13 @@ VariableTable::VariableTable(VariableTable *parent, int size) this->parent = parent->getTable(); } else { level = 0; - this->parent = NULL; + this->parent = nullptr; } count = 1; this->size = size; if (size == 0) { - variableTable = NULL; + variableTable = nullptr; return; } variableTable = (CCallVariable **)malloc(size * sizeof(CCallVariable *)); @@ -207,7 +207,7 @@ VariableTable::VariableTable(VariableTable *parent, int size) } for (int i = 0; i < size; i++) { variableTable[i] = new CCallVariable(); - if (variableTable[i] == NULL) { + if (variableTable[i] == nullptr) { ERROR ("Call variable allocation failed"); } } @@ -220,14 +220,14 @@ VariableTable::VariableTable(AllocVariableTable *src) if (src->parent) { this->parent = src->parent->getTable(); } else { - this->parent = NULL; + this->parent = nullptr; } if (level > 0) { assert(this->parent); } this->size = src->size; if (size == 0) { - variableTable = NULL; + variableTable = nullptr; return; } @@ -238,7 +238,7 @@ VariableTable::VariableTable(AllocVariableTable *src) for (int i = 0; i < size; i++) { variableTable[i] = new CCallVariable(); - if (variableTable[i] == NULL) { + if (variableTable[i] == nullptr) { ERROR ("Call variable allocation failed"); } } @@ -258,7 +258,7 @@ void VariableTable::expand(int size) for (int i = this->size; i < size; i++) { variableTable[i] = new CCallVariable(); - if (variableTable[i] == NULL) { + if (variableTable[i] == nullptr) { ERROR ("Call variable allocation failed"); } } diff --git a/src/xp_parser_ut.cpp b/src/xp_parser_ut.cpp index f2af3f4b2..0f0f3851b 100644 --- a/src/xp_parser_ut.cpp +++ b/src/xp_parser_ut.cpp @@ -49,7 +49,7 @@ TEST(xp_parser, set_xml_buffer_from_string__good) { "" " " ""), // 4 - NULL + nullptr }; for (i = 0; buffers[i]; ++i) { @@ -88,7 +88,7 @@ TEST(xp_parser, set_xml_buffer_from_string__bad) { ("" " " ""), // -3 - NULL + nullptr }; for (i = 0; buffers[i]; ++i) { @@ -156,7 +156,7 @@ TEST(xp_parser, detect_unclosed_xml) { " ]]>\r\n" " \r\n" "\r\n"), /* 2nd */ - NULL + nullptr }; for (i = 0; buffers[i]; ++i) {