Skip to content

Commit

Permalink
Array bounds and maybe-uninitialized warning fixes
Browse files Browse the repository at this point in the history
Array bounds and maybe-uninitialized warning fixes

Added GCC/clang diagnostic disable for array bounds

Fixed false positive array bounds failure in unit tests

Added -01 & -03 quick tests

Fixed constexpr for exception constructor

Made virtual functions protected

Updated project files

Updated generated file

Updated versions and release notes
  • Loading branch information
jwellbelove committed Mar 2, 2023
1 parent 7bfa2d9 commit bcad53e
Show file tree
Hide file tree
Showing 29 changed files with 1,188 additions and 565 deletions.
2 changes: 1 addition & 1 deletion arduino/library-arduino.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Embedded Template Library - Arduino",
"version": "20.35.12",
"version": "20.35.13",
"authors": {
"name": "John Wellbelove",
"email": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion arduino/library-arduino.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Embedded Template Library - Arduino
version=20.35.12
version=20.35.13
author= John Wellbelove <[email protected]>
maintainer=John Wellbelove <[email protected]>
license=MIT
Expand Down
3 changes: 1 addition & 2 deletions include/etl/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ namespace etl
/// Constructor.
//*************************************************************************
ETL_CONSTEXPR
exception(string_type reason_, string_type file_, numeric_type line_)
exception(string_type reason_, string_type /*file_*/, numeric_type line_)
: reason_text(reason_),
line(line_)
{
(void)file_;
}
#endif

Expand Down
21 changes: 12 additions & 9 deletions include/etl/fixed_sized_memory_block_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace etl
class fixed_sized_memory_block_allocator : public imemory_block_allocator
{
public:

static ETL_CONSTANT size_t Block_Size = VBlock_Size;
static ETL_CONSTANT size_t Alignment = VAlignment;
static ETL_CONSTANT size_t Size = VSize;
Expand All @@ -57,22 +58,16 @@ namespace etl
{
}

private:

/// A structure that has the size Block_Size.
struct block
{
char data[Block_Size];
};
protected:

//*************************************************************************
/// The overridden virtual function to allocate a block.
//*************************************************************************
virtual void* allocate_block(size_t required_size, size_t required_alignment) ETL_OVERRIDE
{
if ((required_alignment <= Alignment) &&
(required_size <= Block_Size) &&
!pool.full())
(required_size <= Block_Size) &&
!pool.full())
{
return pool.template allocate<block>();
}
Expand Down Expand Up @@ -106,6 +101,14 @@ namespace etl
return pool.is_in_pool(pblock);
}

private:

/// A structure that has the size Block_Size.
struct block
{
char data[Block_Size];
};

/// The generic pool from which allocate memory blocks.
etl::generic_pool<Block_Size, Alignment, Size> pool;
};
Expand Down
70 changes: 35 additions & 35 deletions include/etl/message_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ namespace etl
new (p) etl::remove_reference_t<TMessage>((etl::forward<TMessage>(msg)));
}

typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
bool valid;

//********************************************
template <typename TType>
bool add_new_message_type(const etl::imessage& msg)
Expand Down Expand Up @@ -320,6 +317,9 @@ namespace etl
return false;
}
}

typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
bool valid;
};

#else
Expand Down Expand Up @@ -543,7 +543,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -553,7 +553,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -836,7 +836,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -846,7 +846,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -1127,7 +1127,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -1137,7 +1137,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -1416,7 +1416,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -1426,7 +1426,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -1699,7 +1699,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -1709,7 +1709,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -1980,7 +1980,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -1990,7 +1990,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -2259,7 +2259,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -2269,7 +2269,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -2536,7 +2536,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -2546,7 +2546,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -2807,7 +2807,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -2817,7 +2817,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -3076,7 +3076,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -3086,7 +3086,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -3343,7 +3343,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -3353,7 +3353,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -3608,7 +3608,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -3618,7 +3618,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -3867,7 +3867,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -3877,7 +3877,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -4124,7 +4124,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -4134,7 +4134,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -4379,7 +4379,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -4389,7 +4389,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down Expand Up @@ -4632,7 +4632,7 @@ namespace etl
private:

//********************************************
#include "etl/private/diagnostic_uninitialized_push.h"
#include "etl/private/diagnostic_uninitialized_push.h"
void delete_current_message()
{
if (valid)
Expand All @@ -4642,7 +4642,7 @@ namespace etl
pmsg->~imessage();
}
}
#include "etl/private/diagnostic_pop.h"
#include "etl/private/diagnostic_pop.h"

//********************************************
void add_new_message(const etl::imessage& msg)
Expand Down
Loading

0 comments on commit bcad53e

Please sign in to comment.