Skip to content

Commit

Permalink
Fix clang warnings -Wformat-nonliteral (#17864)
Browse files Browse the repository at this point in the history
../../third_party/connectedhomeip/src/platform/nxp/k32w/k32w0/Logging.cpp:169:16: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
    GenericLog(msg, v, module, chip::Logging::kLogCategory_None);
               ^~~
../../third_party/connectedhomeip/src/platform/nxp/k32w/k32w0/Logging.cpp:187:16: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
    GenericLog(aFormat, v, module, chip::Logging::kLogCategory_None);
               ^~~~~~~
2 errors generated.
  • Loading branch information
mspang authored and pull[bot] committed Oct 2, 2023
1 parent 9223267 commit 2657820
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/support/EnforceFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* varargs.
*/

#if defined(__GNUC__)
#if defined(__GNUC__) || defined(__clang__)
#define ENFORCE_FORMAT(n, m) __attribute__((format(printf, n, m)))
#else // __GNUC__
#define ENFORCE_FORMAT(n, m) /* How to do with MSVC? */
Expand Down
4 changes: 2 additions & 2 deletions src/platform/nxp/k32w/k32w0/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char
/**
* LwIP log output function.
*/
extern "C" void LwIPLog(const char * msg, ...)
extern "C" void ENFORCE_FORMAT(1, 2) LwIPLog(const char * msg, ...)
{
va_list v;
const char * module = "LWIP";
Expand All @@ -174,7 +174,7 @@ extern "C" void LwIPLog(const char * msg, ...)
#undef K32W_LOG_MODULE_NAME
#define K32W_LOG_MODULE_NAME thread

extern "C" void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, ...)
extern "C" void ENFORCE_FORMAT(3, 4) otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, ...)
{
va_list v;
const char * module = "OT";
Expand Down
7 changes: 7 additions & 0 deletions third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/k32w0_sdk.gni")
import("//build_overrides/openthread.gni")

import("${build_root}/config/compiler/compiler.gni")
import("${chip_root}/third_party/nxp/k32w0_sdk/k32w0_sdk.gni")

openthread_nxp_root = "${chip_root}/third_party/openthread/ot-nxp"
Expand All @@ -23,6 +26,10 @@ config("openthread_k32w0_config") {
include_dirs = [ "${openthread_nxp_root}/src/k32w0/k32w061" ]
include_dirs += [ "${chip_root}/examples/platform/nxp/k32w/k32w0" ]

if (is_clang) {
cflags = [ "-Wno-format-nonliteral" ]
}

defines = [
"OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1",
"OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1",
Expand Down

0 comments on commit 2657820

Please sign in to comment.