mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 00:44:37 -06:00
Update of clang tidy checks (#2710)
* Add clang tidy check on braces * Merge clang-tidy files * Add documentation and clang-tidy revert changes
This commit is contained in:
parent
0e1addb570
commit
eb518e9f1d
@ -1,8 +1,11 @@
|
||||
# Clang-tidy configuration used on the whole code base, including tests and flight code
|
||||
|
||||
Checks: >
|
||||
bugprone-unhandled-self-assignment,
|
||||
modernize-deprecated-headers,
|
||||
modernize-redundant-void-arg,
|
||||
modernize-use-bool-literals,
|
||||
modernize-use-nullptr,
|
||||
-clang-analyzer-security.insecureAPI.rand
|
||||
readability-braces-around-statements
|
||||
-clang-analyzer-security.insecureAPI.rand,
|
||||
WarningsAsErrors: '*'
|
||||
|
||||
2
.github/workflows/build-test.yml
vendored
2
.github/workflows/build-test.yml
vendored
@ -95,10 +95,12 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install clang-tidy-12
|
||||
# Uses the default configuration file (.clang-tidy)
|
||||
- name: General Static Analysis
|
||||
run: |
|
||||
fprime-util generate --ut -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_CLANG_TIDY=clang-tidy-12
|
||||
fprime-util build --all --ut
|
||||
# Uses the release configuration file (release.clang-tidy)
|
||||
- name: Flight Code Static Analysis
|
||||
run: |
|
||||
fprime-util generate -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_CLANG_TIDY="clang-tidy-12;--config-file=$PWD/release.clang-tidy"
|
||||
|
||||
@ -90,8 +90,9 @@ namespace CFDP {
|
||||
}
|
||||
|
||||
// Add the middle words aligned
|
||||
for ( ; index + 4 <= length; index += 4)
|
||||
for ( ; index + 4 <= length; index += 4) {
|
||||
addWordAligned(&data[index]);
|
||||
}
|
||||
|
||||
// Add the last word unaligned if necessary
|
||||
if (index < length) {
|
||||
@ -108,8 +109,9 @@ namespace CFDP {
|
||||
void Checksum ::
|
||||
addWordAligned(const U8 *const word)
|
||||
{
|
||||
for (U8 i = 0; i < 4; ++i)
|
||||
for (U8 i = 0; i < 4; ++i) {
|
||||
addByteAtOffset(word[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
void Checksum ::
|
||||
@ -124,8 +126,9 @@ namespace CFDP {
|
||||
for (U8 i = 0; i < length; ++i) {
|
||||
addByteAtOffset(word[i], offset);
|
||||
++offset;
|
||||
if (offset == 4)
|
||||
if (offset == 4) {
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,8 +43,9 @@ namespace Fw {
|
||||
|
||||
FW_ASSERT(this->m_header.m_type == T_CANCEL);
|
||||
|
||||
if (serialBuffer.getBuffLeft() != 0)
|
||||
if (serialBuffer.getBuffLeft() != 0) {
|
||||
return FW_DESERIALIZE_SIZE_MISMATCH;
|
||||
}
|
||||
|
||||
return FW_SERIALIZE_OK;
|
||||
|
||||
|
||||
@ -56,15 +56,18 @@ namespace Fw {
|
||||
FW_ASSERT(this->m_header.m_type == T_DATA);
|
||||
|
||||
SerializeStatus status = serialBuffer.deserialize(this->m_byteOffset);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = serialBuffer.deserialize(this->m_dataSize);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (serialBuffer.getBuffLeft() != this->m_dataSize)
|
||||
if (serialBuffer.getBuffLeft() != this->m_dataSize) {
|
||||
return FW_DESERIALIZE_SIZE_MISMATCH;
|
||||
}
|
||||
|
||||
U8 *const addr = serialBuffer.getBuffAddr();
|
||||
this->m_data = &addr[this->fixedLengthSize()];
|
||||
@ -91,16 +94,19 @@ namespace Fw {
|
||||
SerializeStatus status;
|
||||
|
||||
status = this->m_header.toSerialBuffer(serialBuffer);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = serialBuffer.serialize(this->m_byteOffset);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = serialBuffer.serialize(this->m_dataSize);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = serialBuffer.pushBytes(this->m_data, this->m_dataSize);
|
||||
|
||||
|
||||
@ -79,12 +79,14 @@ namespace Fw {
|
||||
SerializeStatus status;
|
||||
|
||||
status = this->m_header.toSerialBuffer(serialBuffer);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = serialBuffer.serialize(this->m_checksumValue);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return FW_SERIALIZE_OK;
|
||||
|
||||
|
||||
@ -140,8 +140,10 @@ namespace Fw {
|
||||
{
|
||||
SerializeStatus status;
|
||||
status = this->m_header.fromSerialBuffer(serialBuffer);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
switch (this->m_header.m_type) {
|
||||
case T_START:
|
||||
status = this->m_startPacket.fromSerialBuffer(serialBuffer);
|
||||
|
||||
@ -58,12 +58,14 @@ namespace Fw {
|
||||
SerializeStatus status;
|
||||
|
||||
status = serialBuffer.serialize(type_casted);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = serialBuffer.serialize(this->m_sequenceIndex);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return FW_SERIALIZE_OK;
|
||||
|
||||
|
||||
@ -39,8 +39,10 @@ namespace Fw {
|
||||
{
|
||||
const SerializeStatus status =
|
||||
serialBuffer.deserialize(this->m_length);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@ -48,8 +50,11 @@ namespace Fw {
|
||||
U8 bytes[MAX_LENGTH];
|
||||
const SerializeStatus status =
|
||||
serialBuffer.popBytes(bytes, this->m_length);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
this->m_value = reinterpret_cast<const char*>(addrLeft);
|
||||
}
|
||||
|
||||
@ -64,8 +69,10 @@ namespace Fw {
|
||||
{
|
||||
const SerializeStatus status =
|
||||
serialBuffer.serialize(this->m_length);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@ -73,8 +80,10 @@ namespace Fw {
|
||||
reinterpret_cast<const U8 *>(this->m_value),
|
||||
this->m_length
|
||||
);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return FW_SERIALIZE_OK;
|
||||
|
||||
@ -57,22 +57,28 @@ namespace Fw {
|
||||
{
|
||||
const SerializeStatus status =
|
||||
serialBuffer.deserialize(this->m_fileSize);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const SerializeStatus status =
|
||||
this->m_sourcePath.fromSerialBuffer(serialBuffer);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const SerializeStatus status =
|
||||
this->m_destinationPath.fromSerialBuffer(serialBuffer);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return FW_SERIALIZE_OK;
|
||||
@ -88,29 +94,37 @@ namespace Fw {
|
||||
{
|
||||
const SerializeStatus status =
|
||||
this->m_header.toSerialBuffer(serialBuffer);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const SerializeStatus status =
|
||||
serialBuffer.serialize(this->m_fileSize);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const SerializeStatus status =
|
||||
this->m_sourcePath.toSerialBuffer(serialBuffer);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const SerializeStatus status =
|
||||
this->m_destinationPath.toSerialBuffer(serialBuffer);
|
||||
if (status != FW_SERIALIZE_OK)
|
||||
|
||||
if (status != FW_SERIALIZE_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return FW_SERIALIZE_OK;
|
||||
|
||||
@ -33,7 +33,7 @@ class StringBase : public Serializable {
|
||||
//! This is the max length of the string plus the size of the stored size
|
||||
static constexpr SizeType STATIC_SERIALIZED_SIZE(SizeType maxLength //!< The maximum string length
|
||||
) {
|
||||
return sizeof(FwSizeStoreType) + maxLength;
|
||||
return static_cast<SizeType>(sizeof(FwSizeStoreType)) + maxLength;
|
||||
}
|
||||
|
||||
//! Get the size of a null-terminated string buffer
|
||||
|
||||
@ -34,10 +34,11 @@ namespace Svc {
|
||||
|
||||
// Set size
|
||||
FwSignedSizeType file_size;
|
||||
const Os::FileSystem::Status status =
|
||||
const Os::FileSystem::Status status =
|
||||
Os::FileSystem::getFileSize(sourceFileName, file_size);
|
||||
if (status != Os::FileSystem::OP_OK)
|
||||
if (status != Os::FileSystem::OP_OK) {
|
||||
return Os::File::BAD_SIZE;
|
||||
}
|
||||
// If the size does not cast cleanly to the desired U32 type, return size error
|
||||
if (static_cast<FwSignedSizeType>(static_cast<U32>(file_size)) != file_size) {
|
||||
return Os::File::BAD_SIZE;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
# Clang-tidy configuration used only for flight code
|
||||
|
||||
Checks: >
|
||||
-*,
|
||||
misc-no-recursion
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user