From 0a14c4eeca1c4a18e0ccd745904a82025f32c0a5 Mon Sep 17 00:00:00 2001 From: Eran Date: Thu, 12 Sep 2024 13:33:40 +0300 Subject: [PATCH 1/4] fix rs-dds-config not enabling DDS by default --- tools/dds/dds-config/rs-dds-config.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/dds/dds-config/rs-dds-config.cpp b/tools/dds/dds-config/rs-dds-config.cpp index 1420310a31..ea5fdd32bd 100644 --- a/tools/dds/dds-config/rs-dds-config.cpp +++ b/tools/dds/dds-config/rs-dds-config.cpp @@ -208,6 +208,7 @@ try bool const golden = golden_arg.isSet(); // Create a RealSense context and look for a device + settings["dds"]["enabled"] = true; rs2::context ctx( settings.dump() ); rs2::device device; From b9cc8aeb11214bab33cb445ba5cee918ee9b5dc9 Mon Sep 17 00:00:00 2001 From: Eran Date: Thu, 12 Sep 2024 13:34:06 +0300 Subject: [PATCH 2/4] fix High Coverity issues --- examples/C/color/rs-color.c | 30 +++++-------------- examples/C/depth/rs-depth.c | 21 ++----------- examples/C/distance/rs-distance.c | 18 ++--------- src/global_timestamp_reader.cpp | 16 +++++++--- .../rsutils/src/network-adapter-watcher.cpp | 3 +- 5 files changed, 26 insertions(+), 62 deletions(-) diff --git a/examples/C/color/rs-color.c b/examples/C/color/rs-color.c index 4ed963a938..4b696b5a49 100644 --- a/examples/C/color/rs-color.c +++ b/examples/C/color/rs-color.c @@ -1,5 +1,5 @@ // License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2017 Intel Corporation. All Rights Reserved. +// Copyright(c) 2017-24 Intel Corporation. All Rights Reserved. /* Include the librealsense C header files */ #include @@ -15,12 +15,12 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // These parameters are reconfigurable // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define STREAM RS2_STREAM_COLOR // rs2_stream is a types of data provided by RealSense device // -#define FORMAT RS2_FORMAT_RGB8 // rs2_format identifies how binary data is encoded within a frame // -#define WIDTH 640 // Defines the number of columns for each frame // -#define HEIGHT 480 // Defines the number of lines for each frame // -#define FPS 30 // Defines the rate of frames per second // -#define STREAM_INDEX 0 // Defines the stream index, used for multiple streams of the same type // +#define STREAM RS2_STREAM_COLOR // Type of data provided by RealSense device // +#define FORMAT RS2_FORMAT_ANY // How binary data is encoded within a frame (ANY) // +#define WIDTH 0 // Number of columns for each frame (ANY) // +#define HEIGHT 0 // Number of lines for each frame (ANY) // +#define FPS 0 // Rate of frames per second (ANY) // +#define STREAM_INDEX -1 // Used for multiple streams of the same type (ANY) // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -74,7 +74,7 @@ int main() exit(EXIT_FAILURE); } - while (1) + while (1) // Until user presses Ctrl+C { // This call waits until a new composite_frame is available // composite_frame holds a set of frames. It is used to prevent frame drops @@ -125,18 +125,4 @@ int main() rs2_release_frame(frames); } - - // Stop the pipeline streaming - rs2_pipeline_stop(pipeline, &e); - check_error(e); - - // Release resources - rs2_delete_pipeline_profile(pipeline_profile); - rs2_delete_config(config); - rs2_delete_pipeline(pipeline); - rs2_delete_device(dev); - rs2_delete_device_list(device_list); - rs2_delete_context(ctx); - - return EXIT_SUCCESS; } diff --git a/examples/C/depth/rs-depth.c b/examples/C/depth/rs-depth.c index f21e4ebac5..d191e12d2e 100644 --- a/examples/C/depth/rs-depth.c +++ b/examples/C/depth/rs-depth.c @@ -1,5 +1,5 @@ // License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2017 Intel Corporation. All Rights Reserved. +// Copyright(c) 2017-24 Intel Corporation. All Rights Reserved. /* Include the librealsense C header files */ #include @@ -159,7 +159,7 @@ int main() char* buffer = calloc(display_size, sizeof(char)); char* out = NULL; - while (1) + while (1) // Until user presses Ctrl+C { // This call waits until a new composite_frame is available // composite_frame holds a set of frames. It is used to prevent frame drops @@ -227,21 +227,4 @@ int main() rs2_release_frame(frames); } - - // Stop the pipeline streaming - rs2_pipeline_stop(pipeline, &e); - check_error(e); - - // Release resources - free(buffer); - rs2_delete_pipeline_profile(pipeline_profile); - rs2_delete_stream_profiles_list(stream_profile_list); - rs2_delete_stream_profile(stream_profile); - rs2_delete_config(config); - rs2_delete_pipeline(pipeline); - rs2_delete_device(dev); - rs2_delete_device_list(device_list); - rs2_delete_context(ctx); - - return EXIT_SUCCESS; } diff --git a/examples/C/distance/rs-distance.c b/examples/C/distance/rs-distance.c index 8bb0e73c2b..142ddde0d1 100644 --- a/examples/C/distance/rs-distance.c +++ b/examples/C/distance/rs-distance.c @@ -1,5 +1,5 @@ // License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2017 Intel Corporation. All Rights Reserved. +// Copyright(c) 2017-24 Intel Corporation. All Rights Reserved. /* Include the librealsense C header files */ #include @@ -75,7 +75,7 @@ int main() exit(EXIT_FAILURE); } - while (1) + while (1) // Until user presses Ctrl+C { // This call waits until a new composite_frame is available // composite_frame holds a set of frames. It is used to prevent frame drops @@ -117,18 +117,4 @@ int main() rs2_release_frame(frames); } - - // Stop the pipeline streaming - rs2_pipeline_stop(pipeline, &e); - check_error(e); - - // Release resources - rs2_delete_pipeline_profile(pipeline_profile); - rs2_delete_config(config); - rs2_delete_pipeline(pipeline); - rs2_delete_device(dev); - rs2_delete_device_list(device_list); - rs2_delete_context(ctx); - - return EXIT_SUCCESS; } diff --git a/src/global_timestamp_reader.cpp b/src/global_timestamp_reader.cpp index c82073b0e7..2178de4f25 100644 --- a/src/global_timestamp_reader.cpp +++ b/src/global_timestamp_reader.cpp @@ -88,10 +88,18 @@ namespace librealsense sum_xy += (crnt_sample._x * crnt_sample._y); sum_x2 += (crnt_sample._x * crnt_sample._x); } - b = (sum_y*sum_x2 - sum_x * sum_xy) / (n*sum_x2 - sum_x * sum_x); - a = (n*sum_xy - sum_x * sum_y) / (n*sum_x2 - sum_x * sum_x); - - if (_last_request_time - _prev_time < _time_span_ms) + double denom = n * sum_x2 - sum_x * sum_x; + if( denom > std::numeric_limits< double >::epsilon() ) + { + b = (sum_y * sum_x2 - sum_x * sum_xy) / denom; + a = (n * sum_xy - sum_x * sum_y) / denom; + } + else + { + a = _dest_a; + b = _dest_b; + } + if( _last_request_time - _prev_time < _time_span_ms ) { dt = (_last_request_time - _prev_time) / _time_span_ms; } diff --git a/third-party/rsutils/src/network-adapter-watcher.cpp b/third-party/rsutils/src/network-adapter-watcher.cpp index 88825858f0..4e7c3cf261 100644 --- a/third-party/rsutils/src/network-adapter-watcher.cpp +++ b/third-party/rsutils/src/network-adapter-watcher.cpp @@ -196,10 +196,11 @@ class network_adapter_watcher_singleton #else if( _th.joinable() ) { - if( write( _done, &_done, sizeof( &_done ) ) != sizeof( &_done ) ) + if( write( _done, &_done, sizeof( _done ) ) != sizeof( _done ) ) /* to avoid compiler warning about not using return value */; _th.join(); } + close( _socket ); close( _done ); #endif } From 2063010a9222899183bc1e5d233c60f19bc21a3b Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 16 Sep 2024 08:42:38 +0300 Subject: [PATCH 3/4] fix writing to the 'done' event --- third-party/rsutils/src/network-adapter-watcher.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/third-party/rsutils/src/network-adapter-watcher.cpp b/third-party/rsutils/src/network-adapter-watcher.cpp index 4e7c3cf261..942fa1f1f5 100644 --- a/third-party/rsutils/src/network-adapter-watcher.cpp +++ b/third-party/rsutils/src/network-adapter-watcher.cpp @@ -196,9 +196,12 @@ class network_adapter_watcher_singleton #else if( _th.joinable() ) { - if( write( _done, &_done, sizeof( _done ) ) != sizeof( _done ) ) - /* to avoid compiler warning about not using return value */; - _th.join(); + uint64_t incr = 1; // must be 8-byte integer value + auto rv = write( _done, &incr, sizeof( incr ) ); + if( rv != sizeof( incr ) ) + LOG_WARNING( "failed to write to network adapter watcher done event: " << rv ); + else + _th.join(); } close( _socket ); close( _done ); From 8544e59a711fb3bb97d766b52821d807cb2c26fb Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 16 Sep 2024 09:26:01 +0300 Subject: [PATCH 4/4] fix additional coverity in signal.h --- third-party/rsutils/include/rsutils/signal.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/third-party/rsutils/include/rsutils/signal.h b/third-party/rsutils/include/rsutils/signal.h index 7d2bfb717a..bf799c9068 100644 --- a/third-party/rsutils/include/rsutils/signal.h +++ b/third-party/rsutils/include/rsutils/signal.h @@ -112,7 +112,11 @@ class signal } // How many subscriptions are active - size_t size() const { return _impl->subscribers.size(); } + size_t size() const + { + std::lock_guard< std::mutex > locker( _impl->mutex ); + return _impl->subscribers.size(); + } };