Skip to content

Commit 029c70a

Browse files
Fixed some minor cppcheck issues that we have with stricter settings (#77)
Co-authored-by: Jesper Raemaekers <jesper.raemaekers@wefabricate.com>
1 parent 5cb8842 commit 029c70a

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

lib/inc/datalogging/scrutiny_datalogger_raw_encoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace scrutiny
7070
inline void set_timebase(Timebase const *const timebase) { m_timebase = timebase; }
7171
inline datalogging::buffer_size_t get_entry_write_counter(void) const { return m_entry_write_counter; }
7272
inline datalogging::buffer_size_t get_data_write_counter(void) const { return m_entry_write_counter * m_entry_size; }
73-
inline datalogging::EncodingType::eEncodingType get_encoding(void) const { return ENCODING; }
73+
static inline datalogging::EncodingType::eEncodingType get_encoding(void) { return ENCODING; }
7474
inline datalogging::buffer_size_t get_read_cursor(void) const { return m_first_valid_entry_index * m_entry_size; }
7575
inline datalogging::buffer_size_t get_write_cursor(void) const { return m_next_entry_write_index * m_entry_size; }
7676
inline bool error(void) const { return m_error; }

lib/inc/protocol/scrutiny_comm_handler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace scrutiny
6868
/// @brief Tells if the Request object has a CRC that matches its payload content.
6969
/// @param req The request to check
7070
/// @return True if the CRC is valid. False otherwise
71-
bool check_crc(Request const *const req) const;
71+
static bool check_crc(Request const *const req);
7272

7373
// Writes the CRC property of the response based on the payload content.
7474
void add_crc(Response *const response) const;
@@ -137,7 +137,7 @@ namespace scrutiny
137137
protected:
138138
void process_active_request(void);
139139
bool received_discover_request(void);
140-
bool received_connect_request(void);
140+
bool received_connect_request(void) const;
141141

142142
class RxFSMState
143143
{

lib/src/protocol/scrutiny_comm_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ namespace scrutiny
417417
}
418418

419419
// Check if the last request received is a valid "Comm Discover request".
420-
bool CommHandler::received_connect_request(void)
420+
bool CommHandler::received_connect_request(void) const
421421
{
422422
if (m_active_request.command_id != static_cast<uint8_t>(CommandId::CommControl))
423423
{
@@ -471,7 +471,7 @@ namespace scrutiny
471471
return m_nbytes_to_send - m_nbytes_sent;
472472
}
473473

474-
bool CommHandler::check_crc(Request const *const req) const
474+
bool CommHandler::check_crc(Request const *const req)
475475
{
476476
uint32_t crc = 0;
477477
uint8_t header_data[4];

lib/src/scrutiny_tools.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@ namespace scrutiny
1515
{
1616
namespace tools
1717
{
18-
VariableTypeSize::eVariableTypeSize get_required_type_size(uint_fast8_t const newsize)
18+
VariableTypeSize::eVariableTypeSize get_required_type_size(uint_fast8_t const size)
1919
{
20-
if (newsize <= 1)
20+
if (size <= 1)
2121
{
2222
return VariableTypeSize::_8;
2323
}
24-
else if (newsize <= 2)
24+
else if (size <= 2)
2525
{
2626
return VariableTypeSize::_16;
2727
}
28-
else if (newsize <= 4)
28+
else if (size <= 4)
2929
{
3030
return VariableTypeSize::_32;
3131
}
32-
else if (newsize <= 8)
32+
else if (size <= 8)
3333
{
3434
return VariableTypeSize::_64;
3535
}
36-
else if (newsize <= 16)
36+
else if (size <= 16)
3737
{
3838
return VariableTypeSize::_128;
3939
}
40-
else if (newsize <= 32)
40+
else if (size <= 32)
4141
{
4242
return VariableTypeSize::_256;
4343
}

scripts/static_analysis.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CPPCHECK_ARGS="-I $LIB_ROOT/inc $LIB_ROOT \
1414
--suppress=preprocessorErrorDirective
1515
--suppress=unmatchedSuppression
1616
--inline-suppr
17+
--inconclusive
1718
-DSCRUTINY_STATIC_ANALYSIS"
1819

1920
PLATFORMS="unix32 unix64 win32A win32W win64 avr8 elbrus-e1cp pic8 pic8-enhanced pic16 mips32 native"

0 commit comments

Comments
 (0)