Skip to content

Commit

Permalink
Merge pull request #2181 from elBoberido/iox-1032-replace-iox-expects…
Browse files Browse the repository at this point in the history
…-with-iox-enforce

iox-#1032 replace 'IOX_EXPECTS'/'IOX_ENSURES' with 'IOX_ENFORCE'
  • Loading branch information
elBoberido authored Feb 6, 2024
2 parents 80bbdf9 + 5866693 commit 32bf3fa
Show file tree
Hide file tree
Showing 111 changed files with 1,108 additions and 1,236 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install iceoryx dependencies and clang-tidy
uses: ./.github/actions/install-iceoryx-deps-and-clang
- run: ./tools/scripts/clang_format.sh check
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-20.04
needs: pre-flight-check
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: egor-tensin/[email protected]
with:
# gcc 8.3 is compiler used in QNX 7.1
Expand All @@ -71,7 +71,7 @@ jobs:
runs-on: windows-latest
needs: pre-flight-check
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: ./tools/ci/build-test-windows.ps1 -toolchain MSVC
shell: powershell

Expand All @@ -81,7 +81,7 @@ jobs:
runs-on: windows-latest
needs: pre-flight-check
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: egor-tensin/setup-mingw@v2
with:
version: 10.3
Expand All @@ -99,7 +99,7 @@ jobs:
uses: ros-tooling/[email protected]
with:
required-ros-distributions: humble
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: ./tools/ci/run-integration-test.sh

build-test-ubuntu-with-address-sanitizer-gcc-latest:
Expand All @@ -112,7 +112,7 @@ jobs:
with:
version: 13
platform: x64
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run Address Sanitizer
run: ./tools/ci/build-test-ubuntu-with-sanitizers.sh gcc asan

Expand All @@ -123,7 +123,7 @@ jobs:
needs: pre-flight-check
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install iceoryx dependencies and clang-tidy
uses: ./.github/actions/install-iceoryx-deps-and-clang
- name: Run Address Sanitizer
Expand All @@ -135,7 +135,7 @@ jobs:
runs-on: macos-latest
needs: pre-flight-check
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run Address Sanitizer
run: ./tools/ci/build-test-macos-with-sanitizers.sh asan

Expand All @@ -146,7 +146,7 @@ jobs:
needs: pre-flight-check
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install iceoryx dependencies and clang-tidy
uses: ./.github/actions/install-iceoryx-deps-and-clang
- name: Run Thread Sanitizer
Expand All @@ -160,7 +160,7 @@ jobs:
needs: pre-flight-check
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install iceoryx dependencies and clang-tidy
uses: ./.github/actions/install-iceoryx-deps-and-clang
- run: ./tools/ci/build-test-ubuntu-bazel.sh
Expand All @@ -171,7 +171,7 @@ jobs:
runs-on: ubuntu-latest
needs: pre-flight-check
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: ./tools/ci/coverage-and-docs.sh

- name: Archive generated doxygen
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Checkout branch
uses: actions/checkout@v3
uses: actions/checkout@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -28,7 +28,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -38,7 +38,7 @@ jobs:
verify-links-in-markdown-documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Calculate lychee cache key
run: echo "LYCHEE_CACHE_KEY=cache-lychee-all-branches-$(date +'%G-%V')" >> "$GITHUB_ENV" # %G = year; %V = week number
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
# prevent stuck jobs consuming macos runners for 6 hours
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: ./tools/ci/build-test-macos.sh

clang-tidy-full-scan:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install iceoryx dependencies and clang-tidy
uses: ./.github/actions/install-iceoryx-deps-and-clang
- name: clang-tidy full scan of all entries in .clang-tidy-diff-scans.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
sudo apt-get install -y plantuml texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-fonts-recommended
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ReleaseTag }}
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

// additional includes
#include "iox/error_reporting/types.hpp"
#include "iox/log/logstream.hpp"

