From 064c2050ea04a381e4340090b0fbac38df10f6d5 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Tue, 15 Oct 2024 19:28:51 +0200 Subject: [PATCH] Replace nlSTATIC_ASSERT_PRINT with static_assert (#36075) * Replace nlSTATIC_ASSERT_PRINT with static_assert * Remove unnecessary includes --- src/inet/InetFaultInjection.cpp | 2 -- src/lib/core/CHIPSafeCasts.h | 17 ++++++++--------- src/lib/support/BytesCircularBuffer.cpp | 1 - src/lib/support/CHIPFaultInjection.cpp | 2 -- src/lib/support/PersistentStorageMacros.h | 4 ++-- src/system/SystemFaultInjection.cpp | 1 - 6 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/inet/InetFaultInjection.cpp b/src/inet/InetFaultInjection.cpp index faf0b42176..7b21e06c33 100644 --- a/src/inet/InetFaultInjection.cpp +++ b/src/inet/InetFaultInjection.cpp @@ -23,8 +23,6 @@ #include "InetFaultInjection.h" -#include - namespace chip { namespace Inet { namespace FaultInjection { diff --git a/src/lib/core/CHIPSafeCasts.h b/src/lib/core/CHIPSafeCasts.h index 9d189feeb6..872080415d 100644 --- a/src/lib/core/CHIPSafeCasts.h +++ b/src/lib/core/CHIPSafeCasts.h @@ -26,7 +26,6 @@ #pragma once #include -#include #include namespace chip { @@ -42,7 +41,7 @@ namespace Uint8 { */ inline uint8_t * from_uchar(unsigned char * in) { - nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast unsigned char array as uint8_t array"); + static_assert(CHAR_BIT == 8, "Can't type cast unsigned char array as uint8_t array"); #ifdef __cplusplus return reinterpret_cast(in); #else @@ -59,7 +58,7 @@ inline uint8_t * from_uchar(unsigned char * in) */ inline const uint8_t * from_const_uchar(const unsigned char * in) { - nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast unsigned char array as uint8_t array"); + static_assert(CHAR_BIT == 8, "Can't type cast unsigned char array as uint8_t array"); #ifdef __cplusplus return reinterpret_cast(in); #else @@ -76,7 +75,7 @@ inline const uint8_t * from_const_uchar(const unsigned char * in) */ inline uint8_t * from_char(char * in) { - nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast char array as uint8_t array"); + static_assert(CHAR_BIT == 8, "Can't type cast char array as uint8_t array"); #ifdef __cplusplus return reinterpret_cast(in); #else @@ -93,7 +92,7 @@ inline uint8_t * from_char(char * in) */ inline const uint8_t * from_const_char(const char * in) { - nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast char array as uint8_t array"); + static_assert(CHAR_BIT == 8, "Can't type cast char array as uint8_t array"); #ifdef __cplusplus return reinterpret_cast(in); #else @@ -110,7 +109,7 @@ inline const uint8_t * from_const_char(const char * in) */ inline unsigned char * to_uchar(uint8_t * in) { - nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast uint8_t array to unsigned char array"); + static_assert(CHAR_BIT == 8, "Can't type cast uint8_t array to unsigned char array"); #ifdef __cplusplus return reinterpret_cast(in); #else @@ -127,7 +126,7 @@ inline unsigned char * to_uchar(uint8_t * in) */ inline const unsigned char * to_const_uchar(const uint8_t * in) { - nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast uint8_t array to unsigned char array"); + static_assert(CHAR_BIT == 8, "Can't type cast uint8_t array to unsigned char array"); #ifdef __cplusplus return reinterpret_cast(in); #else @@ -144,7 +143,7 @@ inline const unsigned char * to_const_uchar(const uint8_t * in) */ inline char * to_char(uint8_t * in) { - nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast uint8_t array to char array"); + static_assert(CHAR_BIT == 8, "Can't type cast uint8_t array to char array"); #ifdef __cplusplus return reinterpret_cast(in); #else @@ -161,7 +160,7 @@ inline char * to_char(uint8_t * in) */ inline const char * to_const_char(const uint8_t * in) { - nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast uint8_t array to char array"); + static_assert(CHAR_BIT == 8, "Can't type cast uint8_t array to char array"); #ifdef __cplusplus return reinterpret_cast(in); #else diff --git a/src/lib/support/BytesCircularBuffer.cpp b/src/lib/support/BytesCircularBuffer.cpp index b0eba36430..89e89f1770 100644 --- a/src/lib/support/BytesCircularBuffer.cpp +++ b/src/lib/support/BytesCircularBuffer.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include diff --git a/src/lib/support/CHIPFaultInjection.cpp b/src/lib/support/CHIPFaultInjection.cpp index b7ac95eea1..8b7df7ace9 100644 --- a/src/lib/support/CHIPFaultInjection.cpp +++ b/src/lib/support/CHIPFaultInjection.cpp @@ -22,8 +22,6 @@ */ #include "CHIPFaultInjection.h" -#include - #include namespace chip { diff --git a/src/lib/support/PersistentStorageMacros.h b/src/lib/support/PersistentStorageMacros.h index 986686d9fa..91e3b61e67 100644 --- a/src/lib/support/PersistentStorageMacros.h +++ b/src/lib/support/PersistentStorageMacros.h @@ -33,10 +33,10 @@ namespace chip { do \ { \ constexpr size_t len = std::extent::value; \ - nlSTATIC_ASSERT_PRINT(len > 0, "keyPrefix length must be known at compile time"); \ + static_assert(len > 0, "keyPrefix length must be known at compile time"); \ /* 2 * sizeof(chip::NodeId) to accommodate 2 character for each byte in Node Id */ \ char key[len + 2 * sizeof(chip::NodeId) + 1]; \ - nlSTATIC_ASSERT_PRINT(sizeof(node) <= sizeof(uint64_t), "Node ID size is greater than expected"); \ + static_assert(sizeof(node) <= sizeof(uint64_t), "Node ID size is greater than expected"); \ /* Be careful about switching to ChipLogFormatX64: it would change the storage keys! */ \ snprintf(key, sizeof(key), "%s%" PRIx64, keyPrefix, node); \ action; \ diff --git a/src/system/SystemFaultInjection.cpp b/src/system/SystemFaultInjection.cpp index 1154409674..531395694c 100644 --- a/src/system/SystemFaultInjection.cpp +++ b/src/system/SystemFaultInjection.cpp @@ -25,7 +25,6 @@ /* module header, also carries config, comes first */ #include -#include #include namespace chip {