Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ build --credential_helper="*.qnx.com=%workspace%/.github/tools/qnx_credential_he
build:bl_stub --//score/json:base_library=nlohmann
build:bl_stub --//score/memory/shared/flags:use_typedshmd=False

build:bl_stub --features=minimal_warnings --features=-strict_warnings --features=warnings_as_errors
build:bl_stub --features=minimal_warnings --features=strict_warnings --features=warnings_as_errors

# Exclude external dependencies from strict warnings to avoid third-party library issues
build:bl_stub --per_file_copt=external/.*@-Wno-error

# Common baselibs flags for test
test:bl_common --build_tests_only
Expand All @@ -46,6 +49,7 @@ build:bl-aarch64-linux --config=bl_stub
build:bl-aarch64-linux --config=bl_toolchain_common
build:bl-aarch64-linux --platforms=@score_bazel_platforms//:aarch64-linux-gcc_12.2.0-posix
build:bl-aarch64-linux --extra_toolchains=@score_gcc_aarch64_toolchain//:aarch64-linux-gcc_12.2.0-posix
build:bl-aarch64-linux --build_tag_filters=-rust,-rustfmt
test:bl-aarch64-linux --config=bl_common


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,11 @@ ResultBlank LocklessFlexibleCircularAllocator<AtomicIndirectorType>::FreeBlock(B
for (uint8_t retries = 0U; retries < kMaxRetries; retries++)
{
auto old_buffer_queue_tail = buffer_queue_tail_.load();
auto new_buffer_queue_tail = old_buffer_queue_tail + static_cast<uint32_t>(current_block.block_length);
auto new_buffer_queue_tail = old_buffer_queue_tail + current_block.block_length;
if (AtomicIndirectorType<decltype(buffer_queue_tail_.load())>::compare_exchange_strong(
buffer_queue_tail_, old_buffer_queue_tail, new_buffer_queue_tail, std::memory_order_seq_cst) == true)
{
std::ignore = available_size_.fetch_add(static_cast<std::uint32_t>(current_block.block_length),
std::ignore = available_size_.fetch_add(current_block.block_length,
std::memory_order_seq_cst);
break;
}
Expand Down Expand Up @@ -621,7 +621,7 @@ score::Result<uint8_t*> LocklessFlexibleCircularAllocator<AtomicIndirectorType>:
for (uint8_t retries = 0U; retries < kMaxRetries; retries++)
{
auto old_buffer_queue_head = buffer_queue_head_.load();
new_buffer_queue_head = static_cast<uint32_t>(aligned_size);
new_buffer_queue_head = aligned_size;

if (AtomicIndirectorType<decltype(buffer_queue_head_.load())>::compare_exchange_strong(
buffer_queue_head_, old_buffer_queue_head, new_buffer_queue_head, std::memory_order_seq_cst) == true)
Expand All @@ -636,7 +636,7 @@ score::Result<uint8_t*> LocklessFlexibleCircularAllocator<AtomicIndirectorType>:
return nullptr;
}
// LCOV_EXCL_STOP
auto block_ptr = GetBufferPositionAt(static_cast<std::uint32_t>(new_buffer_queue_head) - aligned_size);
auto block_ptr = GetBufferPositionAt(new_buffer_queue_head - aligned_size);
// TODO: Ticket-230467
// LCOV_EXCL_START
if ((!block_ptr.has_value()) || (block_ptr.value() == nullptr))
Expand All @@ -655,7 +655,7 @@ score::Result<uint8_t*> LocklessFlexibleCircularAllocator<AtomicIndirectorType>:
// LCOV_EXCL_STOP
auto block_meta_data = block_meta_data_result.value();
block_meta_data->list_entry_offset = list_entry_element_index;
block_meta_data->block_length = static_cast<uint32_t>(aligned_size);
block_meta_data->block_length = aligned_size;
allocated_address = GetBufferPositionAt(static_cast<std::size_t>(new_buffer_queue_head) -
static_cast<std::size_t>(aligned_size) + sizeof(BufferBlock));

Expand Down Expand Up @@ -689,7 +689,7 @@ score::Result<uint8_t*> LocklessFlexibleCircularAllocator<AtomicIndirectorType>:
auto list_entry_new = list_entry_old;
list_entry_new.flags = static_cast<std::uint8_t>(ListEntryFlag::kInUse);
list_entry_new.length = static_cast<std::uint16_t>(aligned_size);
list_entry_new.offset = (static_cast<std::uint32_t>(aligned_size) + new_buffer_queue_head - aligned_size);
list_entry_new.offset = (aligned_size + new_buffer_queue_head - aligned_size);
if (AtomicIndirectorType<ListEntry>::compare_exchange_strong(
list_array_.at(static_cast<size_t>(list_entry_element_index)),
list_entry_old,
Expand Down Expand Up @@ -729,13 +729,13 @@ score::Result<uint8_t*> LocklessFlexibleCircularAllocator<AtomicIndirectorType>:
return MakeUnexpected<uint8_t*>(LocklessFlexibleAllocatorErrorCode::kNotEnoughMemory);
}
// LCOV_EXCL_STOP
auto new_buffer_queue_head = old_buffer_queue_head + static_cast<std::uint32_t>(aligned_size);
auto new_buffer_queue_head = old_buffer_queue_head + aligned_size;
if (AtomicIndirectorType<decltype(buffer_queue_head_.load())>::compare_exchange_strong(
buffer_queue_head_, old_buffer_queue_head, new_buffer_queue_head, std::memory_order_seq_cst) == true)
{
// TODO: Ticket-230467
// LCOV_EXCL_START
if (new_buffer_queue_head < static_cast<unsigned int>(aligned_size))
if (new_buffer_queue_head < aligned_size)
{
return nullptr;
}
Expand Down Expand Up @@ -764,7 +764,7 @@ score::Result<uint8_t*> LocklessFlexibleCircularAllocator<AtomicIndirectorType>:
// LCOV_EXCL_STOP
auto block_meta_data = block_meta_data_result.value();
block_meta_data->list_entry_offset = list_entry_element_index;
block_meta_data->block_length = static_cast<std::uint32_t>(aligned_size);
block_meta_data->block_length = aligned_size;
allocated_address = GetBufferPositionAt(static_cast<std::size_t>(offset) + sizeof(BufferBlock));
// TODO: Ticket-230467
// LCOV_EXCL_START
Expand Down Expand Up @@ -799,7 +799,7 @@ score::Result<uint8_t*> LocklessFlexibleCircularAllocator<AtomicIndirectorType>:
auto list_entry_new = list_entry_old;
list_entry_new.flags = static_cast<std::uint8_t>(ListEntryFlag::kInUse);
list_entry_new.length = static_cast<std::uint16_t>(aligned_size);
list_entry_new.offset = (static_cast<std::uint32_t>(aligned_size) + offset);
list_entry_new.offset = (aligned_size + offset);
if (AtomicIndirectorType<ListEntry>::compare_exchange_strong(
list_array_.at(static_cast<size_t>(list_entry_element_index)),
list_entry_old,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RegisterSharedMemoryObjectResult GenericTraceAPI::RegisterShmObject(const TraceC
{
return gMock->RegisterShmObject(client, shm_object_path);
}
return static_cast<ShmObjectHandle>(0);
return 0;
}

RegisterSharedMemoryObjectResult GenericTraceAPI::RegisterShmObject(const TraceClientId client,
Expand All @@ -47,7 +47,8 @@ RegisterSharedMemoryObjectResult GenericTraceAPI::RegisterShmObject(const TraceC
{
return gMock->RegisterShmObject(client, shm_object_fd);
}
return static_cast<ShmObjectHandle>(0);
//return static_cast<ShmObjectHandle>(0);
return 0;
}

ResultBlank GenericTraceAPI::UnregisterShmObject(const TraceClientId client, const ShmObjectHandle handle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Co
{
auto& element = this->unit_->emplace_back();
element.i = static_cast<char>(i);
element.j = static_cast<std::uint64_t>(i);
element.j = i;
}

// When copy constructing a new NonRelocatableVector
Expand All @@ -269,7 +269,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Co
{
auto& element = new_vector.at(i);
EXPECT_EQ(element.i, static_cast<char>(i));
EXPECT_EQ(element.j, static_cast<std::uint64_t>(i));
EXPECT_EQ(element.j, i);
}
}

Expand Down Expand Up @@ -382,7 +382,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Mo
{
auto& element = this->unit_->emplace_back();
element.i = static_cast<char>(i);
element.j = static_cast<std::uint64_t>(i);
element.j = i;
}

// When copy constructing a new NonRelocatableVector
Expand All @@ -396,7 +396,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Mo
{
auto& element = new_vector.at(i);
EXPECT_EQ(element.i, static_cast<char>(i));
EXPECT_EQ(element.j, static_cast<std::uint64_t>(i));
EXPECT_EQ(element.j, i);
}
}

Expand Down Expand Up @@ -519,7 +519,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Mo
{
auto& element = this->unit_->emplace_back();
element.i = static_cast<char>(i);
element.j = static_cast<std::uint64_t>(i);
element.j = i;
}

// and a second NonRelocatableVector which has been filled with different elements
Expand All @@ -532,7 +532,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Mo
{
auto& element = new_vector.emplace_back();
element.i = static_cast<char>(2 * i);
element.j = static_cast<std::uint64_t>(2 * i);
element.j = 2 * i;
}

// When move assigning the first vector to the second
Expand All @@ -543,7 +543,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Mo
{
auto& element = new_vector.at(i);
EXPECT_EQ(element.i, static_cast<char>(i));
EXPECT_EQ(element.j, static_cast<std::uint64_t>(i));
EXPECT_EQ(element.j, i);
}
}

Expand Down
8 changes: 4 additions & 4 deletions score/containers/non_relocatable_vector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Sw
{
auto& element = this->unit_->emplace_back();
element.i = static_cast<char>(i);
element.j = static_cast<std::uint64_t>(i);
element.j = i;
}

// and a second NonRelocatableVector which has been filled with elements
Expand All @@ -177,7 +177,7 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Sw
{
auto& element = new_vector.emplace_back();
element.i = static_cast<char>(2 * i);
element.j = static_cast<std::uint64_t>(2 * i);
element.j = 2 * i;
}

// When swapping the two vectors
Expand All @@ -188,14 +188,14 @@ TYPED_TEST(NonRelocatableVectorTriviallyConstructibleDestructibleTypeFixture, Sw
{
auto& element = new_vector.at(i);
EXPECT_EQ(element.i, static_cast<char>(i));
EXPECT_EQ(element.j, static_cast<std::uint64_t>(i));
EXPECT_EQ(element.j, i);
}

for (std::size_t i = 0; i < second_vector_capacity; ++i)
{
auto& element = this->unit_->at(i);
EXPECT_EQ(element.i, static_cast<char>(2 * i));
EXPECT_EQ(element.j, static_cast<std::uint64_t>(2 * i));
EXPECT_EQ(element.j, 2 * i);
}
}

Expand Down
4 changes: 2 additions & 2 deletions score/datetime_converter/datetime_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ namespace score
namespace common
{

int16_t leapYearsSince1970(const int16_t year)
int32_t leapYearsSince1970(const int16_t year)
{
int16_t numOfLeapYears = (((year - 1969) / 4) - ((year - 1901) / 100)) + ((year - 1601) / 400);
int32_t numOfLeapYears = (((year - 1969) / 4) - ((year - 1901) / 100)) + ((year - 1601) / 400);
if (year < 1970)
{
if (year % 4 == 2 || year % 4 == 3)
Expand Down
2 changes: 1 addition & 1 deletion score/datetime_converter/datetime_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct DateTimeType
std::int8_t m_second{0};
};

int16_t leapYearsSince1970(const int16_t year);
int32_t leapYearsSince1970(const int16_t year);
bool yearIsLeap(const int16_t year);
bool isValidDateTimeFormat(const std::shared_ptr<DateTimeType> dateTime);

Expand Down
4 changes: 2 additions & 2 deletions score/filesystem/filestream/file_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ std::string ComposeTempFilename(std::string original_filename) noexcept
// compatible). Since -1 is equal to max value for unsigned type of variable we defined as cast -1U to uid_t.
// coverity[autosar_cpp14_m5_3_2_violation]
// coverity[autosar_cpp14_m5_19_1_violation]
inline constexpr uid_t kDoNotChangeUID{static_cast<uid_t>(-1U)};
inline constexpr uid_t kDoNotChangeUID{-1U};

// Supression: -1 is a value to indicate to the system that we don't intend to change the group id (Linux and QNX
// compatible). Since -1 is equal to max value for unsigned type of variable we defined as cast -1U to gid_t.
// coverity[autosar_cpp14_m5_3_2_violation]
// coverity[autosar_cpp14_m5_19_1_violation]
inline constexpr uid_t kDoNotChangeGID{static_cast<gid_t>(-1U)};
inline constexpr gid_t kDoNotChangeGID{-1U};

[[nodiscard]] uid_t ExtractUid(const details::IdentityMetadata& metadata,
const AtomicUpdateOwnershipFlags ownership_flag)
Expand Down
8 changes: 4 additions & 4 deletions score/filesystem/filestream/i_file_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ namespace filesystem

using AtomicUpdateOwnershipFlags = std::uint32_t;

inline constexpr AtomicUpdateOwnershipFlags kUseTargetFileUID = (static_cast<AtomicUpdateOwnershipFlags>(1U)) << 0U;
inline constexpr AtomicUpdateOwnershipFlags kUseTargetFileGID = (static_cast<AtomicUpdateOwnershipFlags>(1U)) << 1U;
inline constexpr AtomicUpdateOwnershipFlags kUseCurrentProcessUID = (static_cast<AtomicUpdateOwnershipFlags>(1U)) << 2U;
inline constexpr AtomicUpdateOwnershipFlags kUseCurrentProcessGID = (static_cast<AtomicUpdateOwnershipFlags>(1U)) << 3U;
inline constexpr AtomicUpdateOwnershipFlags kUseTargetFileUID = uint32_t{1} << 0U;
inline constexpr AtomicUpdateOwnershipFlags kUseTargetFileGID = uint32_t{1} << 1U;
inline constexpr AtomicUpdateOwnershipFlags kUseCurrentProcessUID = uint32_t{1} << 2U;
inline constexpr AtomicUpdateOwnershipFlags kUseCurrentProcessGID = uint32_t{1} << 3U;

/// @brief Abstracts the way of how to create input / out operations towards files
///
Expand Down
6 changes: 3 additions & 3 deletions score/json/internal/model/lossless_cast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ constexpr std::uint64_t GetMaximumFloatingPointInteger()
{
static_assert(std::numeric_limits<float>::radix == 2, "only supported binary float radix");
static_assert(std::numeric_limits<float>::digits < 64, "Shift count exceeds the width of uint64_t");
return static_cast<uint64_t>(static_cast<uint64_t>(1) << static_cast<uint8_t>(std::numeric_limits<float>::digits));
return static_cast<uint64_t>(1) << static_cast<uint8_t>(std::numeric_limits<float>::digits);
}

template <typename FloatingPoint, typename = std::enable_if_t<std::is_same<FloatingPoint, float>::value, bool>>
Expand All @@ -112,7 +112,7 @@ constexpr std::uint64_t GetMaximumFloatingPointInteger()
{
static_assert(std::numeric_limits<float>::radix == 2, "only supported binary float radix");
static_assert(std::numeric_limits<float>::digits < 64, "Shift count exceeds the width of uint64_t");
return static_cast<uint64_t>(static_cast<uint64_t>(1) << static_cast<uint8_t>(std::numeric_limits<double>::digits));
return static_cast<uint64_t>(1) << static_cast<uint8_t>(std::numeric_limits<double>::digits);
}

template <typename FloatingPoint,
Expand All @@ -125,7 +125,7 @@ constexpr std::int64_t GetMinimumFloatingPointInteger()
static_assert(std::numeric_limits<float>::radix == 2, "only supported binary float radix");
static_assert(std::numeric_limits<float>::digits < 64, "Shift count exceeds the width of uint64_t");
return -(static_cast<int64_t>(
static_cast<uint64_t>(static_cast<uint64_t>(1) << static_cast<uint8_t>(std::numeric_limits<double>::digits))));
static_cast<uint64_t>(1) << static_cast<uint8_t>(std::numeric_limits<double>::digits)));
}

template <typename Output,
Expand Down
4 changes: 2 additions & 2 deletions score/json/internal/model/object_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ TEST_F(AttributeGettersTest, GetFloatingPointUsingResult)

Result<float> float_result = GetAttribute<float>(test_data_result_, "float");
ASSERT_TRUE(float_result.has_value());
EXPECT_TRUE(abs(float_result.value() - 3.14159265359) < 1e-3);
EXPECT_TRUE(abs(float_result.value() - 3.14159265359f) < 1e-3f);

// Floating-point numbers are always stored as double. Having input as a float
// and trying to get it as a double throws assertion since this should be unreachable case.
Expand All @@ -157,7 +157,7 @@ TEST_F(AttributeGettersTest, GetFloatingPointDirectValue)

Result<float> float_result = GetAttribute<float>(test_data_value_, "float");
ASSERT_TRUE(float_result.has_value());
EXPECT_TRUE(abs(float_result.value() - 3.14159265359) < 1e-3);
EXPECT_TRUE(abs(float_result.value() - 3.14159265359f) < 1e-3f);

// Floating-point numbers are always stored as double. Having input as a float
// and trying to get it as a double throws assertion since this should be unreachable case.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ TEST(JsonSerializeAnyTest, SerializeAny)
// integer
v.emplace_back(std::make_pair("5", score::json::Any{5}));
// float
v.emplace_back(std::make_pair("5.5", score::json::Any{float(5.5f)}));
v.emplace_back(std::make_pair("5.5", score::json::Any{5.5f}));
// double
v.emplace_back(std::make_pair("5.5", score::json::Any{double(5.5f)}));
// null
Expand Down
8 changes: 4 additions & 4 deletions score/language/futurecpp/tests/math_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ TEST(math_test, constants)
EXPECT_DOUBLE_EQ(1.570796326794896619231321691639751442E+00, score::cpp::math::constants::half_pi<double>());
EXPECT_DOUBLE_EQ(0.785398163397448309615660845819875721E+00, score::cpp::math::constants::quarter_pi<double>());

EXPECT_DOUBLE_EQ(score::cpp::math::constants::pi<double>(), 0.5F * score::cpp::math::constants::two_pi<double>());
EXPECT_DOUBLE_EQ(score::cpp::math::constants::pi<double>(), 2.0F * score::cpp::math::constants::half_pi<double>());
EXPECT_DOUBLE_EQ(score::cpp::math::constants::pi<double>(), 4.0F * score::cpp::math::constants::quarter_pi<double>());
EXPECT_DOUBLE_EQ(score::cpp::math::constants::pi<double>(), 0.5 * score::cpp::math::constants::two_pi<double>());
EXPECT_DOUBLE_EQ(score::cpp::math::constants::pi<double>(), 2.0 * score::cpp::math::constants::half_pi<double>());
EXPECT_DOUBLE_EQ(score::cpp::math::constants::pi<double>(), 4.0 * score::cpp::math::constants::quarter_pi<double>());

EXPECT_DOUBLE_EQ(1.772453850905516027298167483341145182E+00, score::cpp::math::constants::root_pi<double>());
EXPECT_DOUBLE_EQ(1.253314137315500251207882642405522626E+00, score::cpp::math::constants::root_half_pi<double>());
Expand Down Expand Up @@ -501,7 +501,7 @@ TEST(math_test, wrap_to_two_pi)

const float plus_inf = std::numeric_limits<float>::infinity();
const float minus_inf = -plus_inf;
const float two_pi = 2.0 * pi;
const float two_pi = 2.0F * pi;
const float two_pi_less = std::nextafter(two_pi, minus_inf);
const float two_pi_more = std::nextafter(two_pi, plus_inf);
EXPECT_FLOAT_EQ(two_pi_less, score::cpp::math::wrap_to_two_pi(two_pi_less));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ score::ResultBlank score::safe_math::details::FloatingPointEnvironment::Test() c
// According to the C++ standard, FE_INEXACT is guaranteed to be a power of 2
// (https://en.cppreference.com/w/cpp/numeric/math/math_errhandling), even if their
// underlying type is signed.
constexpr auto exceptions = FE_ALL_EXCEPT & static_cast<std::uint32_t>(~static_cast<std::uint32_t>(FE_INEXACT));
constexpr auto exceptions = FE_ALL_EXCEPT & static_cast<std::uint32_t>(~FE_INEXACT);
// coverity[autosar_cpp14_a16_0_1_violation]
#else
constexpr auto exceptions = FE_ALL_EXCEPT;
Expand Down Expand Up @@ -90,7 +90,7 @@ void score::safe_math::details::FloatingPointEnvironment::Clear() noexcept
// they can still terminate or go to a safe state. Additionally the user could also check and react on the
// exception when the command fails. It is worth to mention that this is not an expected scenario, if as a user can
// proof that clearing the exception failed, a bug can be reported.
score::cpp::ignore = std::feclearexcept(static_cast<int>(FE_ALL_EXCEPT));
score::cpp::ignore = std::feclearexcept(FE_ALL_EXCEPT);

// Interaction with errno unavoidable since this class is the fallback that catches errors for operations
// where inputs could not be checked in advance. Setting errno to zero is required since some floating point
Expand Down
4 changes: 2 additions & 2 deletions score/memory/shared/offset_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ auto OffsetPtr<PointedType>::operator+=(difference_type offset) -> OffsetPtr&
}
else if (offset < 0)
{
DecrementOffset(static_cast<std::size_t>(AbsoluteValue(offset)));
DecrementOffset(AbsoluteValue(offset));
}
return *this;
}
Expand All @@ -684,7 +684,7 @@ auto OffsetPtr<PointedType>::operator-=(difference_type offset) -> OffsetPtr&
}
else if (offset < 0)
{
IncrementOffset(static_cast<std::size_t>(AbsoluteValue(offset)));
IncrementOffset(AbsoluteValue(offset));
}
return *this;
}
Expand Down
Loading
Loading