From fd2dccf5172ab4a037ff41ef30c42208b54b0cfc Mon Sep 17 00:00:00 2001 From: Tarun Karuturi Date: Tue, 23 Jul 2024 16:56:24 -0700 Subject: [PATCH] Fix log.cpp when compiled with `executorch.enable_et_log=false` (#4358) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/4358 Currently, the ASR execution fails with the following error: `xplat/executorch/runtime/platform/log.cpp:21:25: error: unused variable 'kMaxLogMessageLength' [-Werror,-Wunused-const-variable]` (P1484525874). This diff marks kMaxLogMessageLength as `maybe_unused`. Reviewed By: dbort, dvorjackz Differential Revision: D59641404 fbshipit-source-id: 2a7e324206eb5a31e309dadc4ee3d6c5dc6f68dc --- runtime/platform/log.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/runtime/platform/log.cpp b/runtime/platform/log.cpp index c60b47392e..2c618e8fd9 100644 --- a/runtime/platform/log.cpp +++ b/runtime/platform/log.cpp @@ -17,9 +17,6 @@ namespace torch { namespace executor { namespace internal { -/// Maximum length of a log message. -static constexpr size_t kMaxLogMessageLength = 256; - /** * Get the current timestamp to construct a log event. * @@ -85,6 +82,8 @@ void vlogf( va_list args) { #if ET_LOG_ENABLED + // Maximum length of a log message. + static constexpr size_t kMaxLogMessageLength = 256; char buf[kMaxLogMessageLength]; size_t len = vsnprintf(buf, kMaxLogMessageLength, format, args); if (len >= kMaxLogMessageLength - 1) {