From 170a12a9880303ba06a788e15b668857306a72cd Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Thu, 18 Jan 2024 17:06:13 +0100 Subject: [PATCH 1/9] fix: missing newline on task start fail log --- examples/unix/c11/z_get.c | 2 +- examples/unix/c11/z_info.c | 2 +- examples/unix/c11/z_ping.c | 2 +- examples/unix/c11/z_pong.c | 2 +- examples/unix/c11/z_pub.c | 2 +- examples/unix/c11/z_pub_thr.c | 2 +- examples/unix/c11/z_pull.c | 2 +- examples/unix/c11/z_put.c | 2 +- examples/unix/c11/z_queryable.c | 2 +- examples/unix/c11/z_sub.c | 2 +- examples/unix/c11/z_sub_thr.c | 2 +- examples/unix/c99/z_get.c | 2 +- examples/unix/c99/z_info.c | 2 +- examples/unix/c99/z_ping.c | 2 +- examples/unix/c99/z_pong.c | 2 +- examples/unix/c99/z_pub.c | 2 +- examples/unix/c99/z_pull.c | 2 +- examples/unix/c99/z_put.c | 2 +- examples/unix/c99/z_queryable.c | 2 +- examples/unix/c99/z_sub.c | 2 +- examples/windows/z_get.c | 2 +- examples/windows/z_info.c | 2 +- examples/windows/z_ping.c | 2 +- examples/windows/z_pong.c | 2 +- examples/windows/z_pub.c | 2 +- examples/windows/z_pull.c | 2 +- examples/windows/z_put.c | 2 +- examples/windows/z_queryable.c | 2 +- examples/windows/z_sub.c | 2 +- tests/z_perf_rx.c | 2 +- tests/z_perf_tx.c | 2 +- tests/z_session_test.c | 2 +- tests/z_test_fragment_rx.c | 2 +- tests/z_test_fragment_tx.c | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index e2aa07e9c..aa05bc2a2 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -91,7 +91,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index 2740d5110..5b73c8d59 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -74,7 +74,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index 65a871f05..72d794bfe 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -71,7 +71,7 @@ int main(int argc, char** argv) { } if (zp_start_read_task(z_loan(session), NULL) < 0 || zp_start_lease_task(z_loan(session), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index 8991729e9..5aea9d09e 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -40,7 +40,7 @@ int main(int argc, char** argv) { } if (zp_start_read_task(z_loan(session), NULL) < 0 || zp_start_lease_task(z_loan(session), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_pub.c b/examples/unix/c11/z_pub.c index 2d0ea81ac..b6df956d1 100644 --- a/examples/unix/c11/z_pub.c +++ b/examples/unix/c11/z_pub.c @@ -84,7 +84,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_pub_thr.c b/examples/unix/c11/z_pub_thr.c index d1379c43c..45a935420 100644 --- a/examples/unix/c11/z_pub_thr.c +++ b/examples/unix/c11/z_pub_thr.c @@ -45,7 +45,7 @@ int main(int argc, char **argv) { } // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); exit(-1); } // Declare publisher diff --git a/examples/unix/c11/z_pull.c b/examples/unix/c11/z_pull.c index c39f19c52..dc955e096 100644 --- a/examples/unix/c11/z_pull.c +++ b/examples/unix/c11/z_pull.c @@ -66,7 +66,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index a542c26ac..5ce5b8ee4 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -79,7 +79,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index d9bb7c74a..9b1cd3f65 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -90,7 +90,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index 99ea3e1d7..a9c2c07fd 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -95,7 +95,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c11/z_sub_thr.c b/examples/unix/c11/z_sub_thr.c index 347a70848..a84a288a8 100644 --- a/examples/unix/c11/z_sub_thr.c +++ b/examples/unix/c11/z_sub_thr.c @@ -86,7 +86,7 @@ int main(int argc, char **argv) { } // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); exit(-1); } // Declare Subscriber/resource diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index 29f844879..b2a3d32fa 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -91,7 +91,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c99/z_info.c b/examples/unix/c99/z_info.c index 60606c73a..e50c22a69 100644 --- a/examples/unix/c99/z_info.c +++ b/examples/unix/c99/z_info.c @@ -74,7 +74,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index 0ab80b8ba..542578ee0 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -73,7 +73,7 @@ int main(int argc, char** argv) { if (zp_start_read_task(z_session_loan(&session), NULL) < 0 || zp_start_lease_task(z_session_loan(&session), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index 73570e138..009afa071 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -42,7 +42,7 @@ int main(int argc, char** argv) { if (zp_start_read_task(z_session_loan(&session), NULL) < 0 || zp_start_lease_task(z_session_loan(&session), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index f617c7741..9995a69fb 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -75,7 +75,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c99/z_pull.c b/examples/unix/c99/z_pull.c index 10c16d462..e9fcbb0ea 100644 --- a/examples/unix/c99/z_pull.c +++ b/examples/unix/c99/z_pull.c @@ -66,7 +66,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index 82c259426..218593fcf 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -75,7 +75,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index a7c2d28af..95a31821d 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -86,7 +86,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index 88c144889..25b217569 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -79,7 +79,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_get.c b/examples/windows/z_get.c index 5d2676ffc..5033f3719 100644 --- a/examples/windows/z_get.c +++ b/examples/windows/z_get.c @@ -56,7 +56,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_info.c b/examples/windows/z_info.c index eed2c2952..5f1889c29 100644 --- a/examples/windows/z_info.c +++ b/examples/windows/z_info.c @@ -47,7 +47,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index e260f5459..fdda1c081 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -71,7 +71,7 @@ int main(int argc, char** argv) { } if (zp_start_read_task(z_loan(session), NULL) < 0 || zp_start_lease_task(z_loan(session), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index 8991729e9..5aea9d09e 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -40,7 +40,7 @@ int main(int argc, char** argv) { } if (zp_start_read_task(z_loan(session), NULL) < 0 || zp_start_lease_task(z_loan(session), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_pub.c b/examples/windows/z_pub.c index 89c542ad4..61a3abfc2 100644 --- a/examples/windows/z_pub.c +++ b/examples/windows/z_pub.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_pull.c b/examples/windows/z_pull.c index 4480a43d0..941295e01 100644 --- a/examples/windows/z_pull.c +++ b/examples/windows/z_pull.c @@ -46,7 +46,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_put.c b/examples/windows/z_put.c index 29febb7a2..40a7d0e2b 100644 --- a/examples/windows/z_put.c +++ b/examples/windows/z_put.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_queryable.c b/examples/windows/z_queryable.c index d010ce3fa..23ec86b74 100644 --- a/examples/windows/z_queryable.c +++ b/examples/windows/z_queryable.c @@ -55,7 +55,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/examples/windows/z_sub.c b/examples/windows/z_sub.c index 57cd8f13f..0b0ffc6ad 100644 --- a/examples/windows/z_sub.c +++ b/examples/windows/z_sub.c @@ -49,7 +49,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/tests/z_perf_rx.c b/tests/z_perf_rx.c index 47ebb5cb0..fff0ba46a 100644 --- a/tests/z_perf_rx.c +++ b/tests/z_perf_rx.c @@ -92,7 +92,7 @@ int main(int argc, char **argv) { } // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); exit(-1); } // Declare Subscriber/resource diff --git a/tests/z_perf_tx.c b/tests/z_perf_tx.c index d9e5e7777..83b80f575 100644 --- a/tests/z_perf_tx.c +++ b/tests/z_perf_tx.c @@ -70,7 +70,7 @@ int main(int argc, char **argv) { } // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); exit(-1); } // Declare publisher diff --git a/tests/z_session_test.c b/tests/z_session_test.c index c7afabec1..b2c9d7e95 100644 --- a/tests/z_session_test.c +++ b/tests/z_session_test.c @@ -34,7 +34,7 @@ int main(void) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } diff --git a/tests/z_test_fragment_rx.c b/tests/z_test_fragment_rx.c index b236b1cfc..038214fc6 100644 --- a/tests/z_test_fragment_rx.c +++ b/tests/z_test_fragment_rx.c @@ -58,7 +58,7 @@ int main(int argc, char **argv) { } // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } // Declare subscriber diff --git a/tests/z_test_fragment_tx.c b/tests/z_test_fragment_tx.c index bec1c673d..5af0a3519 100644 --- a/tests/z_test_fragment_tx.c +++ b/tests/z_test_fragment_tx.c @@ -53,7 +53,7 @@ int main(int argc, char **argv) { } // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); + printf("Unable to start read and lease tasks\n"); return -1; } // Put data From 76681cacb545fc2ae492d8db7201e66730a674fc Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Thu, 18 Jan 2024 17:06:41 +0100 Subject: [PATCH 2/9] feat: uniformize c99 pub example with c11 one --- examples/unix/c99/z_pub.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index 9995a69fb..d6beb1aaf 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -26,9 +26,10 @@ int main(int argc, char **argv) { const char *mode = "client"; char *clocator = NULL; char *llocator = NULL; + int n = 10; int opt; - while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { + while ((opt = getopt(argc, argv, "k:v:e:m:l:n:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -45,8 +46,12 @@ int main(int argc, char **argv) { case 'l': llocator = optarg; break; + case 'n': + n = atoi(optarg); + break; case '?': - if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { + if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l' || + optopt == 'n') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); @@ -86,25 +91,20 @@ int main(int argc, char **argv) { return -1; } - char *buf = (char *)malloc(256); - for (int idx = 0; 1; ++idx) { + for (int idx = 0; idx < n; ++idx) { sleep(1); - snprintf(buf, 256, "[%4d] %s", idx, value); - printf("Putting Data ('%s': '%s')...\n", keyexpr, buf); + (void)idx; + printf("Putting Data ('%s': '%s')...\n", keyexpr, value); + z_publisher_put_options_t options = z_publisher_put_options_default(); options.encoding = z_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN, NULL); - z_publisher_put(z_publisher_loan(&pub), (const uint8_t *)buf, strlen(buf), &options); + z_publisher_put(z_publisher_loan(&pub), (const uint8_t *)value, strlen(value), &options); } - + // Clean up z_undeclare_publisher(z_publisher_move(&pub)); - - // Stop read and lease tasks for zenoh-pico zp_stop_read_task(z_session_loan(&s)); zp_stop_lease_task(z_session_loan(&s)); - z_close(z_session_move(&s)); - - free(buf); return 0; } #else From d7c41140ec1a29a42d6ce60b163ec802f0e4212e Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Thu, 18 Jan 2024 17:22:20 +0100 Subject: [PATCH 3/9] fix: free session is task start fail --- examples/freertos_plus_tcp/z_get.c | 1 + examples/freertos_plus_tcp/z_pub.c | 1 + examples/freertos_plus_tcp/z_pull.c | 1 + examples/freertos_plus_tcp/z_put.c | 1 + examples/freertos_plus_tcp/z_queryable.c | 1 + examples/freertos_plus_tcp/z_sub.c | 1 + examples/unix/c11/z_get.c | 1 + examples/unix/c11/z_info.c | 1 + examples/unix/c11/z_ping.c | 1 + examples/unix/c11/z_pong.c | 1 + examples/unix/c11/z_pub.c | 1 + examples/unix/c11/z_pub_thr.c | 1 + examples/unix/c11/z_pull.c | 1 + examples/unix/c11/z_put.c | 1 + examples/unix/c11/z_queryable.c | 1 + examples/unix/c11/z_sub.c | 1 + examples/unix/c11/z_sub_thr.c | 1 + examples/unix/c99/z_get.c | 1 + examples/unix/c99/z_info.c | 1 + examples/unix/c99/z_ping.c | 1 + examples/unix/c99/z_pong.c | 1 + examples/unix/c99/z_pub.c | 1 + examples/unix/c99/z_pull.c | 1 + examples/unix/c99/z_put.c | 1 + examples/unix/c99/z_queryable.c | 1 + examples/unix/c99/z_sub.c | 1 + examples/windows/z_get.c | 1 + examples/windows/z_info.c | 1 + examples/windows/z_ping.c | 1 + examples/windows/z_pong.c | 1 + examples/windows/z_pub.c | 1 + examples/windows/z_pull.c | 1 + examples/windows/z_put.c | 1 + examples/windows/z_queryable.c | 1 + examples/windows/z_sub.c | 1 + tests/z_perf_rx.c | 1 + tests/z_perf_tx.c | 1 + tests/z_session_test.c | 1 + tests/z_test_fragment_rx.c | 1 + tests/z_test_fragment_tx.c | 1 + 40 files changed, 40 insertions(+) diff --git a/examples/freertos_plus_tcp/z_get.c b/examples/freertos_plus_tcp/z_get.c index 39545dc2a..6abd0175e 100644 --- a/examples/freertos_plus_tcp/z_get.c +++ b/examples/freertos_plus_tcp/z_get.c @@ -65,6 +65,7 @@ void app_main(void) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return; } diff --git a/examples/freertos_plus_tcp/z_pub.c b/examples/freertos_plus_tcp/z_pub.c index a71557045..c2d8ca55b 100644 --- a/examples/freertos_plus_tcp/z_pub.c +++ b/examples/freertos_plus_tcp/z_pub.c @@ -76,6 +76,7 @@ void app_main(void) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), &read_task_opt) < 0 || zp_start_lease_task(z_loan(s), &lease_task_opt) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return; } diff --git a/examples/freertos_plus_tcp/z_pull.c b/examples/freertos_plus_tcp/z_pull.c index 04d2c3e34..b8f5c5ee8 100644 --- a/examples/freertos_plus_tcp/z_pull.c +++ b/examples/freertos_plus_tcp/z_pull.c @@ -53,6 +53,7 @@ void app_main(void) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return; } diff --git a/examples/freertos_plus_tcp/z_put.c b/examples/freertos_plus_tcp/z_put.c index 40b142645..40bf859ec 100644 --- a/examples/freertos_plus_tcp/z_put.c +++ b/examples/freertos_plus_tcp/z_put.c @@ -46,6 +46,7 @@ void app_main(void) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return; } diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index ea46660d1..0d9ce87e4 100644 --- a/examples/freertos_plus_tcp/z_queryable.c +++ b/examples/freertos_plus_tcp/z_queryable.c @@ -61,6 +61,7 @@ void app_main(void) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return; } diff --git a/examples/freertos_plus_tcp/z_sub.c b/examples/freertos_plus_tcp/z_sub.c index ce4a90b1a..91395e59f 100644 --- a/examples/freertos_plus_tcp/z_sub.c +++ b/examples/freertos_plus_tcp/z_sub.c @@ -53,6 +53,7 @@ void app_main(void) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return; } diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index aa05bc2a2..ca45ec493 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -92,6 +92,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index 5b73c8d59..455fe17c7 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -75,6 +75,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index 72d794bfe..5e01bfaf6 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -72,6 +72,7 @@ int main(int argc, char** argv) { if (zp_start_read_task(z_loan(session), NULL) < 0 || zp_start_lease_task(z_loan(session), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&session)); return -1; } diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index 5aea9d09e..dc958e1bb 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -41,6 +41,7 @@ int main(int argc, char** argv) { if (zp_start_read_task(z_loan(session), NULL) < 0 || zp_start_lease_task(z_loan(session), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&session)); return -1; } diff --git a/examples/unix/c11/z_pub.c b/examples/unix/c11/z_pub.c index b6df956d1..064b53677 100644 --- a/examples/unix/c11/z_pub.c +++ b/examples/unix/c11/z_pub.c @@ -85,6 +85,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c11/z_pub_thr.c b/examples/unix/c11/z_pub_thr.c index 45a935420..dd3b50220 100644 --- a/examples/unix/c11/z_pub_thr.c +++ b/examples/unix/c11/z_pub_thr.c @@ -46,6 +46,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); exit(-1); } // Declare publisher diff --git a/examples/unix/c11/z_pull.c b/examples/unix/c11/z_pull.c index dc955e096..c6f710bfb 100644 --- a/examples/unix/c11/z_pull.c +++ b/examples/unix/c11/z_pull.c @@ -67,6 +67,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index 5ce5b8ee4..f339d9edf 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -80,6 +80,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index 9b1cd3f65..e9d1b95e5 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -91,6 +91,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index a9c2c07fd..e35fc1427 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -96,6 +96,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c11/z_sub_thr.c b/examples/unix/c11/z_sub_thr.c index a84a288a8..a12f5359d 100644 --- a/examples/unix/c11/z_sub_thr.c +++ b/examples/unix/c11/z_sub_thr.c @@ -87,6 +87,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); exit(-1); } // Declare Subscriber/resource diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index b2a3d32fa..46121e59e 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -92,6 +92,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c99/z_info.c b/examples/unix/c99/z_info.c index e50c22a69..c978af3b4 100644 --- a/examples/unix/c99/z_info.c +++ b/examples/unix/c99/z_info.c @@ -75,6 +75,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index 542578ee0..9269b27b5 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -74,6 +74,7 @@ int main(int argc, char** argv) { if (zp_start_read_task(z_session_loan(&session), NULL) < 0 || zp_start_lease_task(z_session_loan(&session), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&session)); return -1; } diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index 009afa071..73f93d9a1 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -43,6 +43,7 @@ int main(int argc, char** argv) { if (zp_start_read_task(z_session_loan(&session), NULL) < 0 || zp_start_lease_task(z_session_loan(&session), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&session)); return -1; } diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index d6beb1aaf..36483fae3 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -81,6 +81,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c99/z_pull.c b/examples/unix/c99/z_pull.c index e9fcbb0ea..efe2ba8bf 100644 --- a/examples/unix/c99/z_pull.c +++ b/examples/unix/c99/z_pull.c @@ -67,6 +67,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index 218593fcf..2ebcd4178 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -76,6 +76,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index 95a31821d..8460aef16 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -87,6 +87,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index 25b217569..8d25dbb74 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -80,6 +80,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_session_loan(&s), NULL) < 0 || zp_start_lease_task(z_session_loan(&s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/windows/z_get.c b/examples/windows/z_get.c index 5033f3719..2815656dc 100644 --- a/examples/windows/z_get.c +++ b/examples/windows/z_get.c @@ -57,6 +57,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/windows/z_info.c b/examples/windows/z_info.c index 5f1889c29..7967e1aa2 100644 --- a/examples/windows/z_info.c +++ b/examples/windows/z_info.c @@ -48,6 +48,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index fdda1c081..5643832c0 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -72,6 +72,7 @@ int main(int argc, char** argv) { if (zp_start_read_task(z_loan(session), NULL) < 0 || zp_start_lease_task(z_loan(session), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&session)); return -1; } diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index 5aea9d09e..dc958e1bb 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -41,6 +41,7 @@ int main(int argc, char** argv) { if (zp_start_read_task(z_loan(session), NULL) < 0 || zp_start_lease_task(z_loan(session), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&session)); return -1; } diff --git a/examples/windows/z_pub.c b/examples/windows/z_pub.c index 61a3abfc2..8c17d7f7d 100644 --- a/examples/windows/z_pub.c +++ b/examples/windows/z_pub.c @@ -43,6 +43,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/windows/z_pull.c b/examples/windows/z_pull.c index 941295e01..512b2bb79 100644 --- a/examples/windows/z_pull.c +++ b/examples/windows/z_pull.c @@ -47,6 +47,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/windows/z_put.c b/examples/windows/z_put.c index 40a7d0e2b..166edca4e 100644 --- a/examples/windows/z_put.c +++ b/examples/windows/z_put.c @@ -43,6 +43,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/windows/z_queryable.c b/examples/windows/z_queryable.c index 23ec86b74..7a2d7771c 100644 --- a/examples/windows/z_queryable.c +++ b/examples/windows/z_queryable.c @@ -56,6 +56,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/examples/windows/z_sub.c b/examples/windows/z_sub.c index 0b0ffc6ad..0ffd26568 100644 --- a/examples/windows/z_sub.c +++ b/examples/windows/z_sub.c @@ -50,6 +50,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/tests/z_perf_rx.c b/tests/z_perf_rx.c index fff0ba46a..2eadf731c 100644 --- a/tests/z_perf_rx.c +++ b/tests/z_perf_rx.c @@ -93,6 +93,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); exit(-1); } // Declare Subscriber/resource diff --git a/tests/z_perf_tx.c b/tests/z_perf_tx.c index 83b80f575..168294d28 100644 --- a/tests/z_perf_tx.c +++ b/tests/z_perf_tx.c @@ -71,6 +71,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); exit(-1); } // Declare publisher diff --git a/tests/z_session_test.c b/tests/z_session_test.c index b2c9d7e95..33b1977bc 100644 --- a/tests/z_session_test.c +++ b/tests/z_session_test.c @@ -35,6 +35,7 @@ int main(void) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } diff --git a/tests/z_test_fragment_rx.c b/tests/z_test_fragment_rx.c index 038214fc6..133497694 100644 --- a/tests/z_test_fragment_rx.c +++ b/tests/z_test_fragment_rx.c @@ -59,6 +59,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } // Declare subscriber diff --git a/tests/z_test_fragment_tx.c b/tests/z_test_fragment_tx.c index 5af0a3519..b002a34d8 100644 --- a/tests/z_test_fragment_tx.c +++ b/tests/z_test_fragment_tx.c @@ -54,6 +54,7 @@ int main(int argc, char **argv) { // Start read and lease tasks for zenoh-pico if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { printf("Unable to start read and lease tasks\n"); + z_close(z_session_move(&s)); return -1; } // Put data From 2815447ec3264206a11e03ff38100fe6e5948175 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Thu, 18 Jan 2024 17:27:09 +0100 Subject: [PATCH 4/9] fix: unitiialized data issue --- src/protocol/codec/transport.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/protocol/codec/transport.c b/src/protocol/codec/transport.c index e830cb7e6..1eaf27a41 100644 --- a/src/protocol/codec/transport.c +++ b/src/protocol/codec/transport.c @@ -351,6 +351,7 @@ int8_t _z_frame_decode(_z_t_msg_frame_t *msg, _z_zbuf_t *zbf, uint8_t header) { // Mark the reading position of the iobfer size_t r_pos = _z_zbuf_get_rpos(zbf); _z_network_message_t *nm = (_z_network_message_t *)zp_malloc(sizeof(_z_network_message_t)); + memset(nm, 0, sizeof(_z_network_message_t)); ret |= _z_network_message_decode(nm, zbf); if (ret == _Z_RES_OK) { _z_network_message_vec_append(&msg->_messages, nm); From c315a0fe309439b7fb8cf80de9153400f5f5be5b Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Fri, 19 Jan 2024 09:59:28 +0100 Subject: [PATCH 5/9] fix: clean up if declare keyexpr fail in z_put --- examples/freertos_plus_tcp/z_put.c | 7 ++++--- examples/unix/c11/z_put.c | 17 ++++++++++------- examples/unix/c99/z_put.c | 7 ++++--- examples/windows/z_put.c | 7 ++++--- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/examples/freertos_plus_tcp/z_put.c b/examples/freertos_plus_tcp/z_put.c index 40bf859ec..898d0e9b8 100644 --- a/examples/freertos_plus_tcp/z_put.c +++ b/examples/freertos_plus_tcp/z_put.c @@ -54,6 +54,9 @@ void app_main(void) { z_owned_keyexpr_t ke = z_declare_keyexpr(z_loan(s), z_keyexpr(KEYEXPR)); if (!z_check(ke)) { printf("Unable to declare key expression!\n"); + zp_stop_read_task(z_loan(s)); + zp_stop_lease_task(z_loan(s)); + z_close(z_move(s)); return; } @@ -68,12 +71,10 @@ void app_main(void) { zp_sleep_s(1); } + // Clean up z_undeclare_keyexpr(z_loan(s), z_move(ke)); - - // Stop read and lease tasks for zenoh-pico zp_stop_read_task(z_loan(s)); zp_stop_lease_task(z_loan(s)); - z_close(z_move(s)); } #else diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index f339d9edf..19c6b051a 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -85,11 +85,14 @@ int main(int argc, char **argv) { } printf("Declaring key expression '%s'...\n", keyexpr); - // z_owned_keyexpr_t ke = z_declare_keyexpr(z_loan(s), z_keyexpr(keyexpr)); - // if (!z_check(ke)) { - // printf("Unable to declare key expression!\n"); - // return -1; - // } + z_owned_keyexpr_t ke = z_declare_keyexpr(z_loan(s), z_keyexpr(keyexpr)); + if (!z_check(ke)) { + printf("Unable to declare key expression!\n"); + zp_stop_read_task(z_loan(s)); + zp_stop_lease_task(z_loan(s)); + z_close(z_move(s)); + return -1; + } printf("Putting Data ('%s': '%s')...\n", keyexpr, value); z_put_options_t options = z_put_options_default(); @@ -106,9 +109,9 @@ int main(int argc, char **argv) { #if Z_FEATURE_ATTACHMENT == 1 z_bytes_map_drop(&map); #endif - // z_undeclare_keyexpr(z_loan(s), z_move(ke)); - // Stop read and lease tasks for zenoh-pico + // Clean up + z_undeclare_keyexpr(z_loan(s), z_move(ke)); zp_stop_read_task(z_loan(s)); zp_stop_lease_task(z_loan(s)); z_close(z_move(s)); diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index 2ebcd4178..453444869 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -84,6 +84,9 @@ int main(int argc, char **argv) { z_owned_keyexpr_t ke = z_declare_keyexpr(z_session_loan(&s), z_keyexpr(keyexpr)); if (!z_keyexpr_check(&ke)) { printf("Unable to declare key expression!\n"); + zp_stop_read_task(z_session_loan(&s)); + zp_stop_lease_task(z_session_loan(&s)); + z_close(z_session_move(&s)); return -1; } @@ -94,12 +97,10 @@ int main(int argc, char **argv) { printf("Oh no! Put has failed...\n"); } + // Clean up z_undeclare_keyexpr(z_session_loan(&s), z_keyexpr_move(&ke)); - - // Stop read and lease tasks for zenoh-pico zp_stop_read_task(z_session_loan(&s)); zp_stop_lease_task(z_session_loan(&s)); - z_close(z_session_move(&s)); return 0; } diff --git a/examples/windows/z_put.c b/examples/windows/z_put.c index 166edca4e..32f7802a7 100644 --- a/examples/windows/z_put.c +++ b/examples/windows/z_put.c @@ -51,6 +51,9 @@ int main(int argc, char **argv) { z_owned_keyexpr_t ke = z_declare_keyexpr(z_loan(s), z_keyexpr(keyexpr)); if (!z_check(ke)) { printf("Unable to declare key expression!\n"); + zp_stop_read_task(z_loan(s)); + zp_stop_lease_task(z_loan(s)); + z_close(z_move(s)); return -1; } @@ -61,12 +64,10 @@ int main(int argc, char **argv) { printf("Oh no! Put has failed...\n"); } + // Clean up z_undeclare_keyexpr(z_loan(s), z_move(ke)); - - // Stop read and lease tasks for zenoh-pico zp_stop_read_task(z_loan(s)); zp_stop_lease_task(z_loan(s)); - z_close(z_move(s)); return 0; } From 7b6a728443992b95b10176cbe19594c7b89467dd Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Fri, 19 Jan 2024 10:26:52 +0100 Subject: [PATCH 6/9] fix: run Wconversion on c11 examples --- examples/unix/c11/z_ping.c | 8 ++++---- examples/unix/c11/z_pub_thr.c | 2 +- examples/unix/c11/z_sub_thr.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index 5e01bfaf6..564cbc365 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -94,7 +94,7 @@ int main(int argc, char** argv) { uint8_t* data = zp_malloc(args.size); for (unsigned int i = 0; i < args.size; i++) { - data[i] = i % 10; + data[i] = (uint8_t)(i % 10); } zp_mutex_lock(&mutex); if (args.warmup_ms) { @@ -152,17 +152,17 @@ struct args_t parse_args(int argc, char** argv) { char* arg = getopt(argc, argv, 's'); unsigned int size = DEFAULT_PKT_SIZE; if (arg) { - size = atoi(arg); + size = (unsigned int)atoi(arg); } arg = getopt(argc, argv, 'n'); unsigned int number_of_pings = DEFAULT_PING_NB; if (arg) { - number_of_pings = atoi(arg); + number_of_pings = (unsigned int)atoi(arg); } arg = getopt(argc, argv, 'w'); unsigned int warmup_ms = DEFAULT_WARMUP_MS; if (arg) { - warmup_ms = atoi(arg); + warmup_ms = (unsigned int)atoi(arg); } return (struct args_t){ .help_requested = 0, diff --git a/examples/unix/c11/z_pub_thr.c b/examples/unix/c11/z_pub_thr.c index dd3b50220..9711ed46c 100644 --- a/examples/unix/c11/z_pub_thr.c +++ b/examples/unix/c11/z_pub_thr.c @@ -25,7 +25,7 @@ int main(int argc, char **argv) { exit(-1); } char *keyexpr = "test/thr"; - size_t len = atoi(argv[1]); + size_t len = (size_t)atoi(argv[1]); uint8_t *value = (uint8_t *)malloc(len); memset(value, 1, len); diff --git a/examples/unix/c11/z_sub_thr.c b/examples/unix/c11/z_sub_thr.c index a12f5359d..39e3e894a 100644 --- a/examples/unix/c11/z_sub_thr.c +++ b/examples/unix/c11/z_sub_thr.c @@ -102,7 +102,7 @@ int main(int argc, char **argv) { printf("Start listening.\n"); char c = 0; while (c != 'q') { - c = fgetc(stdin); + c = (char)fgetc(stdin); } // Wait for everything to settle printf("End of test\n"); From 7c5c4431c39e5f170b29542ad9b04616426e5dc2 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Fri, 19 Jan 2024 10:27:44 +0100 Subject: [PATCH 7/9] fix: run Wconversion on tests --- tests/z_iobuf_test.c | 6 +++--- tests/z_msgcodec_test.c | 27 ++++++++++++++------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/z_iobuf_test.c b/tests/z_iobuf_test.c index 1a49129dc..88fe777b7 100644 --- a/tests/z_iobuf_test.c +++ b/tests/z_iobuf_test.c @@ -265,7 +265,7 @@ void zbuf_compact(void) { assert(_z_zbuf_len(&zbf) == len01); printf(" Len: %zu, Rpos: %zu, Wpos: %zu\n", len01, _z_zbuf_get_rpos(&zbf), _z_zbuf_get_wpos(&zbf)); - uint8_t vs = 1 + gen_uint8() % (len - counter); + uint8_t vs = (uint8_t)(1 + gen_uint8() % (len - counter)); printf(" Read %u bytes => [", vs); for (uint8_t i = 0; i < vs; i++) { uint8_t l = counter++; @@ -291,7 +291,7 @@ void zbuf_view(void) { uint8_t counter = 0; while (counter < len) { - uint8_t vs = 1 + gen_uint8() % (len - counter); + uint8_t vs = (uint8_t)(1 + gen_uint8() % (len - counter)); _z_zbuf_t rv = _z_zbuf_view(&zbf, vs); printf(" View of %u bytes: ", vs); @@ -448,7 +448,7 @@ void wbuf_reusable_write_zbuf_read(void) { printf(" Writing %zu bytes\n", len); for (size_t z = 0; z < len; z++) { size_t prev_len = _z_wbuf_len(&wbf); - assert(_z_wbuf_write(&wbf, z % (uint8_t)255) == 0); + assert(_z_wbuf_write(&wbf, (uint8_t)(z % 255)) == 0); assert(_z_wbuf_len(&wbf) == prev_len + 1); } diff --git a/tests/z_msgcodec_test.c b/tests/z_msgcodec_test.c index 1bc1bdc3a..4e4511baa 100644 --- a/tests/z_msgcodec_test.c +++ b/tests/z_msgcodec_test.c @@ -137,7 +137,7 @@ _Bool gen_bool(void) { return zp_random_u8() % 2; } uint8_t gen_uint8(void) { return zp_random_u8(); } -uint8_t gen_uint16(void) { return zp_random_u16(); } +uint16_t gen_uint16(void) { return zp_random_u16(); } uint64_t gen_uint64(void) { uint64_t ret = 0; @@ -496,7 +496,8 @@ void payload_field(void) { } _z_source_info_t gen_source_info(void) { - return (_z_source_info_t){._id = gen_zid(), ._source_sn = gen_uint64(), ._entity_id = gen_uint64()}; + return (_z_source_info_t){ + ._id = gen_zid(), ._source_sn = (uint32_t)gen_uint64(), ._entity_id = (uint32_t)gen_uint64()}; } void assert_eq_source_info(const _z_source_info_t *left, const _z_source_info_t *right) { @@ -607,7 +608,7 @@ void assert_eq_subinfo(_z_subinfo_t *left, _z_subinfo_t *right) { /*------------------ ResKey field ------------------*/ _z_keyexpr_t gen_keyexpr(void) { _z_keyexpr_t key; - key._id = gen_zint(); + key._id = gen_uint16(); key._mapping._val = gen_uint8(); _Bool is_numerical = gen_bool(); if (is_numerical == true) { @@ -671,7 +672,7 @@ void keyexpr_field(void) { /*=============================*/ /*------------------ Resource declaration ------------------*/ _z_decl_kexpr_t gen_resource_declaration(void) { - return (_z_decl_kexpr_t){._id = gen_zint(), ._keyexpr = gen_keyexpr()}; + return (_z_decl_kexpr_t){._id = gen_uint16(), ._keyexpr = gen_keyexpr()}; } void assert_eq_resource_declaration(const _z_decl_kexpr_t *left, const _z_decl_kexpr_t *right) { @@ -715,7 +716,7 @@ void resource_declaration(void) { _z_decl_subscriber_t gen_subscriber_declaration(void) { _z_subinfo_t subinfo = gen_subinfo(); _z_decl_subscriber_t e_sd = {._keyexpr = gen_keyexpr(), - ._id = gen_uint64(), + ._id = (uint32_t)gen_uint64(), ._ext_subinfo = {._pull_mode = subinfo.mode == Z_SUBMODE_PULL, ._reliable = subinfo.reliability == Z_RELIABILITY_RELIABLE}}; return e_sd; @@ -761,8 +762,8 @@ void subscriber_declaration(void) { /*------------------ Queryable declaration ------------------*/ _z_decl_queryable_t gen_queryable_declaration(void) { _z_decl_queryable_t e_qd = {._keyexpr = gen_keyexpr(), - ._id = gen_uint64(), - ._ext_queryable_info = {._complete = gen_zint(), ._distance = gen_zint()}}; + ._id = (uint32_t)gen_uint64(), + ._ext_queryable_info = {._complete = gen_uint8(), ._distance = (uint32_t)gen_zint()}}; return e_qd; } @@ -811,7 +812,7 @@ void queryable_declaration(void) { _z_undecl_kexpr_t gen_forget_resource_declaration(void) { _z_undecl_kexpr_t e_frd; - e_frd._id = gen_zint(); + e_frd._id = gen_uint16(); return e_frd; } @@ -853,7 +854,7 @@ void forget_resource_declaration(void) { /*------------------ Forget Subscriber declaration ------------------*/ _z_undecl_subscriber_t gen_forget_subscriber_declaration(void) { - _z_undecl_subscriber_t e_fsd = {._ext_keyexpr = gen_keyexpr(), ._id = gen_uint64()}; + _z_undecl_subscriber_t e_fsd = {._ext_keyexpr = gen_keyexpr(), ._id = (uint32_t)gen_uint64()}; return e_fsd; } @@ -895,7 +896,7 @@ void forget_subscriber_declaration(void) { /*------------------ Forget Queryable declaration ------------------*/ _z_undecl_queryable_t gen_forget_queryable_declaration(void) { - _z_undecl_queryable_t e_fqd = {._ext_keyexpr = gen_keyexpr(), ._id = gen_zint()}; + _z_undecl_queryable_t e_fqd = {._ext_keyexpr = gen_keyexpr(), ._id = (uint32_t)gen_zint()}; return e_fqd; } @@ -1293,8 +1294,8 @@ _z_n_msg_request_t gen_request(void) { ._ext_qos = gen_bool() ? _z_n_qos_make(gen_bool(), gen_bool(), gen_uint8() % 8) : _Z_N_QOS_DEFAULT, ._ext_timestamp = gen_bool() ? gen_timestamp() : _z_timestamp_null(), ._ext_target = gen_uint8() % 3, - ._ext_budget = gen_bool() ? gen_uint64() : 0, - ._ext_timeout_ms = gen_bool() ? gen_uint64() : 0, + ._ext_budget = gen_bool() ? (uint32_t)gen_uint64() : 0, + ._ext_timeout_ms = gen_bool() ? (uint32_t)gen_uint64() : 0, }; switch (gen_uint8() % 4) { case 0: { @@ -1574,7 +1575,7 @@ void open_message(void) { _z_wbuf_clear(&wbf); } -_z_transport_message_t gen_close(void) { return _z_t_msg_make_close(gen_uint(), gen_bool()); } +_z_transport_message_t gen_close(void) { return _z_t_msg_make_close(gen_uint8(), gen_bool()); } void assert_eq_close(const _z_t_msg_close_t *left, const _z_t_msg_close_t *right) { assert(left->_reason == right->_reason); } From 994212e62f6873b7a0f8461a3bf8b9c2efe00afc Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Fri, 19 Jan 2024 10:31:13 +0100 Subject: [PATCH 8/9] fix: run Wconversion on c99 examples --- examples/unix/c99/z_ping.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index 9269b27b5..3bcafece7 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -96,7 +96,7 @@ int main(int argc, char** argv) { uint8_t* data = zp_malloc(args.size); for (unsigned int i = 0; i < args.size; i++) { - data[i] = i % 10; + data[i] = (uint8_t)(i % 10); } zp_mutex_lock(&mutex); if (args.warmup_ms) { @@ -154,17 +154,17 @@ struct args_t parse_args(int argc, char** argv) { char* arg = getopt(argc, argv, 's'); unsigned int size = DEFAULT_PKT_SIZE; if (arg) { - size = atoi(arg); + size = (unsigned int)atoi(arg); } arg = getopt(argc, argv, 'n'); unsigned int number_of_pings = DEFAULT_PING_NB; if (arg) { - number_of_pings = atoi(arg); + number_of_pings = (unsigned int)atoi(arg); } arg = getopt(argc, argv, 'w'); unsigned int warmup_ms = DEFAULT_WARMUP_MS; if (arg) { - warmup_ms = atoi(arg); + warmup_ms = (unsigned int)atoi(arg); } return (struct args_t){ .help_requested = 0, From de6a7c6fc87bf16ba2cafb82d464ab853e9caa5d Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Fri, 19 Jan 2024 10:33:50 +0100 Subject: [PATCH 9/9] build: add commented debug options --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69ac6dc24..2c32d9bb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,8 @@ endif() if(CMAKE_BUILD_TYPE MATCHES "DEBUG") if(UNIX) add_compile_options(-c -Wall -Wextra -Werror -Wshadow -Wpedantic -Wunused -Wstrict-prototypes -pipe -g -O0) + # add_compile_options(-Wconversion) + # add_link_options(-fsanitize=address) elseif(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11 /experimental:c11atomics") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /experimental:c11atomics")