Skip to content

Commit

Permalink
Fix log.cpp when compiled with executorch.enable_et_log=false (pyto…
Browse files Browse the repository at this point in the history
…rch#4358)

Summary:
Pull Request resolved: pytorch#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
  • Loading branch information
tarun292 authored and facebook-github-bot committed Jul 23, 2024
1 parent 48da61a commit fd2dccf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions runtime/platform/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit fd2dccf

Please sign in to comment.