mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[build] add format-nonliteral to missed code (#12251)
This commit enables the format-nonliteral check for code missed in `#12236`. This commit also enables the format-nonliteral warnings in CMake to catch such warnings in future in CMake build.
This commit is contained in:
+2
-2
@@ -92,8 +92,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
|
||||
endif()
|
||||
|
||||
set(OT_CFLAGS
|
||||
$<$<COMPILE_LANGUAGE:C>:${OT_CFLAGS} -Wall -Wextra -Wshadow>
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${OT_CFLAGS} -Wall -Wextra -Wshadow -Wno-c++14-compat -fno-exceptions>
|
||||
$<$<COMPILE_LANGUAGE:C>:${OT_CFLAGS} -Wall -Wformat-nonliteral -Wextra -Wshadow>
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${OT_CFLAGS} -Wall -Wformat-nonliteral -Wextra -Wshadow -Wno-c++14-compat -fno-exceptions>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-Wc99-extensions>
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <openthread-system.h>
|
||||
#include <openthread/cli.h>
|
||||
#include <openthread/logging.h>
|
||||
#include <openthread/platform/debug_uart.h>
|
||||
|
||||
#include "cli/cli_config.h"
|
||||
#include "common/code_utils.hpp"
|
||||
@@ -221,7 +222,7 @@ static void Send(void)
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
|
||||
/* duplicate the output to the debug uart */
|
||||
otSysDebugUart_write_bytes(reinterpret_cast<uint8_t *>(sTxBuffer + sTxHead), sSendLength);
|
||||
otPlatDebugUart_write_bytes(reinterpret_cast<uint8_t *>(sTxBuffer + sTxHead), sSendLength);
|
||||
#endif
|
||||
IgnoreError(otPlatUartSend(reinterpret_cast<uint8_t *>(sTxBuffer + sTxHead), sSendLength));
|
||||
}
|
||||
|
||||
@@ -47,6 +47,10 @@ if(OT_RTT_UART)
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_options(openthread-platform-utils PRIVATE
|
||||
${OT_CFLAGS}
|
||||
)
|
||||
|
||||
target_include_directories(openthread-platform-utils PRIVATE
|
||||
${OT_PUBLIC_INCLUDES}
|
||||
$<TARGET_PROPERTY:ot-config,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
|
||||
@@ -124,7 +124,8 @@ void utilsLogRttDeinit(void);
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ap va_list matching information for aFormat
|
||||
*/
|
||||
void utilsLogRttOutput(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list ap);
|
||||
void utilsLogRttOutput(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list ap)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(3, 0);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
@@ -383,6 +383,7 @@ void otMacFrameUpdateTimeIe(otRadioFrame *aFrame, uint64_t aRadioTime, otRadioCo
|
||||
uint8_t *timeIe;
|
||||
uint64_t time;
|
||||
|
||||
OT_UNUSED_VARIABLE(aRadioContext);
|
||||
VerifyOrExit((aFrame->mInfo.mTxInfo.mIeInfo != nullptr) && (aFrame->mInfo.mTxInfo.mIeInfo->mTimeIeOffset != 0));
|
||||
|
||||
timeIe = aFrame->mPsdu + aFrame->mInfo.mTxInfo.mIeInfo->mTimeIeOffset;
|
||||
@@ -434,7 +435,6 @@ bool otMacFrameSrcAddrMatchCslReceiverPeer(const otRadioFrame *aFrame, const otR
|
||||
break;
|
||||
|
||||
case Mac::Address::kTypeExtended:
|
||||
VerifyOrExit(*reinterpret_cast<const uint64_t *>(aRadioContext->mCslExtAddress.m8) != 0);
|
||||
VerifyOrExit(src.GetExtended() == *static_cast<const Mac::ExtAddress *>(&aRadioContext->mCslExtAddress));
|
||||
matches = true;
|
||||
break;
|
||||
|
||||
@@ -43,6 +43,10 @@ using namespace ot;
|
||||
#if OPENTHREAD_CONFIG_OTNS_ENABLE
|
||||
|
||||
OT_TOOL_WEAK
|
||||
void otPlatOtnsStatus(const char *aStatus) { LogAlways("[OTNS] %s", aStatus); }
|
||||
void otPlatOtnsStatus(const char *aStatus)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aStatus);
|
||||
LogAlways("[OTNS] %s", aStatus);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_OTNS_ENABLE
|
||||
|
||||
@@ -76,7 +76,8 @@ typedef struct otCliCommand
|
||||
*
|
||||
* @returns Number of bytes written by the callback.
|
||||
*/
|
||||
typedef int (*otCliOutputCallback)(void *aContext, const char *aFormat, va_list aArguments);
|
||||
typedef int (*otCliOutputCallback)(void *aContext, const char *aFormat, va_list aArguments)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
|
||||
/**
|
||||
* Initialize the CLI module.
|
||||
|
||||
@@ -52,7 +52,7 @@ extern "C" {
|
||||
*
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (566)
|
||||
#define OPENTHREAD_API_VERSION (567)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -135,7 +136,8 @@ otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen);
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] aArgs va_list matching aFormat.
|
||||
*/
|
||||
void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs);
|
||||
void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(3, 0);
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// Peek/Poke memory access control delegates
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -82,7 +83,7 @@ extern "C" {
|
||||
*
|
||||
* This is a WEAK symbol that can easily be overridden as needed.
|
||||
*/
|
||||
void otPlatDebugUart_printf(const char *fmt, ...);
|
||||
void otPlatDebugUart_printf(const char *fmt, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
/**
|
||||
* Standard vprintf() to the debug uart, with no log decoration.
|
||||
@@ -100,7 +101,7 @@ void otPlatDebugUart_printf(const char *fmt, ...);
|
||||
* symbol because the platform provides a UART_vprintf() like
|
||||
* function that can handle an arbitrary length output.
|
||||
*/
|
||||
void otPlatDebugUart_vprintf(const char *fmt, va_list ap);
|
||||
void otPlatDebugUart_vprintf(const char *fmt, va_list ap) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 0);
|
||||
|
||||
/**
|
||||
* Platform specific write single byte to Debug Uart
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <openthread/error.h>
|
||||
#include <openthread/instance.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -72,7 +73,8 @@ typedef enum
|
||||
* @param[in] aArguments The format string arguments.
|
||||
* @param[out] aContext A pointer to the user context.
|
||||
*/
|
||||
typedef void (*otPlatDiagOutputCallback)(const char *aFormat, va_list aArguments, void *aContext);
|
||||
typedef void (*otPlatDiagOutputCallback)(const char *aFormat, va_list aArguments, void *aContext)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 0);
|
||||
|
||||
/**
|
||||
* Sets the platform diag output callback.
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#ifndef OPENTHREAD_PLATFORM_LOGGING_H_
|
||||
#define OPENTHREAD_PLATFORM_LOGGING_H_
|
||||
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -146,7 +148,8 @@ typedef enum otLogRegion
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*/
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...);
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(3, 4);
|
||||
|
||||
/**
|
||||
* Handles OpenThread log level changes.
|
||||
|
||||
+3
-2
@@ -324,8 +324,9 @@ private:
|
||||
#endif // OPENTHREAD_FTD || OPENTHREAD_MTD
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
static void HandleDiagOutput(const char *aFormat, va_list aArguments, void *aContext);
|
||||
void HandleDiagOutput(const char *aFormat, va_list aArguments);
|
||||
static void HandleDiagOutput(const char *aFormat, va_list aArguments, void *aContext)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 0);
|
||||
void HandleDiagOutput(const char *aFormat, va_list aArguments) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
#endif
|
||||
|
||||
void SetCommandTimeout(uint32_t aTimeoutMilli);
|
||||
|
||||
@@ -553,7 +553,10 @@ public:
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
OutputLine(FormatStringFor<ValueType>(), aGetHandler(GetInstancePtr()));
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -755,14 +758,10 @@ template <> inline constexpr const char *Utils::FormatStringFor<uint8_t>(void) {
|
||||
|
||||
template <> inline constexpr const char *Utils::FormatStringFor<uint16_t>(void) { return "%u"; }
|
||||
|
||||
template <> inline constexpr const char *Utils::FormatStringFor<uint32_t>(void) { return "%lu"; }
|
||||
|
||||
template <> inline constexpr const char *Utils::FormatStringFor<int8_t>(void) { return "%d"; }
|
||||
|
||||
template <> inline constexpr const char *Utils::FormatStringFor<int16_t>(void) { return "%d"; }
|
||||
|
||||
template <> inline constexpr const char *Utils::FormatStringFor<int32_t>(void) { return "%ld"; }
|
||||
|
||||
template <> inline constexpr const char *Utils::FormatStringFor<const char *>(void) { return "%s"; }
|
||||
|
||||
// Specialization of ProcessGet<> for `uint32_t` and `int32_t`
|
||||
@@ -772,7 +771,8 @@ template <> inline otError Utils::ProcessGet<uint32_t>(Arg aArgs[], GetHandler<u
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
|
||||
OutputLine(FormatStringFor<uint32_t>(), ToUlong(aGetHandler(GetInstancePtr())));
|
||||
static_assert(sizeof(unsigned long) >= sizeof(uint32_t), "OpenThread assumes unsigned long is at least 32bit");
|
||||
OutputLine("%lu", ToUlong(aGetHandler(GetInstancePtr())));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -783,7 +783,8 @@ template <> inline otError Utils::ProcessGet<int32_t>(Arg aArgs[], GetHandler<in
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
|
||||
OutputLine(FormatStringFor<int32_t>(), static_cast<long int>(aGetHandler(GetInstancePtr())));
|
||||
static_assert(sizeof(long) >= sizeof(int32_t), "OpenThread assumes long is at least 32bit");
|
||||
OutputLine("%ld", static_cast<long int>(aGetHandler(GetInstancePtr())));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -661,13 +661,15 @@ protected:
|
||||
static unsigned int ConvertLogRegion(otLogRegion aLogRegion);
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
static void HandleDiagOutput_Jump(const char *aFormat, va_list aArguments, void *aContext);
|
||||
void HandleDiagOutput(const char *aFormat, va_list aArguments);
|
||||
static void HandleDiagOutput_Jump(const char *aFormat, va_list aArguments, void *aContext)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 0);
|
||||
void HandleDiagOutput(const char *aFormat, va_list aArguments) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_NCP_CLI_STREAM_ENABLE
|
||||
static int HandleCliOutput(void *aContext, const char *aFormat, va_list aArguments);
|
||||
int HandleCliOutput(const char *aFormat, va_list aArguments);
|
||||
static int HandleCliOutput(void *aContext, const char *aFormat, va_list aArguments)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
int HandleCliOutput(const char *aFormat, va_list aArguments) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
|
||||
|
||||
@@ -73,6 +73,9 @@ static void InputCallback(char *aLine)
|
||||
}
|
||||
}
|
||||
|
||||
static int OutputCallback(void *aContext, const char *aFormat, va_list aArguments)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
|
||||
static int OutputCallback(void *aContext, const char *aFormat, va_list aArguments)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
|
||||
namespace {
|
||||
|
||||
int OutputCallback(void *aContext, const char *aFormat, va_list aArguments) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
|
||||
int OutputCallback(void *aContext, const char *aFormat, va_list aArguments)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
#include <cutils/sockets.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -62,20 +60,17 @@ namespace {
|
||||
|
||||
typedef char(Filename)[sizeof(sockaddr_un::sun_path)];
|
||||
|
||||
void GetFilename(Filename &aFilename, const char *aPattern)
|
||||
{
|
||||
int rval;
|
||||
const char *netIfName = strlen(gNetifName) > 0 ? gNetifName : OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME;
|
||||
|
||||
rval = snprintf(aFilename, sizeof(aFilename), aPattern, netIfName);
|
||||
if (rval < 0 && static_cast<size_t>(rval) >= sizeof(aFilename))
|
||||
{
|
||||
DieNow(OT_EXIT_INVALID_ARGUMENTS);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// using macro to avoid the warning about format-nonliteral
|
||||
#define GetFilename(aFilename, aPattern) \
|
||||
do \
|
||||
{ \
|
||||
int rval = snprintf(aFilename, sizeof(aFilename), aPattern, \
|
||||
(gNetifName[0] ? gNetifName : OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME)); \
|
||||
VerifyOrDie(rval > 0 && static_cast<size_t>(rval) < sizeof(aFilename), OT_EXIT_INVALID_ARGUMENTS); \
|
||||
} while (0)
|
||||
|
||||
const char Daemon::kLogModuleName[] = "Daemon";
|
||||
|
||||
int Daemon::OutputFormat(const char *aFormat, ...)
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
|
||||
#include "openthread-posix-config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#include "core/common/non_copyable.hpp"
|
||||
|
||||
#include "logger.hpp"
|
||||
@@ -49,10 +53,10 @@ public:
|
||||
void TearDown(void);
|
||||
void Update(Mainloop::Context &aContext) override;
|
||||
void Process(const Mainloop::Context &aContext) override;
|
||||
int OutputFormatV(const char *aFormat, va_list aArguments);
|
||||
int OutputFormatV(const char *aFormat, va_list aArguments) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
|
||||
private:
|
||||
int OutputFormat(const char *aFormat, ...);
|
||||
int OutputFormat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3);
|
||||
void createListenSocketOrDie(void);
|
||||
void InitializeSessionSocket(void);
|
||||
|
||||
|
||||
@@ -296,6 +296,12 @@ static bool sIsSyncingState = false;
|
||||
|
||||
static const char kLogModuleName[] = "Netif";
|
||||
|
||||
static void LogCrit(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
static void LogWarn(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
static void LogNote(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
static void LogInfo(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
static void LogDebg(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
static void LogCrit(const char *aFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "common/code_utils.hpp"
|
||||
#include "common/new.hpp"
|
||||
#include "common/string.hpp"
|
||||
#include "posix/platform/radio.hpp"
|
||||
#include "posix/platform/spinel_driver_getter.hpp"
|
||||
#include "posix/platform/spinel_manager.hpp"
|
||||
@@ -568,6 +569,9 @@ static void *sDiagCallbackContext = nullptr;
|
||||
static char *sDiagOutput = nullptr;
|
||||
static uint16_t sDiagOutputLen = 0;
|
||||
|
||||
static void handleDiagOutput(const char *aFormat, va_list aArguments, void *aContext)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 0);
|
||||
|
||||
static void handleDiagOutput(const char *aFormat, va_list aArguments, void *aContext)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
@@ -763,15 +767,15 @@ otError otPlatDiagRadioGetPowerSettings(otInstance *aInstance,
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
static constexpr uint16_t kRawPowerStringSize = OPENTHREAD_CONFIG_POWER_CALIBRATION_RAW_POWER_SETTING_SIZE * 2 + 1;
|
||||
static constexpr uint16_t kFmtStringSize = 100;
|
||||
|
||||
otError error;
|
||||
char cmd[OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE];
|
||||
char output[OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE];
|
||||
int targetPower;
|
||||
int actualPower;
|
||||
char rawPowerSetting[kRawPowerStringSize];
|
||||
char fmt[kFmtStringSize];
|
||||
char rawPowerSetting[OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE];
|
||||
|
||||
static_assert(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE >= kRawPowerStringSize, "RawPowerSetting too large");
|
||||
|
||||
assert((aTargetPower != nullptr) && (aActualPower != nullptr) && (aRawPowerSetting != nullptr) &&
|
||||
(aRawPowerSettingLength != nullptr));
|
||||
@@ -780,9 +784,10 @@ otError otPlatDiagRadioGetPowerSettings(otInstance *aInstance,
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "powersettings %d", aChannel);
|
||||
SuccessOrExit(error = GetRadioSpinel().PlatDiagProcess(cmd));
|
||||
snprintf(fmt, sizeof(fmt), "TargetPower(0.01dBm): %%d\r\nActualPower(0.01dBm): %%d\r\nRawPowerSetting: %%%us\r\n",
|
||||
kRawPowerStringSize);
|
||||
VerifyOrExit(sscanf(output, fmt, &targetPower, &actualPower, rawPowerSetting) == 3, error = OT_ERROR_FAILED);
|
||||
output[sizeof(output) - 1] = ot::kNullChar;
|
||||
VerifyOrExit(sscanf(output, "TargetPower(0.01dBm): %d\r\nActualPower(0.01dBm): %d\r\nRawPowerSetting: %s\r\n",
|
||||
&targetPower, &actualPower, rawPowerSetting) == 3,
|
||||
error = OT_ERROR_FAILED);
|
||||
SuccessOrExit(
|
||||
error = ot::Utils::CmdLineParser::ParseAsHexString(rawPowerSetting, *aRawPowerSettingLength, aRawPowerSetting));
|
||||
*aTargetPower = static_cast<int16_t>(targetPower);
|
||||
|
||||
@@ -126,13 +126,14 @@ private:
|
||||
void OutputExtendedSrcMatchTableSize(void);
|
||||
void OutputShortSrcMatchTableSize(void);
|
||||
|
||||
static void HandleDiagOutput(const char *aFormat, va_list aArguments, void *aContext);
|
||||
void HandleDiagOutput(const char *aFormat, va_list aArguments);
|
||||
static void HandleDiagOutput(const char *aFormat, va_list aArguments, void *aContext)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 0);
|
||||
void HandleDiagOutput(const char *aFormat, va_list aArguments) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
|
||||
void OutputFormat(const char *aName, const char *aValue);
|
||||
void OutputFormat(const char *aName, uint32_t aValue);
|
||||
void OutputResult(const SpinelEntry &aEntry, otError error);
|
||||
void Output(const char *aFormat, ...);
|
||||
void Output(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3);
|
||||
|
||||
static const char *SupportToString(bool aSupport);
|
||||
static const char *RadioCapbilityToString(uint32_t aCapability);
|
||||
|
||||
@@ -497,13 +497,14 @@ void otSysMainloopProcess(otInstance *aInstance, const otSysMainloopContext *aMa
|
||||
bool IsSystemDryRun(void) { return gDryRun; }
|
||||
|
||||
#if OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE && OPENTHREAD_POSIX_CONFIG_DAEMON_CLI_ENABLE
|
||||
void otSysCliInitUsingDaemon(otInstance *aInstance)
|
||||
namespace {
|
||||
int OutputCallback(void *aContext, const char *aFormat, va_list aArguments) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
|
||||
int OutputCallback(void *aContext, const char *aFormat, va_list aArguments)
|
||||
{
|
||||
otCliInit(
|
||||
aInstance,
|
||||
[](void *aContext, const char *aFormat, va_list aArguments) -> int {
|
||||
return static_cast<ot::Posix::Daemon *>(aContext)->OutputFormatV(aFormat, aArguments);
|
||||
},
|
||||
&ot::Posix::Daemon::Get());
|
||||
return static_cast<ot::Posix::Daemon *>(aContext)->OutputFormatV(aFormat, aArguments);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void otSysCliInitUsingDaemon(otInstance *aInstance) { otCliInit(aInstance, OutputCallback, &ot::Posix::Daemon::Get()); }
|
||||
#endif
|
||||
|
||||
@@ -79,6 +79,12 @@ static int sSocket = -1;
|
||||
|
||||
static const char kLogModuleName[] = "Trel";
|
||||
|
||||
static void LogCrit(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
static void LogWarn(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
static void LogNote(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
static void LogInfo(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
static void LogDebg(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
static void LogCrit(const char *aFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
@@ -67,7 +67,7 @@ int SocketWithCloseExec(int aDomain, int aType, int aProtocol, SocketBlockOption
|
||||
* @retval OT_ERROR_NONE The command was executed successfully.
|
||||
* @retval OT_ERROR_FAILED It failed to execute the command.
|
||||
*/
|
||||
otError ExecuteCommand(const char *aFormat, ...);
|
||||
otError ExecuteCommand(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
|
||||
|
||||
} // namespace Posix
|
||||
} // namespace ot
|
||||
|
||||
Reference in New Issue
Block a user