diff --git a/Sming/Arch/Host/Components/driver/hw_timer.cpp b/Sming/Arch/Host/Components/driver/hw_timer.cpp index 0ceacae8fa..ac52f34a50 100644 --- a/Sming/Arch/Host/Components/driver/hw_timer.cpp +++ b/Sming/Arch/Host/Components/driver/hw_timer.cpp @@ -120,7 +120,6 @@ class CTimerThread : public CThread private: typedef std::ratio base_ticks_per_us; uint32_t divisor = 1; - uint32_t frequency = HW_TIMER_BASE_CLK; uint64_t start_time = 0; uint64_t interval = 0; // In microseconds CSemaphore sem; // Signals state change @@ -130,7 +129,6 @@ class CTimerThread : public CThread State state = stopped; hw_timer_source_type_t source_type = TIMER_FRC1_SOURCE; - unsigned irq_level = 1; struct { hw_timer_callback_t func = nullptr; void* arg = nullptr; diff --git a/Sming/Arch/Host/Components/driver/uart.cpp b/Sming/Arch/Host/Components/driver/uart.cpp index d67e386020..9294a03355 100644 --- a/Sming/Arch/Host/Components/driver/uart.cpp +++ b/Sming/Arch/Host/Components/driver/uart.cpp @@ -73,11 +73,6 @@ void notify(smg_uart_t* uart, smg_uart_notify_code_t code) } } -__forceinline bool smg_uart_isr_enabled(uint8_t nr) -{ - return bitRead(isrMask, nr); -} - } // namespace smg_uart_t* smg_uart_get_uart(uint8_t uart_nr) diff --git a/Sming/Arch/Host/Components/hostlib/sockets.h b/Sming/Arch/Host/Components/hostlib/sockets.h index 83570d30ab..71286d0761 100644 --- a/Sming/Arch/Host/Components/hostlib/sockets.h +++ b/Sming/Arch/Host/Components/hostlib/sockets.h @@ -113,12 +113,12 @@ class CSocket assign(fd, addr); } - virtual ~CSocket() + ~CSocket() { close(); } - virtual void close(); + void close(); bool setblocking(bool block); bool bind(const CSockAddr& sa); @@ -217,7 +217,12 @@ class CServerSocket : public CSocket { } - void close() override + virtual ~CServerSocket() + { + close(); + } + + void close() { m_clients.closeall(); CSocket::close(); diff --git a/Sming/Components/FlashString b/Sming/Components/FlashString index 269b830e00..6fd4fab039 160000 --- a/Sming/Components/FlashString +++ b/Sming/Components/FlashString @@ -1 +1 @@ -Subproject commit 269b830e00b64cf17d34e8058685ffc594200aec +Subproject commit 6fd4fab03961377221e1db2303ceb3babe5ede0c diff --git a/Sming/Components/IFS b/Sming/Components/IFS index c72b265e53..c159a7a0dd 160000 --- a/Sming/Components/IFS +++ b/Sming/Components/IFS @@ -1 +1 @@ -Subproject commit c72b265e53ac215a979eff907d216eab068987df +Subproject commit c159a7a0ddc8bb5c5d57994f7ce8f01b406d7a54 diff --git a/Sming/Components/Network/src/IpAddress.h b/Sming/Components/Network/src/IpAddress.h index c092e8f356..f25ae90edb 100644 --- a/Sming/Components/Network/src/IpAddress.h +++ b/Sming/Components/Network/src/IpAddress.h @@ -64,14 +64,12 @@ class IpAddress ip_addr_set_ip4_u32(&this->address, address); } - IpAddress(ip_addr_t& addr) + IpAddress(ip_addr_t& addr) : address(addr) { - address = addr; } - IpAddress(const ip_addr_t& addr) + IpAddress(const ip_addr_t& addr) : address(addr) { - address = addr; } #if LWIP_VERSION_MAJOR == 2 && LWIP_IPV6 diff --git a/Sming/Components/Storage/src/include/Storage/Device.h b/Sming/Components/Storage/src/include/Storage/Device.h index b05017e069..e8d77162c2 100644 --- a/Sming/Components/Storage/src/include/Storage/Device.h +++ b/Sming/Components/Storage/src/include/Storage/Device.h @@ -50,6 +50,11 @@ class Device : public LinkedObjectTemplate { } + Device(const Device&) = delete; + Device(Device&&) = delete; + Device& operator=(const Device&) = delete; + Device& operator=(Device&&) = delete; + ~Device(); bool operator==(const String& name) const diff --git a/Sming/Components/Storage/src/include/Storage/Partition.h b/Sming/Components/Storage/src/include/Storage/Partition.h index 535b0fd4cf..1a2e4c0d0e 100644 --- a/Sming/Components/Storage/src/include/Storage/Partition.h +++ b/Sming/Components/Storage/src/include/Storage/Partition.h @@ -223,10 +223,19 @@ class Partition { } + Partition(Partition&& other) = default; + Partition(Device& device, const Info& info) : mDevice(&device), mPart(&info) { } + ~Partition() + { + } + + Partition& operator=(const Partition& other) = default; + Partition& operator=(Partition&& other) = default; + /** * @name Confirm partition is of the expected type * @{ diff --git a/Sming/Components/lwip/src/Arch/Host/Linux/lwip_arch.cpp b/Sming/Components/lwip/src/Arch/Host/Linux/lwip_arch.cpp index c8ae59f16c..a94d453f65 100644 --- a/Sming/Components/lwip/src/Arch/Host/Linux/lwip_arch.cpp +++ b/Sming/Components/lwip/src/Arch/Host/Linux/lwip_arch.cpp @@ -16,6 +16,11 @@ * If not, see . * ****/ + +// Use implementations defined in +#define lwip_htonl nthol +#define lwip_htons htons + #include "../lwip_arch.h" #include #include @@ -40,7 +45,8 @@ void getMacAddress(const char* ifname, uint8_t hwaddr[6]) return; } - struct ifreq ifr = {0}; + struct ifreq ifr { + }; ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name, ifname, IFNAMSIZ); ifr.ifr_name[IFNAMSIZ - 1] = '\0'; diff --git a/Sming/Components/malloc_count/malloc_count.cpp b/Sming/Components/malloc_count/malloc_count.cpp index f094888c72..e514ae37ea 100644 --- a/Sming/Components/malloc_count/malloc_count.cpp +++ b/Sming/Components/malloc_count/malloc_count.cpp @@ -367,7 +367,7 @@ void* operator new(size_t size) return mc_malloc(size); } -void* operator new(size_t size, const std::nothrow_t&) +void* operator new(size_t size, const std::nothrow_t&) noexcept { return mc_malloc(size); } @@ -377,7 +377,7 @@ void* operator new[](size_t size) return mc_malloc(size); } -void* operator new[](size_t size, const std::nothrow_t&) +void* operator new[](size_t size, const std::nothrow_t&) noexcept { return mc_malloc(size); } diff --git a/Sming/Core/Data/CString.h b/Sming/Core/Data/CString.h index 4335b95bc7..2c895683ff 100644 --- a/Sming/Core/Data/CString.h +++ b/Sming/Core/Data/CString.h @@ -33,6 +33,8 @@ class CString : public std::unique_ptr assign(src.get()); } + CString(CString&& other) = default; + CString(const String& src) { assign(src); @@ -43,6 +45,8 @@ class CString : public std::unique_ptr assign(src); } + ~CString() = default; + void assign(const String& src) { if(src) { @@ -74,6 +78,8 @@ class CString : public std::unique_ptr return *this; } + CString& operator=(CString&& src) = default; + CString& operator=(const String& src) { assign(src); diff --git a/Sming/Core/Data/LinkedObject.h b/Sming/Core/Data/LinkedObject.h index 7d8b25f781..303bb3e8d7 100644 --- a/Sming/Core/Data/LinkedObject.h +++ b/Sming/Core/Data/LinkedObject.h @@ -21,6 +21,12 @@ class LinkedObject { public: + LinkedObject() = default; + LinkedObject(const LinkedObject&) = default; + LinkedObject(LinkedObject&&) = default; + LinkedObject& operator=(const LinkedObject&) = default; + LinkedObject& operator=(LinkedObject&&) = default; + virtual ~LinkedObject() { } @@ -82,6 +88,15 @@ template class LinkedObjectTemplate : public LinkedObject { } + IteratorTemplate(IteratorTemplate&&) = default; + + ~IteratorTemplate() + { + } + + IteratorTemplate& operator=(const IteratorTemplate&) = default; + IteratorTemplate& operator=(IteratorTemplate&&) = default; + IteratorTemplate& operator++() { this->mObject = static_cast(this->mObject->next()); diff --git a/Sming/Core/Data/LinkedObjectList.h b/Sming/Core/Data/LinkedObjectList.h index b194efa681..c0f047b1b1 100644 --- a/Sming/Core/Data/LinkedObjectList.h +++ b/Sming/Core/Data/LinkedObjectList.h @@ -103,12 +103,12 @@ template class LinkedObjectListTemplate : public LinkedObj ObjectType* head() { - return reinterpret_cast(mHead); + return static_cast(mHead); } const ObjectType* head() const { - return reinterpret_cast(mHead); + return static_cast(mHead); } Iterator begin() @@ -153,7 +153,7 @@ template class LinkedObjectListTemplate : public LinkedObj ObjectType* pop() { - return reinterpret_cast(LinkedObjectList::pop()); + return static_cast(LinkedObjectList::pop()); } size_t count() const @@ -176,8 +176,21 @@ template class OwnedLinkedObjectListTemplate : public Link public: OwnedLinkedObjectListTemplate() = default; - OwnedLinkedObjectListTemplate(const OwnedLinkedObjectListTemplate& other) = delete; - OwnedLinkedObjectListTemplate& operator=(const OwnedLinkedObjectListTemplate& other) = delete; + OwnedLinkedObjectListTemplate(const OwnedLinkedObjectListTemplate&) = delete; + + OwnedLinkedObjectListTemplate(OwnedLinkedObjectListTemplate&& other) + { + std::swap(other.mHead, this->mHead); + } + + OwnedLinkedObjectListTemplate& operator=(const OwnedLinkedObjectListTemplate&) = delete; + + OwnedLinkedObjectListTemplate& operator=(OwnedLinkedObjectListTemplate&& other) + { + clear(); + std::swap(other.mHead, this->mHead); + return *this; + } ~OwnedLinkedObjectListTemplate() { diff --git a/Sming/Core/Data/Stream/DataSourceStream.h b/Sming/Core/Data/Stream/DataSourceStream.h index a57e12400d..8fef7842ab 100644 --- a/Sming/Core/Data/Stream/DataSourceStream.h +++ b/Sming/Core/Data/Stream/DataSourceStream.h @@ -117,7 +117,7 @@ class IDataSourceStream : public Stream * @brief Return the total length of the stream * @retval int -1 is returned when the size cannot be determined */ - virtual int available() + int available() override { return -1; } diff --git a/Sming/Core/Data/Stream/ReadWriteStream.h b/Sming/Core/Data/Stream/ReadWriteStream.h index 0cdef21026..a0056dda5d 100644 --- a/Sming/Core/Data/Stream/ReadWriteStream.h +++ b/Sming/Core/Data/Stream/ReadWriteStream.h @@ -34,7 +34,7 @@ class ReadWriteStream : public IDataSourceStream * uses this as the core output method so descendants are required * to implement it */ - virtual size_t write(const uint8_t* buffer, size_t size) = 0; + virtual size_t write(const uint8_t* buffer, size_t size) override = 0; /** @brief Copy data from a source stream * @param source Stream to read data from diff --git a/Sming/Core/Data/StreamTransformer.h b/Sming/Core/Data/StreamTransformer.h index 48050577ee..55beb3278d 100644 --- a/Sming/Core/Data/StreamTransformer.h +++ b/Sming/Core/Data/StreamTransformer.h @@ -43,7 +43,7 @@ class StreamTransformer : public IDataSourceStream return -1; } - bool isValid() const + bool isValid() const override { return sourceStream && sourceStream->isValid(); } diff --git a/Sming/Core/PolledTimer.h b/Sming/Core/PolledTimer.h index 2a85dc0cdb..8a5ce571d1 100644 --- a/Sming/Core/PolledTimer.h +++ b/Sming/Core/PolledTimer.h @@ -142,7 +142,7 @@ class Timer : public NanoTime::TimeSource */ __forceinline bool IRAM_ATTR reset(const TimeType& timeInterval) { - return resetTicks(this->template timeToTicks(timeInterval)); + return resetTicks(this->timeToTicks(timeInterval)); } /** @@ -185,7 +185,7 @@ class Timer : public NanoTime::TimeSource */ __forceinline NanoTime::Time elapsedTime() const { - return this->template ticksToTime(elapsedTicks()); + return this->ticksToTime(elapsedTicks()); } /** @@ -202,7 +202,7 @@ class Timer : public NanoTime::TimeSource */ __forceinline NanoTime::Time remainingTime() const { - return this->template ticksToTime(remainingTicks()); + return this->ticksToTime(remainingTicks()); } __forceinline bool canExpire() const diff --git a/Sming/Core/Timer.h b/Sming/Core/Timer.h index 192314dc84..0f16eb6781 100644 --- a/Sming/Core/Timer.h +++ b/Sming/Core/Timer.h @@ -138,7 +138,7 @@ template class OsTimer64Api : public CallbackTimerApi void OsTimer64Api::setInterval(TickType interval) { - constexpr auto maxTicks = osTimer.maxTicks(); + constexpr auto maxTicks = OsTimerApi::maxTicks(); if(interval > maxTicks) { // interval too large, calculate a good divider uint32_t div = (interval / (maxTicks + 1)) + 1; // integer division, intended diff --git a/Sming/Libraries/OtaUpgrade/OtaUpgrade/BasicStream.h b/Sming/Libraries/OtaUpgrade/OtaUpgrade/BasicStream.h index 880fad0653..208129144c 100644 --- a/Sming/Libraries/OtaUpgrade/OtaUpgrade/BasicStream.h +++ b/Sming/Libraries/OtaUpgrade/OtaUpgrade/BasicStream.h @@ -88,10 +88,12 @@ class BasicStream : public ReadWriteStream { return 0; } - virtual int available() override + + int available() override { return 0; } + bool isFinished() override { return true; diff --git a/Sming/Services/Profiling/MinMaxTimes.h b/Sming/Services/Profiling/MinMaxTimes.h index 74b12c1792..24016e92a2 100644 --- a/Sming/Services/Profiling/MinMaxTimes.h +++ b/Sming/Services/Profiling/MinMaxTimes.h @@ -19,22 +19,22 @@ template class MinMaxTimes : public MinMax32, public Timer NanoTime::Time getMinTime() const { - return this->template ticksToTime(getMin()); + return this->ticksToTime(getMin()); } NanoTime::Time getMaxTime() const { - return this->template ticksToTime(getMax()); + return this->ticksToTime(getMax()); } NanoTime::Time getAverageTime() const { - return this->template ticksToTime(getAverage()); + return this->ticksToTime(getAverage()); } NanoTime::Time getTotalTime() const { - return this->template ticksToTime(getTotal()); + return this->ticksToTime(getTotal()); } size_t printTo(Print& p) const diff --git a/Sming/System/include/stringutil.h b/Sming/System/include/stringutil.h index a64950f7db..efdfac1180 100644 --- a/Sming/System/include/stringutil.h +++ b/Sming/System/include/stringutil.h @@ -44,33 +44,28 @@ int strcasecmp(const char* s1, const char* s2); */ void* memmem(const void* haystack, size_t haystacklen, const void* needle, size_t needlelen); -void *memrchr(const void *s, int c, size_t n); +void* memrchr(const void* s, int c, size_t n); #endif +/** + * @brief Compare block of memory without case sensitivity + */ int memicmp(const void* buf1, const void* buf2, size_t len); -static inline char hexchar(unsigned char c) -{ - if(c < 10) - return '0' + c; - else if(c <= 15) - return 'a' + c - 10; - else - return '\0'; -} +/** + * @brief Return hex character corresponding to given value + * @param c Value from 0-15, others are invalid + * @retval char Hex character '0'-'9', 'a'-'f' or '\0' if invalid + */ +char hexchar(unsigned char c); -static inline signed char unhex(char c) -{ - if(c >= '0' && c <= '9') - return c - '0'; - else if(c >= 'a' && c <= 'f') - return 10 + c - 'a'; - else if(c >= 'A' && c <= 'F') - return 10 + c - 'A'; - else - return -1; -} +/** + * @brief Return numeric value corresponding to given hex character + * @param c Character '0'-'9', 'a'-'f' or 'A'-'F' + * @retval int8_t Numeric value or -1 if character invalid + */ +signed char unhex(char c); #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) diff --git a/Sming/System/stringutil.cpp b/Sming/System/stringutil.cpp index 9e877c6081..5266856c62 100644 --- a/Sming/System/stringutil.cpp +++ b/Sming/System/stringutil.cpp @@ -24,23 +24,16 @@ const char* strstri(const char* pString, const char* pToken) return NULL; int matchIndex = 0; - while(*pString) - { - if(tolower(*pString) == tolower(pToken[matchIndex])) - { + while(*pString) { + if(tolower(*pString) == tolower(pToken[matchIndex])) { //If we reached the end of pToken, return the match - if(pToken[matchIndex + 1] == 0) - { + if(pToken[matchIndex + 1] == 0) { return pString - matchIndex; - } - else - { + } else { ++matchIndex; } ++pString; - } - else - { + } else { //If we were in the middle of a matching process, // recheck current pString character with // the first pToken character else increase pString @@ -68,3 +61,28 @@ int memicmp(const void* buf1, const void* buf2, size_t len) return result; } + +char hexchar(unsigned char c) +{ + if(c < 10) { + return (char)('0' + c); + } + if(c <= 15) { + return (char)('a' + c - 10); + } + return '\0'; +} + +signed char unhex(char c) +{ + if(c >= '0' && c <= '9') { + return (char)(c - '0'); + } + if(c >= 'a' && c <= 'f') { + return (char)(10 + c - 'a'); + } + if(c >= 'A' && c <= 'F') { + return (char)(10 + c - 'A'); + } + return -1; +} diff --git a/Sming/Wiring/Countable.h b/Sming/Wiring/Countable.h index 18b2ea87f4..ddd98204ef 100644 --- a/Sming/Wiring/Countable.h +++ b/Sming/Wiring/Countable.h @@ -19,6 +19,15 @@ template class Countable { public: + Countable() + { + } + + Countable(const Countable&) = delete; + Countable(Countable&&) = delete; + Countable& operator=(const Countable&) = delete; + Countable& operator=(Countable&&) = delete; + virtual ~Countable() { } diff --git a/Sming/Wiring/Print.h b/Sming/Wiring/Print.h index f9ca622aee..9b30383ee8 100644 --- a/Sming/Wiring/Print.h +++ b/Sming/Wiring/Print.h @@ -36,10 +36,20 @@ class Print { public: + Print() + { + } + + Print(const Print&) = delete; + Print(Print&&) = delete; + virtual ~Print() { } + Print& operator=(const Print&) = delete; + Print& operator=(Print&&) = delete; + /** @brief Gets last error @retval int Error number of last write error */ diff --git a/Sming/Wiring/Printable.h b/Sming/Wiring/Printable.h index f538398189..c9252d82db 100644 --- a/Sming/Wiring/Printable.h +++ b/Sming/Wiring/Printable.h @@ -42,6 +42,15 @@ class Print; class Printable { public: + Printable() + { + } + + Printable(const Printable&) = delete; + Printable(Printable&&) = delete; + Printable& operator=(const Printable&) = delete; + Printable& operator=(Printable&&) = delete; + virtual ~Printable() { } diff --git a/Sming/Wiring/WString.h b/Sming/Wiring/WString.h index 054065b1bd..4bb17c3f2d 100644 --- a/Sming/Wiring/WString.h +++ b/Sming/Wiring/WString.h @@ -135,6 +135,7 @@ using flash_string_t = const __FlashStringHelper*; */ class String { +protected: // use a function pointer to allow for "if (s)" without the // complications of an operator bool(). for more information, see: // http://www.artima.com/cppsource/safebool.html @@ -191,19 +192,19 @@ class String String(StringSumHelper&& rval) noexcept; #endif explicit String(char c); - explicit String(unsigned char, unsigned char base = 10, unsigned char width = 0, char pad = '0'); - explicit String(int num, unsigned char base = 10, unsigned char width = 0, char pad = '0') + explicit String(unsigned char, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); + explicit String(int num, unsigned char base = DEC, unsigned char width = 0, char pad = '0') : String(long(num), base, width, pad) { } - explicit String(unsigned int num, unsigned char base = 10, unsigned char width = 0, char pad = '0') + explicit String(unsigned int num, unsigned char base = DEC, unsigned char width = 0, char pad = '0') : String((unsigned long)(num), base, width, pad) { } - explicit String(long, unsigned char base = 10, unsigned char width = 0, char pad = '0'); - explicit String(long long, unsigned char base = 10, unsigned char width = 0, char pad = '0'); - explicit String(unsigned long, unsigned char base = 10, unsigned char width = 0, char pad = '0'); - explicit String(unsigned long long, unsigned char base = 10, unsigned char width = 0, char pad = '0'); + explicit String(long, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); + explicit String(long long, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); + explicit String(unsigned long, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); + explicit String(unsigned long long, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); explicit String(float, unsigned char decimalPlaces = 2); explicit String(double, unsigned char decimalPlaces = 2); /** @} */ @@ -331,19 +332,19 @@ class String { return concat(&c, 1); } - bool concat(unsigned char num, unsigned char base = 10, unsigned char width = 0, char pad = '0'); - bool concat(int num, unsigned char base = 10, unsigned char width = 0, char pad = '0') + bool concat(unsigned char num, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); + bool concat(int num, unsigned char base = DEC, unsigned char width = 0, char pad = '0') { return concat(long(num), base, width, pad); } - bool concat(unsigned int num, unsigned char base = 10, unsigned char width = 0, char pad = '0') + bool concat(unsigned int num, unsigned char base = DEC, unsigned char width = 0, char pad = '0') { return concat((unsigned long)(num), base, width, pad); } - bool concat(long num, unsigned char base = 10, unsigned char width = 0, char pad = '0'); - bool concat(long long num, unsigned char base = 10, unsigned char width = 0, char pad = '0'); - bool concat(unsigned long num, unsigned char base = 10, unsigned char width = 0, char pad = '0'); - bool concat(unsigned long long num, unsigned char base = 10, unsigned char width = 0, char pad = '0'); + bool concat(long num, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); + bool concat(long long num, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); + bool concat(unsigned long num, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); + bool concat(unsigned long long num, unsigned char base = DEC, unsigned char width = 0, char pad = '0'); bool concat(float num); bool concat(double num); @@ -787,7 +788,7 @@ class String */ String& padLeft(uint16_t minWidth, char c = ' ') { - return pad(-minWidth, c); + return pad(int16_t(-minWidth), c); } /** @@ -795,7 +796,7 @@ class String */ String& padRight(uint16_t minWidth, char c = ' ') { - return pad(minWidth, c); + return pad(int16_t(minWidth), c); } /** diff --git a/Sming/Wiring/WVector.h b/Sming/Wiring/WVector.h index eb2f97a493..425b951ea4 100644 --- a/Sming/Wiring/WVector.h +++ b/Sming/Wiring/WVector.h @@ -46,11 +46,18 @@ template class Vector : public Countable using E = typename std::conditional::type; Iterator(const Iterator&) = default; + Iterator(Iterator&&) = default; + Iterator& operator=(const Iterator&) = default; + Iterator& operator=(Iterator&&) = default; Iterator(V& vector, unsigned index) : vector(vector), index(index) { } + ~Iterator() + { + } + Iterator& operator++() { ++index; @@ -96,7 +103,6 @@ template class Vector : public Countable unsigned index{0}; }; - // constructors Vector(unsigned int initialCapacity = 10, unsigned int capacityIncrement = 10) : _increment(capacityIncrement) { _data.allocate(initialCapacity); @@ -107,6 +113,12 @@ template class Vector : public Countable copyFrom(rhv); } + Vector(Vector&&) = delete; + + ~Vector() + { + } + // methods unsigned int capacity() const { @@ -238,7 +250,7 @@ template class Vector : public Countable return _data[index]; } - const Vector& operator=(const Vector& rhv) + Vector& operator=(const Vector& rhv) { if(this != &rhv) { copyFrom(rhv); @@ -246,7 +258,7 @@ template class Vector : public Countable return *this; } - const Vector& operator=(Vector&& other) noexcept // move assignment + Vector& operator=(Vector&& other) noexcept // move assignment { clear(); _increment = 0; @@ -320,7 +332,7 @@ template template int Vector::indexOf(cons { for(unsigned int i = 0; i < _size; i++) { if(_data[i] == elem) { - return i; + return int(i); } } @@ -339,7 +351,7 @@ template template int Vector::lastIndexOf( do { i--; if(_data[i] == elem) { - return i; + return int(i); } } while(i != 0); @@ -436,7 +448,7 @@ template void Vector::sort(Comparer compareFunction) Element& keyRef = _data[j]; // Smaller values move up int i; - for(i = j - 1; (i >= 0) && compareFunction(_data[i], keyRef) > 0; i--) { + for(i = int(j) - 1; (i >= 0) && compareFunction(_data[i], keyRef) > 0; i--) { _data.values[i + 1] = _data.values[i]; } // Put key into its proper location diff --git a/Sming/Wiring/WiringList.h b/Sming/Wiring/WiringList.h index d799215cc4..7110ad6f1b 100644 --- a/Sming/Wiring/WiringList.h +++ b/Sming/Wiring/WiringList.h @@ -19,6 +19,15 @@ template struct ScalarList { T* values{nullptr}; size_t size{0}; + ScalarList() + { + } + + ScalarList(const ScalarList&) = delete; + ScalarList(ScalarList&&) = default; + ScalarList& operator=(const ScalarList&) = delete; + ScalarList& operator=(ScalarList&&) = delete; + ~ScalarList() { clear(); @@ -67,7 +76,7 @@ template struct ScalarList { const T& operator[](unsigned index) const { - return const_cast(*this)[index]; + return values[index]; } }; @@ -99,6 +108,12 @@ template struct ObjectList : public ScalarList { } }; + ObjectList() = default; + ObjectList(const ObjectList&) = delete; + ObjectList(ObjectList&&) = default; + ObjectList& operator=(const ObjectList&) = delete; + ObjectList& operator=(ObjectList&&) = delete; + ~ObjectList() { clear(); diff --git a/tests/HostTests/modules/DateTime.cpp b/tests/HostTests/modules/DateTime.cpp index 738adf564a..5f262a8c0d 100644 --- a/tests/HostTests/modules/DateTime.cpp +++ b/tests/HostTests/modules/DateTime.cpp @@ -55,8 +55,11 @@ class DateTimeTest : public TestGroup unsigned count = checkSetTime(VALID_HTTP_DATE); count += checkSetTime(VALID_ISO_DATETIME); auto elapsed = timer.elapsedTime(); - Serial << "Checked " << count << " dates in " << elapsed.toString() << ", " << elapsed / count - << " per date" << endl; + Serial << "Checked " << count << " dates in " << elapsed.toString(); + if(count != 0) { + Serial << ", " << elapsed / count << " per date"; + } + Serial << endl; } TEST_CASE("getMonthDays") diff --git a/tests/HostTests/modules/Files.cpp b/tests/HostTests/modules/Files.cpp index ed25524c7f..7f5ad4d131 100644 --- a/tests/HostTests/modules/Files.cpp +++ b/tests/HostTests/modules/Files.cpp @@ -16,46 +16,48 @@ class FilesTest : public TestGroup DEFINE_FSTR_LOCAL(testFileName, "test.txt"); int res, pos, size; - FileHandle file{-1}; - TEST_CASE("Initial position and size") { - res = fileSetContent(testFileName, testContent); - debug_i("fileSetContent() returned %d", res); - REQUIRE(size_t(res) == testContent.length()); - file = fileOpen(testFileName, File::ReadWrite); - size = fileSeek(file, 0, SeekOrigin::End); - pos = fileSeek(file, 100, SeekOrigin::Start); - debug_i("pos = %d, size = %d", pos, size); - REQUIRE(pos == 100); - REQUIRE(size_t(size) == testContent.length()); - } - - TEST_CASE("Reduce file sizes") - { - res = fileTruncate(file, 555); - pos = fileTell(file); - size = fileSeek(file, 0, SeekOrigin::End); - debug_i("res = %d, pos = %d, size = %d", res, pos, size); - REQUIRE(res == 0); - REQUIRE(pos == 100); - REQUIRE(size == 555); - } - - TEST_CASE("Increase file size") - { - res = fileTruncate(file, 12345); - size = fileSeek(file, 0, SeekOrigin::End); - debug_i("res = %d, size = %d", res, size); - REQUIRE(res < 0); - REQUIRE(size == 555); - } - - TEST_CASE("Close file") - { - fileClose(file); - REQUIRE(fileTell(file) < 0); - file = -1; + FileHandle file{-1}; + + TEST_CASE("Initial position and size") + { + res = fileSetContent(testFileName, testContent); + debug_i("fileSetContent() returned %d", res); + REQUIRE(size_t(res) == testContent.length()); + file = fileOpen(testFileName, File::ReadWrite); + size = fileSeek(file, 0, SeekOrigin::End); + pos = fileSeek(file, 100, SeekOrigin::Start); + debug_i("pos = %d, size = %d", pos, size); + REQUIRE(pos == 100); + REQUIRE(size_t(size) == testContent.length()); + } + + TEST_CASE("Reduce file sizes") + { + res = fileTruncate(file, 555); + pos = fileTell(file); + size = fileSeek(file, 0, SeekOrigin::End); + debug_i("res = %d, pos = %d, size = %d", res, pos, size); + REQUIRE(res == 0); + REQUIRE(pos == 100); + REQUIRE(size == 555); + } + + TEST_CASE("Increase file size") + { + res = fileTruncate(file, 12345); + size = fileSeek(file, 0, SeekOrigin::End); + debug_i("res = %d, size = %d", res, size); + REQUIRE(res < 0); + REQUIRE(size == 555); + } + + TEST_CASE("Close file") + { + fileClose(file); + REQUIRE(fileTell(file) < 0); + } } TEST_CASE("fileGetSize") diff --git a/tests/HostTests/modules/Stream.cpp b/tests/HostTests/modules/Stream.cpp index 20199bb51e..9781e7f993 100644 --- a/tests/HostTests/modules/Stream.cpp +++ b/tests/HostTests/modules/Stream.cpp @@ -108,7 +108,7 @@ class StreamTest : public TestGroup TEST_CASE("MultipartStream / MultiStream") { unsigned itemIndex{0}; - constexpr const FlashString* items[]{ + const FlashString* items[]{ &template1, &template1_1, &template1_2, &template2, &template2_1, }; MultipartStream multi([&]() -> MultipartStream::BodyPart { diff --git a/tests/HostTests/modules/TemplateStream.cpp b/tests/HostTests/modules/TemplateStream.cpp index 3f325130e7..703d067a9e 100644 --- a/tests/HostTests/modules/TemplateStream.cpp +++ b/tests/HostTests/modules/TemplateStream.cpp @@ -109,7 +109,7 @@ class TemplateStreamTest : public TestGroup SectionTemplate tmpl(new FlashMemoryStream(Resource::ut_template1_in_rst)); REQUIRE(tmpl.sectionCount() == 1); tmpl.setDoubleBraces(true); - tmpl.onGetValue([&tmpl](const char* name) -> String { + tmpl.onGetValue([](const char* name) -> String { debug_e("getValue(%s)", name); if(FS("emit_contents") == name) { return "1"; @@ -174,7 +174,6 @@ class TemplateStreamTest : public TestGroup } tmpl.seek(read); outlen += read; - ptr += read; } String expected; diff --git a/tests/HostTests/modules/Wiring.cpp b/tests/HostTests/modules/Wiring.cpp index 647eccc88a..b83b31e188 100644 --- a/tests/HostTests/modules/Wiring.cpp +++ b/tests/HostTests/modules/Wiring.cpp @@ -93,7 +93,7 @@ class WiringTest : public TestGroup Serial.println(); using Func = Delegate; - auto time = [this](const String& description, Func function) { + auto time = [](const String& description, Func function) { Serial << description << " ..." << endl; TestMap map; fillMap(map);