mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-02 03:09:23 +00:00
fix cast && better char* management
This commit is contained in:
parent
2b1f9ea105
commit
b499578df6
3 changed files with 62 additions and 26 deletions
|
|
@ -96,7 +96,7 @@ void NetsimCommand::exec(Daemon* app, const string& args) {
|
|||
params.loss_rate = (float)atoi(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(), "latency", value, sizeof(value))) {
|
||||
params.latency = atoi(value);
|
||||
params.latency = (uint32_t)atoi(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(), "consecutive_loss_probability", value, sizeof(value))) {
|
||||
params.consecutive_loss_probability = (float)atof(value);
|
||||
|
|
|
|||
|
|
@ -635,7 +635,7 @@ string Daemon::readPipe() {
|
|||
pfd[1].fd = mChildFd;
|
||||
nfds++;
|
||||
}
|
||||
int err = poll(pfd, nfds, 50);
|
||||
int err = poll(pfd, (nfds_t)nfds, 50);
|
||||
if (err > 0) {
|
||||
if (mServerFd != (ortp_pipe_t)-1 && (pfd[0].revents & POLLIN)) {
|
||||
struct sockaddr_storage addr;
|
||||
|
|
|
|||
|
|
@ -472,11 +472,14 @@ void first_notify_parsing() {
|
|||
ConferenceEventTester tester(marie->lc, addr);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
size_t size = strlen(first_notify) + strlen(confUri);
|
||||
char *notify = new char[size];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
snprintf(notify, size, first_notify, confUri);
|
||||
tester.handler->notifyReceived(notify);
|
||||
|
||||
delete[] notify;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
|
|
@ -498,11 +501,14 @@ void first_notify_parsing_wrong_conf() {
|
|||
ConferenceEventTester tester(marie->lc, addr);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
size_t size = strlen(first_notify) + strlen(confUri);
|
||||
char *notify = new char[size];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
snprintf(notify, size, first_notify, confUri);
|
||||
tester.handler->notifyReceived(notify);
|
||||
|
||||
delete[] notify;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 0, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_FALSE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
|
|
@ -523,21 +529,27 @@ void participant_added_parsing() {
|
|||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
LinphoneAddress *frankAddr = linphone_core_interpret_url(marie->lc, frankUri);
|
||||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
char notify_added[strlen(participant_added_notify) + strlen(confUri)];
|
||||
size_t size = strlen(first_notify) + strlen(confUri);
|
||||
char *notify = new char[size];
|
||||
size_t size2 = strlen(participant_added_notify) + strlen(confUri);
|
||||
char *notify_added = new char[size2];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
snprintf(notify, size, first_notify, confUri);
|
||||
tester.handler->notifyReceived(notify);
|
||||
|
||||
delete[] notify;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(!tester.participants.find(linphone_address_as_string(bobAddr))->second);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second);
|
||||
|
||||
snprintf(notify_added, sizeof(notify_added), participant_added_notify, confUri);
|
||||
snprintf(notify_added, size2, participant_added_notify, confUri);
|
||||
tester.handler->notifyReceived(notify_added);
|
||||
|
||||
delete[] notify_added;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 3, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(frankAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(!tester.participants.find(linphone_address_as_string(frankAddr))->second);
|
||||
|
|
@ -559,21 +571,27 @@ void participant_not_added_parsing() {
|
|||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
LinphoneAddress *frankAddr = linphone_core_interpret_url(marie->lc, frankUri);
|
||||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
char notify_not_added[strlen(participant_not_added_notify) + strlen(confUri)];
|
||||
size_t size = strlen(first_notify) + strlen(confUri);
|
||||
char *notify = new char[size];
|
||||
size_t size2 = strlen(participant_not_added_notify) + strlen(confUri);
|
||||
char *notify_not_added = new char[size2];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
snprintf(notify, size, first_notify, confUri);
|
||||
tester.handler->notifyReceived(notify);
|
||||
|
||||
delete[] notify;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(!tester.participants.find(linphone_address_as_string(bobAddr))->second);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second);
|
||||
|
||||
snprintf(notify_not_added, sizeof(notify_not_added), participant_not_added_notify, confUri);
|
||||
snprintf(notify_not_added, size2, participant_not_added_notify, confUri);
|
||||
tester.handler->notifyReceived(notify_not_added);
|
||||
|
||||
delete[] notify_not_added;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.participants.find(linphone_address_as_string(frankAddr)) != tester.participants.end());
|
||||
|
||||
|
|
@ -593,21 +611,27 @@ void participant_deleted_parsing() {
|
|||
ConferenceEventTester tester(marie->lc, addr);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
char notify_deleted[strlen(participant_deleted_notify) + strlen(confUri)];
|
||||
size_t size = strlen(first_notify) + strlen(confUri);
|
||||
char *notify = new char[size];
|
||||
size_t size2 = strlen(participant_deleted_notify) + strlen(confUri);
|
||||
char *notify_deleted = new char[size2];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
snprintf(notify, size, first_notify, confUri);
|
||||
tester.handler->notifyReceived(notify);
|
||||
|
||||
delete[] notify;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(!tester.participants.find(linphone_address_as_string(bobAddr))->second);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second);
|
||||
|
||||
snprintf(notify_deleted, sizeof(notify_deleted), participant_deleted_notify, confUri);
|
||||
snprintf(notify_deleted, size2, participant_deleted_notify, confUri);
|
||||
tester.handler->notifyReceived(notify_deleted);
|
||||
|
||||
delete[] notify_deleted;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 1, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
|
||||
|
|
@ -626,21 +650,27 @@ void participant_admined_parsing() {
|
|||
ConferenceEventTester tester(marie->lc, addr);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
char notify_admined[strlen(participant_admined_notify) + strlen(confUri)];
|
||||
size_t size = strlen(first_notify) + strlen(confUri);
|
||||
char *notify = new char[size];
|
||||
size_t size2 = strlen(participant_admined_notify) + strlen(confUri);
|
||||
char *notify_admined = new char[size2];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
snprintf(notify, size, first_notify, confUri);
|
||||
tester.handler->notifyReceived(notify);
|
||||
|
||||
delete[] notify;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(!tester.participants.find(linphone_address_as_string(bobAddr))->second);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second);
|
||||
|
||||
snprintf(notify_admined, sizeof(notify_admined), participant_admined_notify, confUri);
|
||||
snprintf(notify_admined, size2, participant_admined_notify, confUri);
|
||||
tester.handler->notifyReceived(notify_admined);
|
||||
|
||||
delete[] notify_admined;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second);
|
||||
|
|
@ -660,21 +690,27 @@ void participant_unadmined_parsing() {
|
|||
ConferenceEventTester tester(marie->lc, addr);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
char notify_unadmined[strlen(participant_unadmined_notify) + strlen(confUri)];
|
||||
size_t size = strlen(first_notify) + strlen(confUri);
|
||||
char *notify = new char[size];
|
||||
size_t size2 = strlen(participant_unadmined_notify) + strlen(confUri);
|
||||
char notify_unadmined[size2];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
snprintf(notify, size, first_notify, confUri);
|
||||
tester.handler->notifyReceived(notify);
|
||||
|
||||
delete[] notify;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(!tester.participants.find(linphone_address_as_string(bobAddr))->second);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second);
|
||||
|
||||
snprintf(notify_unadmined, sizeof(notify_unadmined), participant_unadmined_notify, confUri);
|
||||
snprintf(notify_unadmined, size2, participant_unadmined_notify, confUri);
|
||||
tester.handler->notifyReceived(notify_unadmined);
|
||||
|
||||
delete[] participant_unadmined_notify;
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(!tester.participants.find(linphone_address_as_string(aliceAddr))->second);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue