Skip to content

[fix] Fix compilation error that occurs when USE_LOG4CXX is ON#244

Merged
BewareMyPower merged 1 commit into
apache:mainfrom
massakam:fix-logger-switch
Apr 6, 2023
Merged

[fix] Fix compilation error that occurs when USE_LOG4CXX is ON#244
BewareMyPower merged 1 commit into
apache:mainfrom
massakam:fix-logger-switch

Conversation

@massakam
Copy link
Copy Markdown
Contributor

@massakam massakam commented Apr 6, 2023

Motivation

When I tried to compile with the USE_LOG4CXX option ON, it failed with the following error:

/pulsar-client-cpp/lib/Log4cxxLogger.cc: In static member function 'static log4cxx::LevelPtr pulsar::Log4CxxLogger::getLevel(pulsar::Logger::Level)':
/pulsar-client-cpp/lib/Log4cxxLogger.cc:63:5: error: control reaches end of non-void function [-Werror=return-type]
     }
     ^

The reason seems to be that there is no default branch in the switch statement in Log4CxxLogger::getLevel, and control may reach the end of the function without returning anything.

static log4cxx::LevelPtr getLevel(Level level) {
switch (level) {
case LEVEL_DEBUG:
return log4cxx::Level::getDebug();
case LEVEL_INFO:
return log4cxx::Level::getInfo();
case LEVEL_WARN:
return log4cxx::Level::getWarn();
case LEVEL_ERROR:
return log4cxx::Level::getError();
}
}

Modifications

Added the default branch to the switch statement. This branch returns INFO.

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

@massakam massakam added the bug Something isn't working label Apr 6, 2023
@massakam massakam added this to the 3.2.0 milestone Apr 6, 2023
@massakam massakam self-assigned this Apr 6, 2023
@BewareMyPower BewareMyPower merged commit 0088a64 into apache:main Apr 6, 2023
@massakam massakam deleted the fix-logger-switch branch April 7, 2023 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants