diff --git a/.clang-tidy b/.clang-tidy index b663ac471a..6ca7b5de33 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -22,6 +22,7 @@ hicpp-*, -bugprone-easily-swappable-parameters, -bugprone-branch-clone, -bugprone-implicit-widening-of-multiplication-result, +-bugprone-not-null-terminated-result, -concurrency-mt-unsafe, -readability-named-parameter, -readability-avoid-const-params-in-decls, @@ -86,7 +87,7 @@ hicpp-*, # -readability-function-cognitive-complexity # ## is it working correctly? produces hard to understand warning -# -clang-analyzer-core.uninitialized.UndefReturn +# -clang-analyzer-core.uninitialized.UndefReturn # -clang-analyzer-optin.cplusplus.VirtualCall # ########################################### diff --git a/iceoryx_binding_c/include/iceoryx_binding_c/config.h b/iceoryx_binding_c/include/iceoryx_binding_c/config.h index 9f99758ebf..ef23068cf0 100644 --- a/iceoryx_binding_c/include/iceoryx_binding_c/config.h +++ b/iceoryx_binding_c/include/iceoryx_binding_c/config.h @@ -97,7 +97,7 @@ uint32_t iox_cfg_max_runtime_name_length(); /// @brief the maximum size of a node name string + \0 terminator #define IOX_CONFIG_NODE_NAME_SIZE 101 -/// @brief the maximum size of a service description string identifier -#define IOX_CONFIG_SERVICE_STRING_SIZE 100 +/// @brief the maximum size of a service description string identifier + \0 terminator +#define IOX_CONFIG_SERVICE_STRING_SIZE 101 #endif // IOX_BINDING_C_CONFIG_H diff --git a/iceoryx_binding_c/include/iceoryx_binding_c/service_description.h b/iceoryx_binding_c/include/iceoryx_binding_c/service_description.h index acbcaa8065..f9b2619339 100644 --- a/iceoryx_binding_c/include/iceoryx_binding_c/service_description.h +++ b/iceoryx_binding_c/include/iceoryx_binding_c/service_description.h @@ -1,4 +1,4 @@ -// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ typedef struct { - char serviceString[IOX_CONFIG_SERVICE_STRING_SIZE + 1U]; // +1U for \0 terminator - char instanceString[IOX_CONFIG_SERVICE_STRING_SIZE + 1U]; - char eventString[IOX_CONFIG_SERVICE_STRING_SIZE + 1U]; + char serviceString[IOX_CONFIG_SERVICE_STRING_SIZE]; + char instanceString[IOX_CONFIG_SERVICE_STRING_SIZE]; + char eventString[IOX_CONFIG_SERVICE_STRING_SIZE]; } iox_service_description_t; #endif diff --git a/iceoryx_binding_c/test/moduletests/test_config.cpp b/iceoryx_binding_c/test/moduletests/test_config.cpp index bb3abbad80..4744baaef1 100644 --- a/iceoryx_binding_c/test/moduletests/test_config.cpp +++ b/iceoryx_binding_c/test/moduletests/test_config.cpp @@ -59,6 +59,6 @@ TEST(iox_cfg, valuesAreCorrectlyConnected) constexpr uint64_t ZERO_TERMINATOR_SIZE = 1U; EXPECT_EQ(IOX_CONFIG_NODE_NAME_SIZE, iox::NodeName_t::capacity() + ZERO_TERMINATOR_SIZE); - EXPECT_EQ(IOX_CONFIG_SERVICE_STRING_SIZE, iox::capro::IdString_t::capacity()); + EXPECT_EQ(IOX_CONFIG_SERVICE_STRING_SIZE, iox::capro::IdString_t::capacity() + ZERO_TERMINATOR_SIZE); } } // namespace diff --git a/iceoryx_binding_c/test/moduletests/test_service_description.cpp b/iceoryx_binding_c/test/moduletests/test_service_description.cpp index 8ca0656958..26b12c06c1 100644 --- a/iceoryx_binding_c/test/moduletests/test_service_description.cpp +++ b/iceoryx_binding_c/test/moduletests/test_service_description.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Apex.AI Inc. All rights reserved. +// Copyright (c) 2021 - 2022 Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_examples/icediscovery_in_c/README.md b/iceoryx_examples/icediscovery_in_c/README.md index 678c60f2f9..c73501d31f 100644 --- a/iceoryx_examples/icediscovery_in_c/README.md +++ b/iceoryx_examples/icediscovery_in_c/README.md @@ -28,7 +28,7 @@ To be able to search for services, we need to include: #include "iceoryx_binding_c/service_discovery.h" ``` -We create some stack storage for the service discovery and initialize it. +We create some storage for the service discovery and initialize it. ```c diff --git a/iceoryx_examples/icediscovery_in_c/iox_c_find_service.c b/iceoryx_examples/icediscovery_in_c/iox_c_find_service.c index 4234776a62..d58b7d7103 100644 --- a/iceoryx_examples/icediscovery_in_c/iox_c_find_service.c +++ b/iceoryx_examples/icediscovery_in_c/iox_c_find_service.c @@ -50,8 +50,8 @@ void printSearchResult(const iox_service_description_t service) //! [search function for all front devices] void searchFrontDevices(const iox_service_description_t service, void* count) { - if (strncmp("FrontLeft", service.instanceString, IOX_CONFIG_SERVICE_STRING_SIZE) == 0 - || strncmp("FrontRight", service.instanceString, IOX_CONFIG_SERVICE_STRING_SIZE) == 0) + if (strncmp(service.instanceString, "FrontLeft", IOX_CONFIG_SERVICE_STRING_SIZE) == 0 + || strncmp(service.instanceString, "FrontRight", IOX_CONFIG_SERVICE_STRING_SIZE) == 0) { ++*(uint32_t*)count; } @@ -74,7 +74,7 @@ int main() uint64_t missedServices = 0U; uint64_t numberFoundServices = 0U; - const uint32_t WAIT_TIME_IN_MS = 1000; + const uint32_t WAIT_TIME_IN_MS = 1000U; while (keepRunning) { diff --git a/iceoryx_examples/icediscovery_in_c/iox_c_offer_service.c b/iceoryx_examples/icediscovery_in_c/iox_c_offer_service.c index bf3471ed91..dfb79feedb 100644 --- a/iceoryx_examples/icediscovery_in_c/iox_c_offer_service.c +++ b/iceoryx_examples/icediscovery_in_c/iox_c_offer_service.c @@ -57,7 +57,7 @@ int main() cameraPublishers[3] = iox_pub_init(&cameraPublisherStorage[3], "Camera", "FrontRight", "Image", &options); cameraPublishers[4] = iox_pub_init(&cameraPublisherStorage[4], "Camera", "BackLeft", "Image", &options); - const uint32_t WAIT_TIME_IN_MS = 1000; + const uint32_t WAIT_TIME_IN_MS = 1000U; bool offer = false; while (keepRunning) {