diff --git a/examples/z_get.c b/examples/z_get.c index b0956e0a6..d886aee0b 100644 --- a/examples/z_get.c +++ b/examples/z_get.c @@ -76,7 +76,7 @@ int main(int argc, char** argv) { &opts); // here, the send is moved and will be dropped by zenoh when adequate z_owned_reply_t reply; - for (z_result_t res = z_recv(z_loan(handler), &reply); res == Z_OK; res = z_recv(z_loan(handler), &reply)) { + while (z_recv(z_loan(handler), &reply) == Z_OK) { if (z_reply_is_ok(z_loan(reply))) { const z_loaned_sample_t* sample = z_reply_ok(z_loan(reply)); diff --git a/examples/z_get_liveliness.c b/examples/z_get_liveliness.c index 91d9e11b5..026827cdf 100644 --- a/examples/z_get_liveliness.c +++ b/examples/z_get_liveliness.c @@ -49,7 +49,7 @@ int main(int argc, char** argv) { z_fifo_channel_reply_new(&closure, &handler, 16); z_liveliness_get(z_loan(s), z_loan(keyexpr), z_move(closure), NULL); z_owned_reply_t reply; - for (z_result_t res = z_recv(z_loan(handler), &reply); res == Z_OK; res = z_recv(z_loan(handler), &reply)) { + while (z_recv(z_loan(handler), &reply) == Z_OK) { if (z_reply_is_ok(z_loan(reply))) { const z_loaned_sample_t* sample = z_reply_ok(z_loan(reply)); z_view_string_t key_str; diff --git a/examples/z_get_shm.c b/examples/z_get_shm.c index 4cb71167b..0c9d7878d 100644 --- a/examples/z_get_shm.c +++ b/examples/z_get_shm.c @@ -102,7 +102,7 @@ int main(int argc, char** argv) { &opts); // here, the send is moved and will be dropped by zenoh when adequate z_owned_reply_t reply; - for (z_result_t res = z_recv(z_loan(handler), &reply); res == Z_OK; res = z_recv(z_loan(handler), &reply)) { + while (z_recv(z_loan(handler), &reply) == Z_OK) { if (z_reply_is_ok(z_loan(reply))) { const z_loaned_sample_t* sample = z_reply_ok(z_loan(reply)); diff --git a/examples/z_non_blocking_get.c b/examples/z_non_blocking_get.c index 338989ee1..5ed47efff 100644 --- a/examples/z_non_blocking_get.c +++ b/examples/z_non_blocking_get.c @@ -53,8 +53,9 @@ int main(int argc, char** argv) { z_get(z_loan(s), z_loan(keyexpr), "", z_move(closure), &opts); // here, the closure is moved and will be dropped by zenoh when adequate z_owned_reply_t reply; - for (z_result_t res = z_try_recv(z_loan(handler), &reply); res != Z_CHANNEL_DISCONNECTED; - res = z_try_recv(z_loan(handler), &reply)) { + + z_result_t res; + while ((res = z_try_recv(z_loan(handler), &reply)) != Z_CHANNEL_DISCONNECTED) { if (res != Z_OK) { z_sleep_ms(50); continue; diff --git a/examples/z_queryable_with_channels.c b/examples/z_queryable_with_channels.c index 44561d431..3770593bb 100644 --- a/examples/z_queryable_with_channels.c +++ b/examples/z_queryable_with_channels.c @@ -64,7 +64,7 @@ int main(int argc, char** argv) { printf("Press CTRL-C to quit...\n"); z_owned_query_t oquery; - for (z_result_t res = z_recv(z_loan(handler), &oquery); res == Z_OK; res = z_recv(z_loan(handler), &oquery)) { + while (z_recv(z_loan(handler), &oquery) == Z_OK) { const z_loaned_query_t* query = z_loan(oquery); z_view_string_t key_string; z_keyexpr_as_view_string(z_query_keyexpr(query), &key_string); diff --git a/tests/z_int_queryable_attachment_test.c b/tests/z_int_queryable_attachment_test.c index 0fbf8caba..c573c9665 100644 --- a/tests/z_int_queryable_attachment_test.c +++ b/tests/z_int_queryable_attachment_test.c @@ -198,7 +198,7 @@ int run_get() { z_get(z_loan(s), z_loan(ke), "", z_move(closure), &opts); z_owned_reply_t reply; - for (z_result_t res = z_recv(z_loan(handler), &reply); res == Z_OK; res = z_recv(z_loan(handler), &reply)) { + while (z_recv(z_loan(handler), &reply) == Z_OK) { assert(z_reply_is_ok(z_loan(reply))); const z_loaned_sample_t *sample = z_reply_ok(z_loan(reply)); diff --git a/tests/z_int_queryable_test.c b/tests/z_int_queryable_test.c index 4c1d5902e..2de7fffd8 100644 --- a/tests/z_int_queryable_test.c +++ b/tests/z_int_queryable_test.c @@ -109,7 +109,7 @@ int run_get() { z_get_options_default(&opts); z_get(z_loan(s), z_loan(ke), "", z_move(closure), &opts); z_owned_reply_t reply; - for (z_result_t res = z_recv(z_loan(handler), &reply); res == Z_OK; res = z_recv(z_loan(handler), &reply)) { + while (z_recv(z_loan(handler), &reply) == Z_OK) { assert(z_reply_is_ok(z_loan(reply))); const z_loaned_sample_t *sample = z_reply_ok(z_loan(reply));