namespace iox
{
Expand Down Expand Up @@ -62,6 +63,12 @@ enum class CBindingError : iox::er::ErrorCode::type

const char* asStringLiteral(const CBindingError error) noexcept;

inline log::LogStream& operator<<(log::LogStream& stream, CBindingError value) noexcept
{
stream << asStringLiteral(value);
return stream;
}

class CBindingErrorType
{
public:
Expand Down
14 changes: 7 additions & 7 deletions iceoryx_binding_c/source/c_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_posh/mepoo/chunk_header.hpp"

#include "iox/assertions.hpp"

extern "C" {
#include "iceoryx_binding_c/chunk.h"
Expand All @@ -25,36 +25,36 @@ using namespace iox::mepoo;

void* iox_chunk_header_to_user_payload(iox_chunk_header_t* const chunkHeader)
{
IOX_EXPECTS(chunkHeader != nullptr);
IOX_ENFORCE(chunkHeader != nullptr, "'chunkHeader' must not be a 'nullptr'");
return reinterpret_cast<ChunkHeader*>(chunkHeader)->userPayload();
}

const void* iox_chunk_header_to_user_payload_const(const iox_chunk_header_t* const chunkHeader)
{
IOX_EXPECTS(chunkHeader != nullptr);
IOX_ENFORCE(chunkHeader != nullptr, "'chunkHeader' must not be a 'nullptr'");
return reinterpret_cast<const ChunkHeader*>(chunkHeader)->userPayload();
}

void* iox_chunk_header_to_user_header(iox_chunk_header_t* const chunkHeader)
{
IOX_EXPECTS(chunkHeader != nullptr);
IOX_ENFORCE(chunkHeader != nullptr, "'chunkHeader' must not be a 'nullptr'");
return reinterpret_cast<ChunkHeader*>(chunkHeader)->userHeader();
}

const void* iox_chunk_header_to_user_header_const(const iox_chunk_header_t* const chunkHeader)
{
IOX_EXPECTS(chunkHeader != nullptr);
IOX_ENFORCE(chunkHeader != nullptr, "'chunkHeader' must not be a 'nullptr'");
return reinterpret_cast<const ChunkHeader*>(chunkHeader)->userHeader();
}

iox_chunk_header_t* iox_chunk_header_from_user_payload(void* const userPayload)
{
IOX_EXPECTS(userPayload != nullptr);
IOX_ENFORCE(userPayload != nullptr, "'userPayload' must not be a 'nullptr'");
return reinterpret_cast<iox_chunk_header_t*>(ChunkHeader::fromUserPayload(userPayload));
}

const iox_chunk_header_t* iox_chunk_header_from_user_payload_const(const void* const userPayload)
{
IOX_EXPECTS(userPayload != nullptr);
IOX_ENFORCE(userPayload != nullptr, "'userPayload' must not be a 'nullptr'");
return reinterpret_cast<const iox_chunk_header_t*>(ChunkHeader::fromUserPayload(userPayload));
}
47 changes: 24 additions & 23 deletions iceoryx_binding_c/source/c_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ constexpr uint64_t CLIENT_OPTIONS_INIT_CHECK_CONSTANT = 47113130815;

void iox_client_options_init(iox_client_options_t* options)
{
IOX_EXPECTS(options != nullptr);
IOX_ENFORCE(options != nullptr, "'options' must not be a 'nullptr'");

ClientOptions clientOptions;
options->responseQueueCapacity = clientOptions.responseQueueCapacity;
Expand All @@ -49,7 +49,7 @@ void iox_client_options_init(iox_client_options_t* options)

bool iox_client_options_is_initialized(const iox_client_options_t* const options)
{
IOX_EXPECTS(options != nullptr);
IOX_ENFORCE(options != nullptr, "'options' must not be a 'nullptr'");

return options->initCheck == CLIENT_OPTIONS_INIT_CHECK_CONSTANT;
}
Expand All @@ -60,11 +60,12 @@ iox_client_t iox_client_init(iox_client_storage_t* self,
const char* const event,
const iox_client_options_t* const options)
{
IOX_EXPECTS(self != nullptr);
IOX_EXPECTS(service != nullptr);
IOX_EXPECTS(instance != nullptr);
IOX_EXPECTS(event != nullptr);
IOX_EXPECTS(options == nullptr || (options != nullptr && iox_client_options_is_initialized(options)));
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
IOX_ENFORCE(service != nullptr, "'service' must not be a 'nullptr'");
IOX_ENFORCE(instance != nullptr, "'instance' must not be a 'nullptr'");
IOX_ENFORCE(event != nullptr, "'event' must not be a 'nullptr'");
IOX_ENFORCE(options == nullptr || (options != nullptr && iox_client_options_is_initialized(options)),
"'options' must be either a 'nullptr' or the data behind the pointer must be initialized");

ClientOptions clientOptions;
if (options != nullptr)
Expand All @@ -87,7 +88,7 @@ iox_client_t iox_client_init(iox_client_storage_t* self,

void iox_client_deinit(iox_client_t const self)
{
IOX_EXPECTS(self != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");

delete self;
}
Expand All @@ -102,8 +103,8 @@ iox_AllocationResult iox_client_loan_aligned_request(iox_client_t const self,
const uint64_t payloadSize,
const uint32_t payloadAlignment)
{
IOX_EXPECTS(self != nullptr);
IOX_EXPECTS(payload != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'");

auto result = self->loan(payloadSize, payloadAlignment);
if (result.has_error())
Expand All @@ -117,15 +118,15 @@ iox_AllocationResult iox_client_loan_aligned_request(iox_client_t const self,

void iox_client_release_request(iox_client_t const self, void* const payload)
{
IOX_EXPECTS(self != nullptr);
IOX_EXPECTS(payload != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'");

self->releaseRequest(payload);
}

iox_ClientSendResult iox_client_send(iox_client_t const self, void* const payload)
{
IOX_EXPECTS(self != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");

auto result = self->send(payload);
if (result.has_error())
Expand All @@ -138,26 +139,26 @@ iox_ClientSendResult iox_client_send(iox_client_t const self, void* const payloa

void iox_client_connect(iox_client_t const self)
{
IOX_EXPECTS(self != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
self->connect();
}

void iox_client_disconnect(iox_client_t const self)
{
IOX_EXPECTS(self != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
self->disconnect();
}

iox_ConnectionState iox_client_get_connection_state(iox_client_t const self)
{
IOX_EXPECTS(self != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
return cpp2c::connectionState(self->getConnectionState());
}

iox_ChunkReceiveResult iox_client_take_response(iox_client_t const self, const void** const payload)
{
IOX_EXPECTS(self != nullptr);
IOX_EXPECTS(payload != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'");

auto result = self->take();
if (result.has_error())
Expand All @@ -171,27 +172,27 @@ iox_ChunkReceiveResult iox_client_take_response(iox_client_t const self, const v

void iox_client_release_response(iox_client_t const self, const void* const payload)
{
IOX_EXPECTS(self != nullptr);
IOX_EXPECTS(payload != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
IOX_ENFORCE(payload != nullptr, "'payload' must not be a 'nullptr'");

self->releaseResponse(payload);
}

void iox_client_release_queued_responses(iox_client_t const self)
{
IOX_EXPECTS(self != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
self->releaseQueuedResponses();
}

bool iox_client_has_responses(iox_client_t const self)
{
IOX_EXPECTS(self != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
return self->hasResponses();
}

bool iox_client_has_missed_responses(iox_client_t const self)
{
IOX_EXPECTS(self != nullptr);
IOX_ENFORCE(self != nullptr, "'self' must not be a 'nullptr'");
return self->hasMissedResponses();
}

Expand Down
Loading

0 comments on commit 32bf3fa

Please sign in to comment.