Replace nlSTATIC_ASSERT_PRINT with static_assert (#36075)
* Replace nlSTATIC_ASSERT_PRINT with static_assert
* Remove unnecessary includes
diff --git a/src/inet/InetFaultInjection.cpp b/src/inet/InetFaultInjection.cpp
index faf0b42..7b21e06 100644
--- a/src/inet/InetFaultInjection.cpp
+++ b/src/inet/InetFaultInjection.cpp
@@ -23,8 +23,6 @@
#include "InetFaultInjection.h"
-#include <nlassert.h>
-
namespace chip {
namespace Inet {
namespace FaultInjection {
diff --git a/src/lib/core/CHIPSafeCasts.h b/src/lib/core/CHIPSafeCasts.h
index 9d189fe..8720804 100644
--- a/src/lib/core/CHIPSafeCasts.h
+++ b/src/lib/core/CHIPSafeCasts.h
@@ -26,7 +26,6 @@
#pragma once
#include <limits.h>
-#include <nlassert.h>
#include <stdint.h>
namespace chip {
@@ -42,7 +41,7 @@
*/
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<uint8_t *>(in);
#else
@@ -59,7 +58,7 @@
*/
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<const uint8_t *>(in);
#else
@@ -76,7 +75,7 @@
*/
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<uint8_t *>(in);
#else
@@ -93,7 +92,7 @@
*/
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<const uint8_t *>(in);
#else
@@ -110,7 +109,7 @@
*/
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<unsigned char *>(in);
#else
@@ -127,7 +126,7 @@
*/
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<const unsigned char *>(in);
#else
@@ -144,7 +143,7 @@
*/
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<char *>(in);
#else
@@ -161,7 +160,7 @@
*/
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<const char *>(in);
#else
diff --git a/src/lib/support/BytesCircularBuffer.cpp b/src/lib/support/BytesCircularBuffer.cpp
index b0eba36..89e89f1 100644
--- a/src/lib/support/BytesCircularBuffer.cpp
+++ b/src/lib/support/BytesCircularBuffer.cpp
@@ -20,7 +20,6 @@
#include <algorithm>
#include <limits>
-#include <nlassert.h>
#include <string.h>
#include <lib/support/CodeUtils.h>
diff --git a/src/lib/support/CHIPFaultInjection.cpp b/src/lib/support/CHIPFaultInjection.cpp
index b7ac95e..8b7df7a 100644
--- a/src/lib/support/CHIPFaultInjection.cpp
+++ b/src/lib/support/CHIPFaultInjection.cpp
@@ -22,8 +22,6 @@
*/
#include "CHIPFaultInjection.h"
-#include <nlassert.h>
-
#include <string.h>
namespace chip {
diff --git a/src/lib/support/PersistentStorageMacros.h b/src/lib/support/PersistentStorageMacros.h
index 986686d..91e3b61 100644
--- a/src/lib/support/PersistentStorageMacros.h
+++ b/src/lib/support/PersistentStorageMacros.h
@@ -33,10 +33,10 @@
do \
{ \
constexpr size_t len = std::extent<decltype(keyPrefix)>::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 1154409..5313956 100644
--- a/src/system/SystemFaultInjection.cpp
+++ b/src/system/SystemFaultInjection.cpp
@@ -25,7 +25,6 @@
/* module header, also carries config, comes first */
#include <system/SystemFaultInjection.h>
-#include <nlassert.h>
#include <string.h>
namespace chip {