mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
Reduced warnings from cppcheck v2.2
This commit is contained in:
parent
1b82d4dfaf
commit
0180a7c9bd
@ -59,7 +59,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
struct free_function : public etl::function<void, const etl::exception&>
|
||||
{
|
||||
free_function(void (*p_function_)(const etl::exception&))
|
||||
explicit free_function(void (*p_function_)(const etl::exception&))
|
||||
: etl::function<void, const etl::exception&>(p_function_)
|
||||
{
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ namespace etl
|
||||
/// The function operator that calls the destination function.
|
||||
///\param data The data to pass to the function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()(TParameter data) const
|
||||
void operator ()(TParameter data) const ETL_OVERRIDE
|
||||
{
|
||||
// Call the object's member function with the data.
|
||||
(p_object->*p_function)(data);
|
||||
@ -148,7 +148,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// The function operator that calls the destination function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()() const
|
||||
void operator ()() const ETL_OVERRIDE
|
||||
{
|
||||
// Call the object's member function.
|
||||
(p_object->*p_function)();
|
||||
@ -173,7 +173,7 @@ namespace etl
|
||||
/// Constructor.
|
||||
///\param p_function Pointer to the function
|
||||
//*************************************************************************
|
||||
function(void(*p_function_)(TParameter))
|
||||
explicit function(void(*p_function_)(TParameter))
|
||||
: p_function(p_function_)
|
||||
{
|
||||
}
|
||||
@ -182,7 +182,7 @@ namespace etl
|
||||
/// The function operator that calls the destination function.
|
||||
///\param data The data to pass to the function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()(TParameter data) const
|
||||
void operator ()(TParameter data) const ETL_OVERRIDE
|
||||
{
|
||||
// Call the function with the data.
|
||||
(*p_function)(data);
|
||||
@ -206,7 +206,7 @@ namespace etl
|
||||
/// Constructor.
|
||||
///\param p_function Pointer to the function.
|
||||
//*************************************************************************
|
||||
function(void(*p_function_)(void))
|
||||
explicit function(void(*p_function_)(void))
|
||||
: p_function(p_function_)
|
||||
{
|
||||
}
|
||||
@ -214,7 +214,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// The function operator that calls the destination function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()() const
|
||||
void operator ()() const ETL_OVERRIDE
|
||||
{
|
||||
// Call the function.
|
||||
(*p_function)();
|
||||
@ -243,7 +243,7 @@ namespace etl
|
||||
/// Constructor.
|
||||
///\param object Reference to the object
|
||||
//*************************************************************************
|
||||
function_mp(TObject& object_)
|
||||
explicit function_mp(TObject& object_)
|
||||
: p_object(&object_)
|
||||
{
|
||||
}
|
||||
@ -252,7 +252,7 @@ namespace etl
|
||||
/// The function operator that calls the destination function.
|
||||
///\param data The data to pass to the function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()(TParameter data) const
|
||||
void operator ()(TParameter data) const ETL_OVERRIDE
|
||||
{
|
||||
// Call the object's member function with the data.
|
||||
(p_object->*Function)(data);
|
||||
@ -281,7 +281,7 @@ namespace etl
|
||||
/// Constructor.
|
||||
///\param object Reference to the object
|
||||
//*************************************************************************
|
||||
function_mv(TObject& object_)
|
||||
explicit function_mv(TObject& object_)
|
||||
: p_object(&object_)
|
||||
{
|
||||
}
|
||||
@ -290,7 +290,7 @@ namespace etl
|
||||
/// The function operator that calls the destination function.
|
||||
///\param data The data to pass to the function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()() const
|
||||
void operator ()() const ETL_OVERRIDE
|
||||
{
|
||||
// Call the object's member function.
|
||||
(p_object->*Function)();
|
||||
@ -319,7 +319,7 @@ namespace etl
|
||||
/// The function operator that calls the destination function.
|
||||
///\param data The data to pass to the function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()(TParameter data) const
|
||||
void operator ()(TParameter data) const ETL_OVERRIDE
|
||||
{
|
||||
// Call the object's member function with the data.
|
||||
(Instance.*Function)(data);
|
||||
@ -344,7 +344,7 @@ namespace etl
|
||||
/// The function operator that calls the destination function.
|
||||
///\param data The data to pass to the function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()() const
|
||||
void operator ()() const ETL_OVERRIDE
|
||||
{
|
||||
// Call the object's member function.
|
||||
(Instance.*Function)();
|
||||
@ -376,7 +376,7 @@ namespace etl
|
||||
/// The function operator that calls the destination function.
|
||||
///\param data The data to pass to the function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()(TParameter data) const
|
||||
void operator ()(TParameter data) const ETL_OVERRIDE
|
||||
{
|
||||
// Call the object's member function with the data.
|
||||
(*Function)(data);
|
||||
@ -408,7 +408,7 @@ namespace etl
|
||||
/// The function operator that calls the destination function.
|
||||
///\param data The data to pass to the function.
|
||||
//*************************************************************************
|
||||
virtual void operator ()() const
|
||||
void operator ()() const ETL_OVERRIDE
|
||||
{
|
||||
// Call the function.
|
||||
(*Function)();
|
||||
|
||||
@ -623,9 +623,9 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
static const size_t SIZE = base_t::SIZE;
|
||||
static const size_t ALIGNMENT = base_t::ALIGNMENT;
|
||||
static const size_t TYPE_SIZE = base_t::TYPE_SIZE;
|
||||
using base_t::SIZE;
|
||||
using base_t::ALIGNMENT;
|
||||
using base_t::TYPE_SIZE;
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor
|
||||
|
||||
@ -224,7 +224,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
reference operator [](size_t i)
|
||||
{
|
||||
return reference(p_buffer[i]);
|
||||
return p_buffer[i];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -234,7 +234,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_reference operator [](size_t i) const
|
||||
{
|
||||
return const_reference(p_buffer[i]);
|
||||
return p_buffer[i];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -246,7 +246,7 @@ namespace etl
|
||||
reference at(size_t i)
|
||||
{
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds));
|
||||
return reference(p_buffer[i]);
|
||||
return p_buffer[i];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -258,7 +258,7 @@ namespace etl
|
||||
const_reference at(size_t i) const
|
||||
{
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(vector_out_of_bounds));
|
||||
return const_reference(p_buffer[i]);
|
||||
return p_buffer[i];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -267,7 +267,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
reference front()
|
||||
{
|
||||
return reference(p_buffer[0]);
|
||||
return p_buffer[0];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -276,7 +276,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
return const_reference(p_buffer[0]);
|
||||
return p_buffer[0];
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -285,7 +285,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
reference back()
|
||||
{
|
||||
return reference(*(p_end - 1));
|
||||
return *(p_end - 1);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -294,7 +294,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_reference back() const
|
||||
{
|
||||
return const_reference(*(p_end - 1));
|
||||
return *(p_end - 1);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -303,7 +303,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
pointer data()
|
||||
{
|
||||
return pointer(p_buffer);
|
||||
return p_buffer;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -312,7 +312,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_pointer data() const
|
||||
{
|
||||
return const_pointer(p_buffer);
|
||||
return p_buffer;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
|
||||
@ -39,7 +39,7 @@ SOFTWARE.
|
||||
|
||||
#define ETL_VERSION_MAJOR 18
|
||||
#define ETL_VERSION_MINOR 16
|
||||
#define ETL_VERSION_PATCH 3
|
||||
#define ETL_VERSION_PATCH 4
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "18.16.3",
|
||||
"version": "18.16.4",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=18.16.3
|
||||
version=18.16.4
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
===============================================================================
|
||||
18.16.4
|
||||
Reduced warnings from cppcheck v2.2
|
||||
|
||||
===============================================================================
|
||||
18.16.3
|
||||
Added VS2019 to CI configuration file.
|
||||
|
||||
@ -38,84 +38,84 @@ SOFTWARE.
|
||||
#include "etl/integral_limits.h"
|
||||
#include "etl/type_traits.h"
|
||||
|
||||
// Count bits the easy way.
|
||||
template <typename T>
|
||||
size_t test_count(T value)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
for (int i = 0; i < etl::integral_limits<T>::bits; ++i)
|
||||
{
|
||||
if ((value & (T(1) << i)) != 0)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// Check parity the easy way.
|
||||
template <typename T>
|
||||
size_t test_parity(T value)
|
||||
{
|
||||
size_t count = test_count(value);
|
||||
|
||||
return count & 1;
|
||||
}
|
||||
|
||||
// Power of 2.
|
||||
uint64_t test_power_of_2(int power)
|
||||
{
|
||||
uint64_t result = 1;
|
||||
|
||||
for (int i = 0; i < power; ++i)
|
||||
{
|
||||
result *= 2;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Fold bits.
|
||||
template <typename TReturn>
|
||||
TReturn test_fold_bits(uint64_t value, int size)
|
||||
{
|
||||
int bits_remaining = 64;
|
||||
uint64_t mask = test_power_of_2(size) - 1;
|
||||
TReturn result = 0;
|
||||
|
||||
while (bits_remaining > size)
|
||||
{
|
||||
result = result ^ (value & mask);
|
||||
value = value >> size;
|
||||
bits_remaining -= size;
|
||||
}
|
||||
|
||||
result = result ^ (value & mask);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Slow gray to binary
|
||||
template <typename T>
|
||||
T compare_gray_to_binary(T value_)
|
||||
{
|
||||
typedef typename std::make_unsigned<T>::type type;
|
||||
|
||||
type value = type(value_);
|
||||
|
||||
T mask;
|
||||
for (mask = value >> 1; mask != 0; mask = mask >> 1)
|
||||
{
|
||||
value = value ^ mask;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// Count bits the easy way.
|
||||
template <typename T>
|
||||
size_t test_count(T value)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
for (int i = 0; i < etl::integral_limits<T>::bits; ++i)
|
||||
{
|
||||
if ((value & (T(1) << i)) != 0)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// Check parity the easy way.
|
||||
template <typename T>
|
||||
size_t test_parity(T value)
|
||||
{
|
||||
size_t count = test_count(value);
|
||||
|
||||
return count & 1;
|
||||
}
|
||||
|
||||
// Power of 2.
|
||||
uint64_t test_power_of_2(int power)
|
||||
{
|
||||
uint64_t result = 1;
|
||||
|
||||
for (int i = 0; i < power; ++i)
|
||||
{
|
||||
result *= 2;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Fold bits.
|
||||
template <typename TReturn>
|
||||
TReturn test_fold_bits(uint64_t value, int size)
|
||||
{
|
||||
int bits_remaining = 64;
|
||||
uint64_t mask = test_power_of_2(size) - 1;
|
||||
TReturn result = 0;
|
||||
|
||||
while (bits_remaining > size)
|
||||
{
|
||||
result = result ^ (value & mask);
|
||||
value = value >> size;
|
||||
bits_remaining -= size;
|
||||
}
|
||||
|
||||
result = result ^ (value & mask);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Slow gray to binary
|
||||
template <typename T>
|
||||
T compare_gray_to_binary(T value_)
|
||||
{
|
||||
typedef typename std::make_unsigned<T>::type type;
|
||||
|
||||
type value = type(value_);
|
||||
|
||||
T mask;
|
||||
for (mask = value >> 1; mask != 0; mask = mask >> 1)
|
||||
{
|
||||
value = value ^ mask;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
SUITE(test_binary)
|
||||
{
|
||||
//*************************************************************************
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user