mirror of
https://github.com/espressif/openthread.git
synced 2026-09-08 18:20:06 +00:00
[diag] check buffer size definition (#3541)
This commit is contained in:
+13
-1
@@ -36,17 +36,19 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
#include <openthread/cli.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
|
||||
#include "cli/cli.hpp"
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/encoding.hpp"
|
||||
#include "common/logging.hpp"
|
||||
#include "common/new.hpp"
|
||||
#include "common/tasklet.hpp"
|
||||
#include "utils/static_assert.hpp"
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
|
||||
#include <openthread/platform/debug_uart.h>
|
||||
@@ -84,6 +86,16 @@
|
||||
|
||||
#endif // OT_CLI_UART_LOCK_HDR_FILE
|
||||
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE,
|
||||
"diag output buffer should be smaller than CLI UART tx buffer");
|
||||
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE <= OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE,
|
||||
"diag command line should be smaller than CLI UART rx buffer");
|
||||
#endif
|
||||
|
||||
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH <= OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE,
|
||||
"command line should be should be smaller than CLI rx buffer");
|
||||
|
||||
namespace ot {
|
||||
namespace Cli {
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ template <> struct StaticAssertError<true>
|
||||
|
||||
} // namespace ot
|
||||
|
||||
#define __OT_STATIC_ASSERT_ERROR(aError, aLine) aError##aLine
|
||||
#define _OT_STATIC_ASSERT_ERROR(aLine) __OT_STATIC_ASSERT_ERROR(StaticAssertError, aLine)
|
||||
|
||||
/**
|
||||
* This macro does static assert.
|
||||
*
|
||||
@@ -53,10 +56,10 @@ template <> struct StaticAssertError<true>
|
||||
* @param[in] aMessage A message to describe what is wrong when @p aExpression is false.
|
||||
*
|
||||
*/
|
||||
#define OT_STATIC_ASSERT(aExpression, aMessage) \
|
||||
enum \
|
||||
{ \
|
||||
StaticAssertError##__LINE__ = sizeof(ot::StaticAssertError<(aExpression) != 0>(aMessage)), \
|
||||
#define OT_STATIC_ASSERT(aExpression, aMessage) \
|
||||
enum \
|
||||
{ \
|
||||
_OT_STATIC_ASSERT_ERROR(__COUNTER__) = sizeof(ot::StaticAssertError<(aExpression) != 0>(aMessage)), \
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "ncp/ncp_buffer.hpp"
|
||||
#include "ncp/spinel_decoder.hpp"
|
||||
#include "ncp/spinel_encoder.hpp"
|
||||
#include "utils/static_assert.hpp"
|
||||
|
||||
#include "spinel.h"
|
||||
|
||||
@@ -397,6 +398,9 @@ protected:
|
||||
otError HandlePropertySet_SPINEL_PROP_HOST_POWER_STATE(uint8_t aHeader);
|
||||
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_TX_BUFFER_SIZE,
|
||||
"diag output buffer should be smaller than NCP UART tx buffer");
|
||||
|
||||
otError HandlePropertySet_SPINEL_PROP_NEST_STREAM_MFG(uint8_t aHeader);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -42,9 +42,17 @@
|
||||
#include "common/instance.hpp"
|
||||
#include "common/new.hpp"
|
||||
#include "net/ip6.hpp"
|
||||
#include "utils/static_assert.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_NCP_SPI
|
||||
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE,
|
||||
"diag output should be smaller than NCP SPI tx buffer");
|
||||
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE,
|
||||
"diag command line should be smaller than NCP SPI rx buffer");
|
||||
#endif
|
||||
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
|
||||
|
||||
@@ -45,9 +45,15 @@
|
||||
#include "common/instance.hpp"
|
||||
#include "common/new.hpp"
|
||||
#include "net/ip6.hpp"
|
||||
#include "utils/static_assert.hpp"
|
||||
|
||||
#if OPENTHREAD_ENABLE_NCP_UART
|
||||
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
OT_STATIC_ASSERT(OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_UART_RX_BUFFER_SIZE,
|
||||
"diag command line should be smaller than NCP UART rx buffer");
|
||||
#endif
|
||||
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user