mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 00:44:37 -06:00
Fix clang-tidy checks (#4379)
* fix(.clang-tidy): `Checks` is supposed to be a comma separated list of checks * fix clang-tidy warning * fix a few lint warnings * run clang-format * more format
This commit is contained in:
parent
d6f43b02ff
commit
903677e97d
@ -6,6 +6,6 @@ Checks: >
|
||||
modernize-redundant-void-arg,
|
||||
modernize-use-bool-literals,
|
||||
modernize-use-nullptr,
|
||||
readability-braces-around-statements
|
||||
-clang-analyzer-security.insecureAPI.rand,
|
||||
readability-braces-around-statements,
|
||||
-clang-analyzer-security.insecureAPI.rand
|
||||
WarningsAsErrors: '*'
|
||||
|
||||
@ -18,8 +18,9 @@ namespace GTest {
|
||||
|
||||
void Bytes ::compare(const Bytes& expected, const Bytes& actual) {
|
||||
ASSERT_EQ(expected.size, actual.size);
|
||||
for (size_t i = 0; i < expected.size; ++i)
|
||||
for (size_t i = 0; i < expected.size; ++i) {
|
||||
ASSERT_EQ(expected.bytes[i], actual.bytes[i]) << "At i=" << i << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace GTest
|
||||
|
||||
@ -19,9 +19,10 @@ TEST(Nominal, SwitchStream) {
|
||||
}
|
||||
TEST(OffNominal, SwitchStream) {
|
||||
Os::Posix::Console::PosixConsole posix_console;
|
||||
ASSERT_DEATH(
|
||||
posix_console.setOutputStream(static_cast<Os::Posix::Console::PosixConsole::Stream>(3)),
|
||||
"Posix/|\\Console.cpp:33"); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional death test
|
||||
// intentional death test
|
||||
ASSERT_DEATH(posix_console.setOutputStream(static_cast< // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange)
|
||||
Os::Posix::Console::PosixConsole::Stream>(3)),
|
||||
"Posix/|\\Console.cpp:33");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
@ -193,7 +193,8 @@ void Os::Test::Directory::Tester::ReadAllFiles::action(Os::Test::Directory::Test
|
||||
// Number of files read should be the number of files in the directory minus the original seek position
|
||||
ASSERT_EQ(outFileCount, state.m_filenames.size());
|
||||
for (FwSizeType i = 0; i < outFileCount; i++) {
|
||||
ASSERT_TRUE(state.is_valid_filename(std::string(outArray[i].toChar())));
|
||||
ASSERT_TRUE(
|
||||
state.is_valid_filename(std::string(outArray[i].toChar()))); // NOLINT(clang-analyzer-security.ArrayBound)
|
||||
}
|
||||
// readDirectory resets the seek position to the end
|
||||
state.m_seek_position = 0;
|
||||
|
||||
@ -37,8 +37,9 @@ FauxPhaser::State FauxPhaser::run(U32 tick_of_cycle, U32 cycle_length) {
|
||||
(state == FauxPhaser::RUNNING || state == FauxPhaser::STARTING)) {
|
||||
bool finished_on_time = (current->length == current->actual_length);
|
||||
current++;
|
||||
if (current < children.end())
|
||||
if (current < children.end()) {
|
||||
current->runtime = 0;
|
||||
}
|
||||
// A child has run long, the machine is forced to idle before starting the next child to avoid a short cycle
|
||||
state = finished_on_time ? FauxPhaser::STARTING : FauxPhaser::IDLE;
|
||||
}
|
||||
@ -53,8 +54,9 @@ FauxPhaser::State FauxPhaser::run(U32 tick_of_cycle, U32 cycle_length) {
|
||||
} else {
|
||||
EXPECT_FALSE(1);
|
||||
}
|
||||
if (current < children.end())
|
||||
if (current < children.end()) {
|
||||
current->runtime++;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@ -125,8 +125,9 @@ void BufferLoggerTester ::dispatchOne() {
|
||||
}
|
||||
|
||||
void BufferLoggerTester ::dispatchAll() {
|
||||
while (this->component.m_queue.getMessagesAvailable() > 0)
|
||||
while (this->component.m_queue.getMessagesAvailable() > 0) {
|
||||
this->dispatchOne();
|
||||
}
|
||||
}
|
||||
|
||||
Fw::Time BufferLoggerTester ::generateTestTime(const U32 seconds) {
|
||||
|
||||
@ -37,8 +37,10 @@ void BadDescriptorFile ::serializeFPrime(Fw::SerializeBufferBase& buffer) {
|
||||
for (U32 record = 0; record < this->n; record++) {
|
||||
Fw::Time t(TimeBase::TB_WORKSTATION_TIME, 0, 0);
|
||||
// Force an invalid record descriptor
|
||||
FPrime::Records::Descriptor descriptor = static_cast<FPrime::Records::Descriptor>(
|
||||
10); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional test
|
||||
FPrime::Records::Descriptor descriptor =
|
||||
static_cast<FPrime::Records::Descriptor>( // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange)
|
||||
// intentional test
|
||||
10);
|
||||
FPrime::Records::serialize(descriptor, t, record, record + 1, buffer);
|
||||
}
|
||||
// CRC
|
||||
@ -51,8 +53,10 @@ void BadDescriptorFile ::serializeAMPCS(Fw::SerializeBufferBase& buffer) {
|
||||
// Records
|
||||
for (U32 i = 0; i < this->n; ++i) {
|
||||
// Force an invalid time flag
|
||||
const AMPCSSequence::Record::TimeFlag::t timeFlag = static_cast<AMPCSSequence::Record::TimeFlag::t>(
|
||||
10); // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange) intentional test
|
||||
const AMPCSSequence::Record::TimeFlag::t timeFlag =
|
||||
static_cast<AMPCSSequence::Record::TimeFlag::t>( // NOLINT(clang-analyzer-optin.core.EnumCastOutOfRange)
|
||||
// intentional test
|
||||
10);
|
||||
const AMPCSSequence::Record::Time::t time = 0;
|
||||
const AMPCSSequence::Record::Opcode::t opcode = i;
|
||||
const U32 argument = i + 1;
|
||||
|
||||
@ -49,8 +49,9 @@ void ComLoggerTester ::dispatchOne() {
|
||||
}
|
||||
|
||||
void ComLoggerTester ::dispatchAll() {
|
||||
while (this->comLogger.m_queue.getMessagesAvailable() > 0)
|
||||
while (this->comLogger.m_queue.getMessagesAvailable() > 0) {
|
||||
this->dispatchOne();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@ -113,7 +113,8 @@ void ComStubTester ::test_retry_async() {
|
||||
}
|
||||
// Retrying for as many times as the RETRY_LIMIT should be ok
|
||||
for (FwIndexType i = 0; i < this->component.RETRY_LIMIT; i++) {
|
||||
invoke_to_drvAsyncSendReturnIn(0, buffers[i], Drv::ByteStreamStatus::SEND_RETRY);
|
||||
invoke_to_drvAsyncSendReturnIn(
|
||||
0, buffers[i], Drv::ByteStreamStatus::SEND_RETRY); // NOLINT(clang-analyzer-security.ArrayBound)
|
||||
// Test we have indeed retried (data sent on drvAsyncSendOut)
|
||||
ASSERT_from_drvAsyncSendOut_SIZE(static_cast<U32>(i + 1));
|
||||
ASSERT_from_drvAsyncSendOut(static_cast<U32>(i), buffers[i]);
|
||||
|
||||
@ -342,7 +342,7 @@ void FileDownlinkTester ::from_bufferSendOut_handler(const FwIndexType portNum,
|
||||
ASSERT_LT(buffers_index, FW_NUM_ARRAY_ELEMENTS(this->buffers));
|
||||
// Copy buffer before recycling
|
||||
U8* data = new U8[buffer.getSize()];
|
||||
this->buffers[buffers_index] = data;
|
||||
this->buffers[buffers_index] = data; // NOLINT(clang-analyzer-security.ArrayBound)
|
||||
buffers_index++;
|
||||
::memcpy(data, buffer.getData(), buffer.getSize());
|
||||
Fw::Buffer buffer_new = buffer;
|
||||
|
||||
@ -507,8 +507,9 @@ void PrmDbImpl::clearDb(PrmDbType prmDbType) {
|
||||
|
||||
bool PrmDbImpl::dbEqual() {
|
||||
for (FwSizeType i = 0; i < PRMDB_NUM_DB_ENTRIES; i++) {
|
||||
if (!(this->m_dbStore1[i] == this->m_dbStore2[i]))
|
||||
if (!(this->m_dbStore1[i] == this->m_dbStore2[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -90,8 +90,8 @@ void TokenBucketTester ::testReconfiguring() {
|
||||
ASSERT_EQ(bucket.getTokens(), newMaxTokens - 1);
|
||||
|
||||
// set new rate, replenish quickly
|
||||
while (bucket.trigger(Fw::Time(0, 0)))
|
||||
;
|
||||
while (bucket.trigger(Fw::Time(0, 0))) {
|
||||
}
|
||||
bucket.setReplenishInterval(1000000);
|
||||
U32 newRate = 2;
|
||||
bucket.setReplenishRate(newRate);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user