Skip to content

Commit 064c205

Browse files
authored
Replace nlSTATIC_ASSERT_PRINT with static_assert (project-chip#36075)
* Replace nlSTATIC_ASSERT_PRINT with static_assert * Remove unnecessary includes
1 parent 8a08d57 commit 064c205

6 files changed

+10
-17
lines changed

src/inet/InetFaultInjection.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
#include "InetFaultInjection.h"
2525

26-
#include <nlassert.h>
27-
2826
namespace chip {
2927
namespace Inet {
3028
namespace FaultInjection {

src/lib/core/CHIPSafeCasts.h

+8-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#pragma once
2727

2828
#include <limits.h>
29-
#include <nlassert.h>
3029
#include <stdint.h>
3130

3231
namespace chip {
@@ -42,7 +41,7 @@ namespace Uint8 {
4241
*/
4342
inline uint8_t * from_uchar(unsigned char * in)
4443
{
45-
nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast unsigned char array as uint8_t array");
44+
static_assert(CHAR_BIT == 8, "Can't type cast unsigned char array as uint8_t array");
4645
#ifdef __cplusplus
4746
return reinterpret_cast<uint8_t *>(in);
4847
#else
@@ -59,7 +58,7 @@ inline uint8_t * from_uchar(unsigned char * in)
5958
*/
6059
inline const uint8_t * from_const_uchar(const unsigned char * in)
6160
{
62-
nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast unsigned char array as uint8_t array");
61+
static_assert(CHAR_BIT == 8, "Can't type cast unsigned char array as uint8_t array");
6362
#ifdef __cplusplus
6463
return reinterpret_cast<const uint8_t *>(in);
6564
#else
@@ -76,7 +75,7 @@ inline const uint8_t * from_const_uchar(const unsigned char * in)
7675
*/
7776
inline uint8_t * from_char(char * in)
7877
{
79-
nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast char array as uint8_t array");
78+
static_assert(CHAR_BIT == 8, "Can't type cast char array as uint8_t array");
8079
#ifdef __cplusplus
8180
return reinterpret_cast<uint8_t *>(in);
8281
#else
@@ -93,7 +92,7 @@ inline uint8_t * from_char(char * in)
9392
*/
9493
inline const uint8_t * from_const_char(const char * in)
9594
{
96-
nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast char array as uint8_t array");
95+
static_assert(CHAR_BIT == 8, "Can't type cast char array as uint8_t array");
9796
#ifdef __cplusplus
9897
return reinterpret_cast<const uint8_t *>(in);
9998
#else
@@ -110,7 +109,7 @@ inline const uint8_t * from_const_char(const char * in)
110109
*/
111110
inline unsigned char * to_uchar(uint8_t * in)
112111
{
113-
nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast uint8_t array to unsigned char array");
112+
static_assert(CHAR_BIT == 8, "Can't type cast uint8_t array to unsigned char array");
114113
#ifdef __cplusplus
115114
return reinterpret_cast<unsigned char *>(in);
116115
#else
@@ -127,7 +126,7 @@ inline unsigned char * to_uchar(uint8_t * in)
127126
*/
128127
inline const unsigned char * to_const_uchar(const uint8_t * in)
129128
{
130-
nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast uint8_t array to unsigned char array");
129+
static_assert(CHAR_BIT == 8, "Can't type cast uint8_t array to unsigned char array");
131130
#ifdef __cplusplus
132131
return reinterpret_cast<const unsigned char *>(in);
133132
#else
@@ -144,7 +143,7 @@ inline const unsigned char * to_const_uchar(const uint8_t * in)
144143
*/
145144
inline char * to_char(uint8_t * in)
146145
{
147-
nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast uint8_t array to char array");
146+
static_assert(CHAR_BIT == 8, "Can't type cast uint8_t array to char array");
148147
#ifdef __cplusplus
149148
return reinterpret_cast<char *>(in);
150149
#else
@@ -161,7 +160,7 @@ inline char * to_char(uint8_t * in)
161160
*/
162161
inline const char * to_const_char(const uint8_t * in)
163162
{
164-
nlSTATIC_ASSERT_PRINT(CHAR_BIT == 8, "Can't type cast uint8_t array to char array");
163+
static_assert(CHAR_BIT == 8, "Can't type cast uint8_t array to char array");
165164
#ifdef __cplusplus
166165
return reinterpret_cast<const char *>(in);
167166
#else

src/lib/support/BytesCircularBuffer.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include <algorithm>
2222
#include <limits>
23-
#include <nlassert.h>
2423
#include <string.h>
2524

2625
#include <lib/support/CodeUtils.h>

src/lib/support/CHIPFaultInjection.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*/
2323
#include "CHIPFaultInjection.h"
2424

25-
#include <nlassert.h>
26-
2725
#include <string.h>
2826

2927
namespace chip {

src/lib/support/PersistentStorageMacros.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ namespace chip {
3333
do \
3434
{ \
3535
constexpr size_t len = std::extent<decltype(keyPrefix)>::value; \
36-
nlSTATIC_ASSERT_PRINT(len > 0, "keyPrefix length must be known at compile time"); \
36+
static_assert(len > 0, "keyPrefix length must be known at compile time"); \
3737
/* 2 * sizeof(chip::NodeId) to accommodate 2 character for each byte in Node Id */ \
3838
char key[len + 2 * sizeof(chip::NodeId) + 1]; \
39-
nlSTATIC_ASSERT_PRINT(sizeof(node) <= sizeof(uint64_t), "Node ID size is greater than expected"); \
39+
static_assert(sizeof(node) <= sizeof(uint64_t), "Node ID size is greater than expected"); \
4040
/* Be careful about switching to ChipLogFormatX64: it would change the storage keys! */ \
4141
snprintf(key, sizeof(key), "%s%" PRIx64, keyPrefix, node); \
4242
action; \

src/system/SystemFaultInjection.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
/* module header, also carries config, comes first */
2626
#include <system/SystemFaultInjection.h>
2727

28-
#include <nlassert.h>
2928
#include <string.h>
3029

3130
namespace chip {

0 commit comments

Comments
 (0)