Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-133

Missing parenthesis in LOG4CXX_ASSERT

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 0.9.7
    • 0.10.0
    • None
    • None

    Description

      On Apr 11, 2006, at 4:13 AM, Ondrej Pacovsky wrote:

      Hi, I'd just like to note that the LOG4CXX_ASSERT macro might be a bit dangerous because of its usage of the "condition" param:

      #define LOG4CXX_ASSERT(logger, condition, message) { \
      if (!condition && logger->isErrorEnabled()) {\
      logger->forcedLog(::log4cxx::Level::getError(), message, LOG4CXX_LOCATION); }}

      when used e.g. as LOG4CXX_ASSERT(lmain, false || true, "damn"), it producess the error message when it shouldn't.

      FIX: use parentheses
      #define LOG4CXX_ASSERT(logger, condition, message) { \
      if (!(condition) && logger->isErrorEnabled()) {\
      logger->forcedLog(::log4cxx::Level::getError(), message, LOG4CXX_LOCATION); }}

      cheers,
      Ondrej

      Attachments

        Activity

          People

            carnold@apache.org Curt Arnold
            carnold@apache.org Curt Arnold
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: