diff --git a/examples/arduino/z_pub.ino b/examples/arduino/z_pub.ino index 3e3be23c7..243aaa2f2 100644 --- a/examples/arduino/z_pub.ino +++ b/examples/arduino/z_pub.ino @@ -64,7 +64,8 @@ void setup() { // Open Zenoh session Serial.print("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { Serial.println("Unable to open session!"); while (1) { diff --git a/examples/arduino/z_pull.ino b/examples/arduino/z_pull.ino index 26478d740..c2f5bf643 100644 --- a/examples/arduino/z_pull.ino +++ b/examples/arduino/z_pull.ino @@ -77,7 +77,8 @@ void setup() { // Open Zenoh session Serial.print("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { Serial.println("Unable to open session!"); while (1) { diff --git a/examples/arduino/z_queryable.ino b/examples/arduino/z_queryable.ino index adfb3a439..fe174fdeb 100644 --- a/examples/arduino/z_queryable.ino +++ b/examples/arduino/z_queryable.ino @@ -75,7 +75,8 @@ void setup() { // Open Zenoh session Serial.print("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { Serial.println("Unable to open session!"); while (1) { diff --git a/examples/arduino/z_scout.ino b/examples/arduino/z_scout.ino index 632b50295..33102754e 100644 --- a/examples/arduino/z_scout.ino +++ b/examples/arduino/z_scout.ino @@ -114,7 +114,8 @@ void setup() { void loop() { int *context = (int *)malloc(sizeof(int)); *context = 0; - z_owned_scouting_config_t config = z_scouting_config_default(); + z_owned_scouting_config_t config; + z_scouting_config_default(&config); z_owned_closure_hello_t closure = z_closure_hello(callback, drop, context); printf("Scouting...\n"); z_scout(z_scouting_config_move(&config), z_closure_hello_move(&closure)); diff --git a/examples/arduino/z_sub.ino b/examples/arduino/z_sub.ino index e4d847a64..9a707958d 100644 --- a/examples/arduino/z_sub.ino +++ b/examples/arduino/z_sub.ino @@ -73,7 +73,8 @@ void setup() { // Open Zenoh session Serial.print("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { Serial.println("Unable to open session!"); while (1) { diff --git a/examples/espidf/z_get.c b/examples/espidf/z_get.c index 57a10d1e9..9f7c1115e 100644 --- a/examples/espidf/z_get.c +++ b/examples/espidf/z_get.c @@ -141,7 +141,8 @@ void app_main() { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/espidf/z_pub.c b/examples/espidf/z_pub.c index a793c0b1f..95280b39f 100644 --- a/examples/espidf/z_pub.c +++ b/examples/espidf/z_pub.c @@ -128,7 +128,8 @@ void app_main() { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/espidf/z_pull.c b/examples/espidf/z_pull.c index 11e0d51a3..c96c1de38 100644 --- a/examples/espidf/z_pull.c +++ b/examples/espidf/z_pull.c @@ -135,7 +135,8 @@ void app_main() { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/espidf/z_queryable.c b/examples/espidf/z_queryable.c index dd1d1ae04..9083658be 100644 --- a/examples/espidf/z_queryable.c +++ b/examples/espidf/z_queryable.c @@ -137,7 +137,8 @@ void app_main() { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/espidf/z_sub.c b/examples/espidf/z_sub.c index 3793c2201..10456c866 100644 --- a/examples/espidf/z_sub.c +++ b/examples/espidf/z_sub.c @@ -134,7 +134,8 @@ void app_main() { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/freertos_plus_tcp/z_get.c b/examples/freertos_plus_tcp/z_get.c index 2ac6ca289..789d790b9 100644 --- a/examples/freertos_plus_tcp/z_get.c +++ b/examples/freertos_plus_tcp/z_get.c @@ -57,7 +57,8 @@ void app_main(void) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return; diff --git a/examples/freertos_plus_tcp/z_pub.c b/examples/freertos_plus_tcp/z_pub.c index 32ad9bb91..ea7b026d0 100644 --- a/examples/freertos_plus_tcp/z_pub.c +++ b/examples/freertos_plus_tcp/z_pub.c @@ -40,7 +40,8 @@ void app_main(void) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return; diff --git a/examples/freertos_plus_tcp/z_pub_st.c b/examples/freertos_plus_tcp/z_pub_st.c index bb3a1840b..058ad1b20 100644 --- a/examples/freertos_plus_tcp/z_pub_st.c +++ b/examples/freertos_plus_tcp/z_pub_st.c @@ -41,7 +41,8 @@ void app_main(void) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return; diff --git a/examples/freertos_plus_tcp/z_pull.c b/examples/freertos_plus_tcp/z_pull.c index 1ce442e00..4cdbe244a 100644 --- a/examples/freertos_plus_tcp/z_pull.c +++ b/examples/freertos_plus_tcp/z_pull.c @@ -46,7 +46,8 @@ void app_main(void) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return; diff --git a/examples/freertos_plus_tcp/z_put.c b/examples/freertos_plus_tcp/z_put.c index 2b134aae7..e03624565 100644 --- a/examples/freertos_plus_tcp/z_put.c +++ b/examples/freertos_plus_tcp/z_put.c @@ -38,7 +38,8 @@ void app_main(void) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return; diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index 6bfdd1f3b..ff3f96d61 100644 --- a/examples/freertos_plus_tcp/z_queryable.c +++ b/examples/freertos_plus_tcp/z_queryable.c @@ -53,7 +53,8 @@ void app_main(void) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return; diff --git a/examples/freertos_plus_tcp/z_sub.c b/examples/freertos_plus_tcp/z_sub.c index af32e1f2b..fd166e24d 100644 --- a/examples/freertos_plus_tcp/z_sub.c +++ b/examples/freertos_plus_tcp/z_sub.c @@ -45,7 +45,8 @@ void app_main(void) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return; diff --git a/examples/freertos_plus_tcp/z_sub_st.c b/examples/freertos_plus_tcp/z_sub_st.c index ebcf180bc..8e53e3f26 100644 --- a/examples/freertos_plus_tcp/z_sub_st.c +++ b/examples/freertos_plus_tcp/z_sub_st.c @@ -49,7 +49,8 @@ void app_main(void) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return; diff --git a/examples/mbed/z_get.cpp b/examples/mbed/z_get.cpp index 905ac4e1c..0fe71405b 100644 --- a/examples/mbed/z_get.cpp +++ b/examples/mbed/z_get.cpp @@ -52,7 +52,8 @@ int main(int argc, char **argv) { net.connect(); // Initialize Zenoh Session and other parameters - z_owned_config_t config = z_config_default(); + z_owned_config_t config; + z_config_default(&config); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT)); @@ -60,7 +61,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/mbed/z_pub.cpp b/examples/mbed/z_pub.cpp index 0fb939071..2cc28df22 100644 --- a/examples/mbed/z_pub.cpp +++ b/examples/mbed/z_pub.cpp @@ -39,7 +39,8 @@ int main(int argc, char **argv) { net.connect(); // Initialize Zenoh Session and other parameters - z_owned_config_t config = z_config_default(); + z_owned_config_t config; + z_config_default(&config); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT)); @@ -47,7 +48,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/mbed/z_pull.cpp b/examples/mbed/z_pull.cpp index 24acaeaec..c32ea6b68 100644 --- a/examples/mbed/z_pull.cpp +++ b/examples/mbed/z_pull.cpp @@ -46,7 +46,8 @@ int main(int argc, char **argv) { net.connect(); // Initialize Zenoh Session and other parameters - z_owned_config_t config = z_config_default(); + z_owned_config_t config; + z_config_default(&config); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT)); @@ -54,7 +55,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/mbed/z_queryable.cpp b/examples/mbed/z_queryable.cpp index b0b9358bf..96a71f320 100644 --- a/examples/mbed/z_queryable.cpp +++ b/examples/mbed/z_queryable.cpp @@ -48,7 +48,8 @@ int main(int argc, char **argv) { net.connect(); // Initialize Zenoh Session and other parameters - z_owned_config_t config = z_config_default(); + z_owned_config_t config; + z_config_default(&config); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT)); @@ -56,7 +57,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/mbed/z_scout.cpp b/examples/mbed/z_scout.cpp index c3cdf5d41..8b53bda86 100644 --- a/examples/mbed/z_scout.cpp +++ b/examples/mbed/z_scout.cpp @@ -99,7 +99,8 @@ int main(void) { int *context = (int *)malloc(sizeof(int)); *context = 0; - z_owned_scouting_config_t config = z_scouting_config_default(); + z_owned_scouting_config_t config; + z_scouting_config_default(&config); z_owned_closure_hello_t closure = z_closure_hello(callback, drop, context); printf("Scouting...\n"); z_scout(z_scouting_config_move(&config), z_closure_hello_move(&closure)); diff --git a/examples/mbed/z_sub.cpp b/examples/mbed/z_sub.cpp index b60f82d44..6255ad23a 100644 --- a/examples/mbed/z_sub.cpp +++ b/examples/mbed/z_sub.cpp @@ -45,7 +45,8 @@ int main(int argc, char **argv) { net.connect(); // Initialize Zenoh Session and other parameters - z_owned_config_t config = z_config_default(); + z_owned_config_t config; + z_config_default(&config); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE)); if (strcmp(CONNECT, "") != 0) { zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(CONNECT)); @@ -53,7 +54,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_config_move(&config)); + z_owned_session_t s; + z_open(&s, z_config_move(&config)); if (!z_session_check(&s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index a67a203ed..196d8c1f6 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -92,7 +92,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_get_channel.c b/examples/unix/c11/z_get_channel.c index 821024253..00cba7f1c 100644 --- a/examples/unix/c11/z_get_channel.c +++ b/examples/unix/c11/z_get_channel.c @@ -68,7 +68,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index 269d5bd92..8833212fd 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -67,7 +67,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index 4d2f7003d..018b4a23f 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -65,7 +65,8 @@ int main(int argc, char** argv) { z_condvar_init(&cond); z_owned_config_t config; z_config_default(&config); - z_owned_session_t session = z_open(z_move(config)); + z_owned_session_t session; + z_open(&session, z_move(config)); if (!z_check(session)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index bf2c0f3e9..e8647214f 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -34,7 +34,8 @@ int main(int argc, char** argv) { (void)argv; z_owned_config_t config; z_config_default(&config); - z_owned_session_t session = z_open(z_move(config)); + z_owned_session_t session; + z_open(&session, z_move(config)); if (!z_check(session)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_pub.c b/examples/unix/c11/z_pub.c index 245f09657..6b881769b 100644 --- a/examples/unix/c11/z_pub.c +++ b/examples/unix/c11/z_pub.c @@ -77,7 +77,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_pub_st.c b/examples/unix/c11/z_pub_st.c index 6cd8970bc..e9b5f558b 100644 --- a/examples/unix/c11/z_pub_st.c +++ b/examples/unix/c11/z_pub_st.c @@ -74,7 +74,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_pub_thr.c b/examples/unix/c11/z_pub_thr.c index 1a373f679..c6fba29b3 100644 --- a/examples/unix/c11/z_pub_thr.c +++ b/examples/unix/c11/z_pub_thr.c @@ -39,7 +39,8 @@ int main(int argc, char **argv) { } } // Open session - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/unix/c11/z_pull.c b/examples/unix/c11/z_pull.c index 1ea90d4a5..0f6cb1590 100644 --- a/examples/unix/c11/z_pull.c +++ b/examples/unix/c11/z_pull.c @@ -59,7 +59,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index f2eaa92ab..dfb67822f 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -72,7 +72,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index d42003b9d..1ae3244bd 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -83,7 +83,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_queryable_channel.c b/examples/unix/c11/z_queryable_channel.c index e0585b684..e12fb3fec 100644 --- a/examples/unix/c11/z_queryable_channel.c +++ b/examples/unix/c11/z_queryable_channel.c @@ -68,7 +68,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index ab93e1d6c..69a4be9f1 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -95,7 +95,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_sub_channel.c b/examples/unix/c11/z_sub_channel.c index 15a5330d6..87671d52c 100644 --- a/examples/unix/c11/z_sub_channel.c +++ b/examples/unix/c11/z_sub_channel.c @@ -51,7 +51,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_sub_st.c b/examples/unix/c11/z_sub_st.c index 7562e090d..3a2cd04b5 100644 --- a/examples/unix/c11/z_sub_st.c +++ b/examples/unix/c11/z_sub_st.c @@ -80,7 +80,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/unix/c11/z_sub_thr.c b/examples/unix/c11/z_sub_thr.c index 5106fde57..648af3c5f 100644 --- a/examples/unix/c11/z_sub_thr.c +++ b/examples/unix/c11/z_sub_thr.c @@ -80,7 +80,8 @@ int main(int argc, char **argv) { } } // Open session - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/windows/z_get.c b/examples/windows/z_get.c index 14f47a79e..c156d9f89 100644 --- a/examples/windows/z_get.c +++ b/examples/windows/z_get.c @@ -57,7 +57,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_info.c b/examples/windows/z_info.c index 49d8ae8fc..b4600585e 100644 --- a/examples/windows/z_info.c +++ b/examples/windows/z_info.c @@ -40,7 +40,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index dbb608f5c..1bdd33684 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -65,7 +65,8 @@ int main(int argc, char** argv) { z_condvar_init(&cond); z_owned_config_t config; z_config_default(&config); - z_owned_session_t session = z_open(z_move(config)); + z_owned_session_t s; + z_open(&session, z_move(config)); if (!z_check(session)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index bf2c0f3e9..9d7b81b19 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -34,7 +34,8 @@ int main(int argc, char** argv) { (void)argv; z_owned_config_t config; z_config_default(&config); - z_owned_session_t session = z_open(z_move(config)); + z_owned_session_t s; + z_open(&session, z_move(config)); if (!z_check(session)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_pub.c b/examples/windows/z_pub.c index 7c20866ad..b7b10bc7e 100644 --- a/examples/windows/z_pub.c +++ b/examples/windows/z_pub.c @@ -35,7 +35,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_pub_st.c b/examples/windows/z_pub_st.c index 818164609..c75c8b806 100644 --- a/examples/windows/z_pub_st.c +++ b/examples/windows/z_pub_st.c @@ -37,7 +37,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_pull.c b/examples/windows/z_pull.c index 181ab4c90..4a28f6724 100644 --- a/examples/windows/z_pull.c +++ b/examples/windows/z_pull.c @@ -40,7 +40,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_put.c b/examples/windows/z_put.c index 008ab820c..2f8dc5483 100644 --- a/examples/windows/z_put.c +++ b/examples/windows/z_put.c @@ -35,7 +35,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_queryable.c b/examples/windows/z_queryable.c index 8b188ae39..759057927 100644 --- a/examples/windows/z_queryable.c +++ b/examples/windows/z_queryable.c @@ -48,7 +48,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_sub.c b/examples/windows/z_sub.c index 1a224a25f..5d196baf9 100644 --- a/examples/windows/z_sub.c +++ b/examples/windows/z_sub.c @@ -42,7 +42,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/windows/z_sub_st.c b/examples/windows/z_sub_st.c index da27566fd..d499e70bb 100644 --- a/examples/windows/z_sub_st.c +++ b/examples/windows/z_sub_st.c @@ -47,7 +47,8 @@ int main(int argc, char **argv) { } printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/examples/zephyr/z_get.c b/examples/zephyr/z_get.c index ef608b249..6362cb8e7 100644 --- a/examples/zephyr/z_get.c +++ b/examples/zephyr/z_get.c @@ -57,7 +57,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/zephyr/z_pub.c b/examples/zephyr/z_pub.c index dceac3cc1..61b902760 100644 --- a/examples/zephyr/z_pub.c +++ b/examples/zephyr/z_pub.c @@ -45,7 +45,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/zephyr/z_pull.c b/examples/zephyr/z_pull.c index c2c65d51d..58145744c 100644 --- a/examples/zephyr/z_pull.c +++ b/examples/zephyr/z_pull.c @@ -50,7 +50,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/zephyr/z_queryable.c b/examples/zephyr/z_queryable.c index c38abc75d..9f2f92214 100644 --- a/examples/zephyr/z_queryable.c +++ b/examples/zephyr/z_queryable.c @@ -53,7 +53,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/examples/zephyr/z_sub.c b/examples/zephyr/z_sub.c index b80ba82d9..a1ca8d339 100644 --- a/examples/zephyr/z_sub.c +++ b/examples/zephyr/z_sub.c @@ -49,7 +49,8 @@ int main(int argc, char **argv) { // Open Zenoh session printf("Opening Zenoh Session..."); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/include/zenoh-pico/api/primitives.h b/include/zenoh-pico/api/primitives.h index 2b54f16fc..1844582bf 100644 --- a/include/zenoh-pico/api/primitives.h +++ b/include/zenoh-pico/api/primitives.h @@ -801,7 +801,7 @@ int8_t z_scout(z_owned_scouting_config_t *config, z_owned_closure_hello_t *callb * A :c:type:`z_owned_session_t` with either a valid open session or a failing session. * Should the session opening fail, ``z_check(val)`` ing the returned value will return ``false``. */ -z_owned_session_t z_open(z_owned_config_t *config); +int8_t z_open(z_owned_session_t *zs, z_owned_config_t *config); /** * Closes a Zenoh session. diff --git a/src/api/api.c b/src/api/api.c index fa8c0f4d5..4e16215d6 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -561,26 +561,26 @@ int8_t z_scout(z_owned_scouting_config_t *config, z_owned_closure_hello_t *callb return ret; } -z_owned_session_t z_open(z_owned_config_t *config) { - z_owned_session_t zs; - z_session_null(&zs); +int8_t z_open(z_owned_session_t *zs, z_owned_config_t *config) { + z_session_null(zs); // Create rc _z_session_rc_t zsrc = _z_session_rc_new(); if (zsrc.in == NULL) { z_config_drop(config); - return zs; + return _Z_ERR_SYSTEM_OUT_OF_MEMORY; } // Open session - if (_z_open(&zsrc.in->val, config->_value) != _Z_RES_OK) { + int8_t ret = _z_open(&zsrc.in->val, config->_value); + if (ret != _Z_RES_OK) { _z_session_rc_drop(&zsrc); z_config_drop(config); - return zs; + return ret; } // Store rc in session - zs._rc = zsrc; + zs->_rc = zsrc; z_config_drop(config); - return zs; + return _Z_RES_OK; } int8_t z_close(z_owned_session_t *zs) { diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index 0a6b59f77..eda75c0d2 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -221,7 +221,8 @@ int main(int argc, char **argv) { printf("Ok\n"); z_sleep_s(SLEEP); - z_owned_session_t s1 = z_open(z_move(_ret_config)); + z_owned_session_t s1; + z_open(&s1, z_move(_ret_config)); assert(z_check(s1)); z_id_t _ret_zid = z_info_zid(z_loan(s1)); printf("Session 1 with PID: 0x"); @@ -260,7 +261,8 @@ int main(int argc, char **argv) { assert_eq(strncmp(_ret_cstr, argv[1], strlen(_ret_cstr)), 0); #endif - z_owned_session_t s2 = z_open(z_move(_ret_config)); + z_owned_session_t s2; + z_open(&s2, z_move(_ret_config)); assert(z_check(s2)); _ret_zid = z_info_zid(z_loan(s2)); printf("Session 2 with PID: 0x"); diff --git a/tests/z_client_test.c b/tests/z_client_test.c index 61f8b5d6f..02bc0f5f5 100644 --- a/tests/z_client_test.c +++ b/tests/z_client_test.c @@ -121,7 +121,8 @@ int main(int argc, char **argv) { for (unsigned int i = 0; i < SET; i++) idx[i] = i; - z_owned_session_t s1 = z_open(z_move(config)); + z_owned_session_t s1; + z_open(&s1, z_move(config)); assert(z_check(s1)); z_string_t zid1 = format_id(&(_Z_RC_IN_VAL(z_loan(s1))._local_zid)); printf("Session 1 with PID: %s\n", zid1.val); @@ -136,7 +137,8 @@ int main(int argc, char **argv) { z_config_default(&config); zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(argv[1])); - z_owned_session_t s2 = z_open(z_move(config)); + z_owned_session_t s2; + z_open(&s2, z_move(config)); assert(z_check(s2)); z_string_t zid2 = format_id(&(_Z_RC_IN_VAL(z_loan(s2))._local_zid)); printf("Session 2 with PID: %s\n", zid2.val); diff --git a/tests/z_peer_multicast_test.c b/tests/z_peer_multicast_test.c index 6b7902a79..88f977b81 100644 --- a/tests/z_peer_multicast_test.c +++ b/tests/z_peer_multicast_test.c @@ -72,7 +72,8 @@ int main(int argc, char **argv) { for (unsigned int i = 0; i < SET; i++) idx[i] = i; - z_owned_session_t s1 = z_open(z_move(config)); + z_owned_session_t s1; + z_open(&s1, z_move(config)); assert(z_check(s1)); _z_bytes_t id_as_bytes = _z_bytes_wrap(_Z_RC_IN_VAL(z_loan(s1))._local_zid.id, _z_id_len(_Z_RC_IN_VAL(z_loan(s1))._local_zid)); @@ -90,7 +91,8 @@ int main(int argc, char **argv) { zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make("peer")); zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(argv[1])); - z_owned_session_t s2 = z_open(z_move(config)); + z_owned_session_t s2; + z_open(&s2, z_move(config)); assert(z_check(s2)); id_as_bytes = _z_bytes_wrap(_Z_RC_IN_VAL(z_loan(s2))._local_zid.id, _z_id_len(_Z_RC_IN_VAL(z_loan(s2))._local_zid)); z_string_t zid2 = _z_string_from_bytes(&id_as_bytes); diff --git a/tests/z_perf_rx.c b/tests/z_perf_rx.c index 44263e32b..e2d9c1f40 100644 --- a/tests/z_perf_rx.c +++ b/tests/z_perf_rx.c @@ -86,7 +86,8 @@ int main(int argc, char **argv) { zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); } // Open session - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/tests/z_perf_tx.c b/tests/z_perf_tx.c index 042fe7a1a..b0fcb4432 100644 --- a/tests/z_perf_tx.c +++ b/tests/z_perf_tx.c @@ -64,7 +64,8 @@ int main(int argc, char **argv) { zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); } // Open session - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); exit(-1); diff --git a/tests/z_session_test.c b/tests/z_session_test.c index 624696a86..57f383dbc 100644 --- a/tests/z_session_test.c +++ b/tests/z_session_test.c @@ -27,7 +27,8 @@ int main(void) { zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make("client")); printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/tests/z_test_fragment_rx.c b/tests/z_test_fragment_rx.c index 1df4b7528..c2c0aa824 100644 --- a/tests/z_test_fragment_rx.c +++ b/tests/z_test_fragment_rx.c @@ -61,7 +61,8 @@ int main(int argc, char **argv) { zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); } // Open session - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1; diff --git a/tests/z_test_fragment_tx.c b/tests/z_test_fragment_tx.c index 6e9bb3a06..402c62f70 100644 --- a/tests/z_test_fragment_tx.c +++ b/tests/z_test_fragment_tx.c @@ -58,7 +58,8 @@ int main(int argc, char **argv) { zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); } // Open session - z_owned_session_t s = z_open(z_move(config)); + z_owned_session_t s; + z_open(&s, z_move(config)); if (!z_check(s)) { printf("Unable to open session!\n"); return -1;