Skip to content

Commit 7786833

Browse files
committed
Fix unreachable test code
1 parent a4ee5ed commit 7786833

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

test/lib/c/03-publish-b2c-qos1.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ int main(int argc, char *argv[])
7171
if(rc != MOSQ_ERR_SUCCESS) return rc;
7272

7373
while(1){
74-
mosquitto_loop(mosq, 300, 1);
74+
if(mosquitto_loop(mosq, 300, 1)){
75+
break;
76+
}
7577
}
7678
mosquitto_destroy(mosq);
7779

test/lib/cpp/03-publish-b2c-qos1-unexpected-puback.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void mosquittopp_test::on_connect(int rc)
2626
int main(int argc, char *argv[])
2727
{
2828
mosquittopp_test *mosq;
29+
int rc = 1;
2930

3031
if(argc != 2){
3132
return 1;
@@ -39,14 +40,14 @@ int main(int argc, char *argv[])
3940
mosq->connect("localhost", port, 5);
4041

4142
while(1){
42-
int rc = mosq->loop(300, 1);
43-
if(rc){
44-
exit(0);
43+
if(mosq->loop(300, 1)){
44+
rc = 0;
45+
break;
4546
}
4647
}
4748
delete mosq;
4849
mosqpp::lib_cleanup();
4950

50-
return 1;
51+
return rc;
5152
}
5253

test/lib/cpp/03-publish-b2c-qos1.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void mosquittopp_test::on_message(const struct mosquitto_message *msg)
5757
int main(int argc, char *argv[])
5858
{
5959
mosquittopp_test *mosq;
60+
int rc = 1;
6061

6162
if(argc != 2){
6263
return 1;
@@ -70,13 +71,15 @@ int main(int argc, char *argv[])
7071
mosq->connect("localhost", port, 60);
7172

7273
while(1){
73-
mosq->loop();
74+
if(mosq->loop()){
75+
rc = 0;
76+
break;
77+
}
7478
}
75-
delete mosq;
7679

7780
delete mosq;
7881
mosqpp::lib_cleanup();
7982

80-
return 1;
83+
return rc;
8184
}
8285

0 commit comments

Comments
 (0)