diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/posix_call.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/posix_call.inl index 04d4c10c757..dc84c828204 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/posix_call.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/posix_call.inl @@ -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. @@ -73,9 +73,8 @@ inline cxx::string errorLiteralToString(const char template inline cxx::string PosixCallResult::getHumanReadableErrnum() const noexcept { - /// NOLINTJUSTIFICATION @todo iox-#1614 replace with upcoming uninitialized array - /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) - char buffer[POSIX_CALL_ERROR_STRING_SIZE]; + containers::UnitializedArray buffer; + buffer[0] = '\0'; return internal::errorLiteralToString(strerror_r(errnum, &buffer[0], POSIX_CALL_ERROR_STRING_SIZE), &buffer[0]); } diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/posix_call.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/posix_call.hpp index ec8e28b33fb..a48aad5ff3f 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/posix_call.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/posix_call.hpp @@ -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. @@ -16,6 +16,7 @@ #ifndef IOX_HOOFS_POSIX_WRAPPER_POSIX_CALL_HPP #define IOX_HOOFS_POSIX_WRAPPER_POSIX_CALL_HPP +#include "iceoryx_hoofs/containers/uninitialized_array.hpp" #include "iceoryx_hoofs/cxx/algorithm.hpp" #include "iceoryx_hoofs/cxx/attributes.hpp" #include "iceoryx_hoofs/cxx/expected.hpp" diff --git a/iceoryx_hoofs/source/posix_wrapper/posix_access_rights.cpp b/iceoryx_hoofs/source/posix_wrapper/posix_access_rights.cpp index 75f1557864c..9135c97f257 100644 --- a/iceoryx_hoofs/source/posix_wrapper/posix_access_rights.cpp +++ b/iceoryx_hoofs/source/posix_wrapper/posix_access_rights.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. -// 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. @@ -16,7 +16,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_hoofs/posix_wrapper/posix_access_rights.hpp" - +#include "iceoryx_hoofs/containers/uninitialized_array.hpp" #include "iceoryx_hoofs/posix_wrapper/posix_call.hpp" #include "iceoryx_platform/grp.hpp" #include "iceoryx_platform/platform_correction.hpp" @@ -147,10 +147,7 @@ PosixUser::groupVector_t PosixUser::getGroups() const noexcept } gid_t userDefaultGroup = getpwnamCall->value->pw_gid; - - /// NOLINTJUSTIFICATION @todo iox-#1614 use upcoming cxx::array - /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) - gid_t groups[MaxNumberOfGroups]; + containers::UnitializedArray groups; int32_t numGroups = MaxNumberOfGroups; auto getgrouplistCall = posixCall(iox_getgrouplist)(userName->c_str(), userDefaultGroup, &groups[0], &numGroups) @@ -171,9 +168,7 @@ PosixUser::groupVector_t PosixUser::getGroups() const noexcept groupVector_t vec; for (int32_t i = 0; i < numGroups; ++i) { - /// NOLINTJUSTIFICATION @todo iox-#1614 will be fixed when upcoming cxx::array is used - /// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) - vec.emplace_back(PosixGroup(groups[i])); + vec.emplace_back(PosixGroup(groups[static_cast(i)])); } return vec; diff --git a/iceoryx_hoofs/source/posix_wrapper/thread.cpp b/iceoryx_hoofs/source/posix_wrapper/thread.cpp index 167832b133b..42d3d8b5180 100644 --- a/iceoryx_hoofs/source/posix_wrapper/thread.cpp +++ b/iceoryx_hoofs/source/posix_wrapper/thread.cpp @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_hoofs/posix_wrapper/thread.hpp" +#include "iceoryx_hoofs/containers/uninitialized_array.hpp" #include "iceoryx_hoofs/cxx/helplets.hpp" #include "iceoryx_hoofs/log/logging.hpp" #include "iceoryx_hoofs/posix_wrapper/posix_call.hpp" @@ -35,9 +36,7 @@ void setThreadName(iox_pthread_t thread, const ThreadName_t& name) noexcept ThreadName_t getThreadName(iox_pthread_t thread) noexcept { - // NOLINTJUSTIFICATION required as name buffer for iox_pthread_getname_np - // NOLINTNEXTLINE(hicpp-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) - char tempName[MAX_THREAD_NAME_LENGTH + 1U]; + containers::UnitializedArray tempName; posixCall(iox_pthread_getname_np)(thread, &tempName[0], MAX_THREAD_NAME_LENGTH + 1U) .successReturnValue(0) diff --git a/iceoryx_hoofs/source/posix_wrapper/unix_domain_socket.cpp b/iceoryx_hoofs/source/posix_wrapper/unix_domain_socket.cpp index 58aea6a0a97..f5caf6ab19f 100644 --- a/iceoryx_hoofs/source/posix_wrapper/unix_domain_socket.cpp +++ b/iceoryx_hoofs/source/posix_wrapper/unix_domain_socket.cpp @@ -279,9 +279,7 @@ UnixDomainSocket::timedReceive(const units::Duration& timeout) const noexcept { return cxx::error(convertErrnoToIpcChannelError(setsockoptCall.get_error().errnum)); } - // NOLINTJUSTIFICATION needed for recvfrom - // NOLINTNEXTLINE(hicpp-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) - char message[MAX_MESSAGE_SIZE + 1]; + containers::UnitializedArray message; auto recvCall = posixCall(iox_recvfrom)(m_sockfd, &message[0], MAX_MESSAGE_SIZE, 0, nullptr, nullptr) .failureReturnValue(ERROR_CODE) @@ -293,7 +291,7 @@ UnixDomainSocket::timedReceive(const units::Duration& timeout) const noexcept { return cxx::error(convertErrnoToIpcChannelError(recvCall.get_error().errnum)); } - return cxx::success(message); + return cxx::success(&message[0]); } cxx::expected UnixDomainSocket::initalizeSocket() noexcept